潘志宝
2024-11-04 a3a0726158dc82590ad591ca9b56f17c31fe9951
提交 | 用户 | 时间
8c1646 1 package com.iailab.module.data.plan.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.plan.category.entity.PlanItemCategoryEntity;
6 import com.iailab.module.data.plan.category.service.PlanItemCategoryService;
7 import com.iailab.module.data.plan.category.vo.PlanItemCategoryReqVO;
8 import com.iailab.module.data.plan.category.vo.PlanItemCategoryRespVO;
9 import com.iailab.module.data.plan.category.vo.PlanItemCategorySaveReqVO;
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年11月01日
28  */
29 @Tag(name = "数据平台 - 计划分类")
30 @RestController
31 @RequestMapping("/data/plan/category")
32 @Validated
33 public class PlanItemCategoryController {
34
35     @Autowired
36     private PlanItemCategoryService indItemCategoryService;
37
38     @GetMapping("/list")
39     @Operation(summary = "获取计划分类列表", description = "用于【计划分类】界面")
40     @PreAuthorize("@ss.hasPermission('data:plan-item-category:query')")
41     public CommonResult<List<PlanItemCategoryRespVO>> getList(PlanItemCategoryReqVO reqVO) {
42         List<PlanItemCategoryEntity> list = indItemCategoryService.getList(reqVO);
43         list.sort(Comparator.comparing(PlanItemCategoryEntity::getSort));
44         return success(BeanUtils.toBean(list, PlanItemCategoryRespVO.class));
45     }
46
47     @GetMapping("/list-all-simple")
48     @Operation(summary = "获取计划分类列表", description = "用于【计划分类】界面")
49     @PreAuthorize("@ss.hasPermission('data:plan-item-category:query')")
50     public CommonResult<List<PlanItemCategoryRespVO>> getList() {
51         List<PlanItemCategoryEntity> list = indItemCategoryService.getSimpleList();
52         list.sort(Comparator.comparing(PlanItemCategoryEntity::getSort));
53         return success(BeanUtils.toBean(list, PlanItemCategoryRespVO.class));
54     }
55
56     @PostMapping("/create")
57     @Operation(summary = "创建计划分类")
58     @PreAuthorize("@ss.hasPermission('data:plan-item-category:create')")
59     public CommonResult<Boolean> create(@Valid @RequestBody PlanItemCategorySaveReqVO createReqVO) {
60         indItemCategoryService.create(createReqVO);
61         return success(true);
62     }
63
64     @PutMapping("/update")
65     @Operation(summary = "修改计划分类")
66     @PreAuthorize("@ss.hasPermission('data:plan-item-category:update')")
67     public CommonResult<Boolean> update(@Valid @RequestBody PlanItemCategorySaveReqVO updateReqVO) {
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:plan-item-category:delete')")
76     public CommonResult<Boolean> delete(@RequestParam("id") String id) {
77         indItemCategoryService.delete(id);
78         return success(true);
79     }
80
81     @GetMapping("/get")
82     @Operation(summary = "获取计划分类信息")
83     @PreAuthorize("@ss.hasPermission('data:plan-item-category:query')")
84     public CommonResult<PlanItemCategoryRespVO> get(String id) {
85         PlanItemCategoryEntity entity = indItemCategoryService.get(id);
86         return success(BeanUtils.toBean(entity, PlanItemCategoryRespVO.class));
87     }
88 }