package com.backendsys.modules.material.controller;

import com.backendsys.modules.common.config.security.annotations.Anonymous;
import com.backendsys.modules.material.entity.MaterialTag;
import com.backendsys.modules.material.service.MaterialTagService;
import com.backendsys.modules.common.utils.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@Validated
@RestController
@Tag(name = "素材标签管理")
public class MaterialTagController {

    @Autowired
    private MaterialTagService materialTagService;

    @Operation(summary = "获取素材标签列表")
    @PreAuthorize("@sr.hasPermission('20.3')")
    @GetMapping("/api/material/getMaterialTagList")
    public Result getMaterialTagList(@Validated(MaterialTag.TagList.class) MaterialTag materialTag) {
        return Result.success().put("data", materialTagService.selectMaterialTagList(materialTag));
    }

    @Anonymous
    @Operation(summary = "获取素材标签列表(下拉)")
    @GetMapping("/api/material/getMaterialTagPopover")
    public Result getMaterialTagPopover(@Validated(MaterialTag.TagList.class) MaterialTag materialTag) {
        return Result.success().put("data", materialTagService.selectMaterialTagPopover(materialTag));
    }

}
