package com.backendsys.modules.material.controller;

import com.backendsys.modules.common.config.security.annotations.Anonymous;
import com.backendsys.modules.material.entity.MaterialCategory;
import com.backendsys.modules.material.service.MaterialCategoryService;
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.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@Validated
@RestController
@Tag(name = "素材分类管理")
public class MaterialCategoryController {

    @Autowired
    private MaterialCategoryService materialCategoryService;

    @Operation(summary = "获取素材分类列表")
//    @PreAuthorize("@sr.hasPermission('20.2')")
    @GetMapping("/api/material/getMaterialCategoryList")
    public Result getMaterialCategoryList(MaterialCategory materialCategory) {
        return Result.success().put("data", materialCategoryService.selectMaterialCategoryList(materialCategory));
    }

    @Anonymous
    @Operation(summary = "获取素材分类列表(下拉)")
    @GetMapping("/api/material/getMaterialCategoryPopover")
    public Result getMaterialCategoryPopover(MaterialCategory materialCategory) {
        return Result.success().put("data", materialCategoryService.selectMaterialCategoryPopover(materialCategory));
    }

}
