潘志宝
2024-12-15 bbe7acfbe5a4c08d6edc91eaf81dcecf9d630e18
提交 | 用户 | 时间
f1162e 1 package com.iailab.module.data.ind.category.controller.admin;
2
3 import com.iailab.framework.common.pojo.CommonResult;
4 import com.iailab.framework.common.util.object.BeanUtils;
5 import com.iailab.module.data.ind.category.entity.IndItemCategoryEntity;
6 import com.iailab.module.data.ind.category.service.IndItemCategoryService;
7 import com.iailab.module.data.ind.category.vo.IndItemCategoryReqVO;
8 import com.iailab.module.data.ind.category.vo.IndItemCategoryRespVO;
9 import com.iailab.module.data.ind.category.vo.IndItemCategorySaveReqVO;
10 import io.swagger.v3.oas.annotations.Operation;
11 import io.swagger.v3.oas.annotations.Parameter;
12 import io.swagger.v3.oas.annotations.tags.Tag;
13 import org.springframework.beans.factory.annotation.Autowired;
14 import org.springframework.security.access.prepost.PreAuthorize;
15 import org.springframework.validation.annotation.Validated;
16 import org.springframework.web.bind.annotation.*;
17
18 import javax.validation.Valid;
19 import java.util.Comparator;
20 import java.util.List;
21
22 import static com.iailab.framework.common.pojo.CommonResult.success;
23
24 /**
25  * @author PanZhibao
26  * @Description
27  * @createTime 2024年09月10日
28  */
29 @Tag(name = "数据平台 - 指标分类")
30 @RestController
cb49da 31 @RequestMapping("/data/ind/category")
f1162e 32 @Validated
33 public class IndItemCategoryController {
34
35     @Autowired
36     private IndItemCategoryService indItemCategoryService;
37
38     @GetMapping("/list")
39     @Operation(summary = "获取指标分类列表", description = "用于【指标分类】界面")
40     @PreAuthorize("@ss.hasPermission('data:ind-item-category:query')")
41     public CommonResult<List<IndItemCategoryRespVO>> getList(IndItemCategoryReqVO reqVO) {
42         List<IndItemCategoryEntity> list = indItemCategoryService.getList(reqVO);
cb49da 43         list.sort(Comparator.comparing(IndItemCategoryEntity::getSort));
44         return success(BeanUtils.toBean(list, IndItemCategoryRespVO.class));
45     }
46
47     @GetMapping("/list-all-simple")
48     @Operation(summary = "获取指标分类列表", description = "用于【指标分类】界面")
49     @PreAuthorize("@ss.hasPermission('data:ind-item-category:query')")
50     public CommonResult<List<IndItemCategoryRespVO>> getList() {
51         List<IndItemCategoryEntity> list = indItemCategoryService.getSimpleList();
f1162e 52         list.sort(Comparator.comparing(IndItemCategoryEntity::getSort));
53         return success(BeanUtils.toBean(list, IndItemCategoryRespVO.class));
54     }
55
56     @PostMapping("/create")
57     @Operation(summary = "创建指标分类")
58     @PreAuthorize("@ss.hasPermission('data:ind-item-category:create')")
a63a4f 59     public CommonResult<Boolean> create(@Valid @RequestBody IndItemCategorySaveReqVO createReqVO) {
f1162e 60         indItemCategoryService.create(createReqVO);
61         return success(true);
62     }
63
64     @PutMapping("/update")
65     @Operation(summary = "修改指标分类")
66     @PreAuthorize("@ss.hasPermission('data:ind-item-category:update')")
a63a4f 67     public CommonResult<Boolean> update(@Valid @RequestBody IndItemCategorySaveReqVO updateReqVO) {
f1162e 68         indItemCategoryService.update(updateReqVO);
69         return success(true);
70     }
71
72     @DeleteMapping("/delete")
73     @Operation(summary = "删除指标分类")
74     @Parameter(name = "id", description = "指标分类编号", required= true, example = "1024")
75     @PreAuthorize("@ss.hasPermission('data:ind-item-category:delete')")
a63a4f 76     public CommonResult<Boolean> delete(@RequestParam("id") String id) {
f1162e 77         indItemCategoryService.delete(id);
78         return success(true);
79     }
80
81     @GetMapping("/get")
82     @Operation(summary = "获取指标分类信息")
cb49da 83     @PreAuthorize("@ss.hasPermission('data:ind-item-category:query')")
a63a4f 84     public CommonResult<IndItemCategoryRespVO> get(String id) {
f1162e 85         IndItemCategoryEntity entity = indItemCategoryService.get(id);
86         return success(BeanUtils.toBean(entity, IndItemCategoryRespVO.class));
87     }
88 }