package com.iailab.module.data.ind.category.controller.admin; import com.iailab.framework.common.pojo.CommonResult; import com.iailab.framework.common.util.object.BeanUtils; import com.iailab.module.data.ind.category.entity.IndItemCategoryEntity; import com.iailab.module.data.ind.category.service.IndItemCategoryService; import com.iailab.module.data.ind.category.vo.IndItemCategoryReqVO; import com.iailab.module.data.ind.category.vo.IndItemCategoryRespVO; import com.iailab.module.data.ind.category.vo.IndItemCategorySaveReqVO; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; 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.*; import javax.validation.Valid; import java.util.Comparator; import java.util.List; import static com.iailab.framework.common.pojo.CommonResult.success; /** * @author PanZhibao * @Description * @createTime 2024年09月10日 */ @Tag(name = "数据平台 - 指标分类") @RestController @RequestMapping("/data/ind-item-category") @Validated public class IndItemCategoryController { @Autowired private IndItemCategoryService indItemCategoryService; @GetMapping("/list") @Operation(summary = "获取指标分类列表", description = "用于【指标分类】界面") @PreAuthorize("@ss.hasPermission('data:ind-item-category:query')") public CommonResult> getList(IndItemCategoryReqVO reqVO) { List list = indItemCategoryService.getList(reqVO); list.sort(Comparator.comparing(IndItemCategoryEntity::getSort)); return success(BeanUtils.toBean(list, IndItemCategoryRespVO.class)); } @PostMapping("/create") @Operation(summary = "创建指标分类") @PreAuthorize("@ss.hasPermission('data:ind-item-category:create')") public CommonResult createMenu(@Valid @RequestBody IndItemCategorySaveReqVO createReqVO) { indItemCategoryService.create(createReqVO); return success(true); } @PutMapping("/update") @Operation(summary = "修改指标分类") @PreAuthorize("@ss.hasPermission('data:ind-item-category:update')") public CommonResult updateMenu(@Valid @RequestBody IndItemCategorySaveReqVO updateReqVO) { indItemCategoryService.update(updateReqVO); return success(true); } @DeleteMapping("/delete") @Operation(summary = "删除指标分类") @Parameter(name = "id", description = "指标分类编号", required= true, example = "1024") @PreAuthorize("@ss.hasPermission('data:ind-item-category:delete')") public CommonResult deleteMenu(@RequestParam("id") String id) { indItemCategoryService.delete(id); return success(true); } @GetMapping("/get") @Operation(summary = "获取指标分类信息") @PreAuthorize("@ss.hasPermission('system:ind-item-category:query')") public CommonResult getMenu(String id) { IndItemCategoryEntity entity = indItemCategoryService.get(id); return success(BeanUtils.toBean(entity, IndItemCategoryRespVO.class)); } }