潘志宝
2024-11-04 a3a0726158dc82590ad591ca9b56f17c31fe9951
提交 | 用户 | 时间
8c1646 1 package com.iailab.module.data.plan.item.controller.admin;
2
ed4f78 3 import com.iailab.framework.apilog.core.annotation.ApiAccessLog;
8c1646 4 import com.iailab.framework.common.pojo.CommonResult;
5 import com.iailab.framework.common.pojo.PageResult;
6 import com.iailab.framework.common.util.object.BeanUtils;
7 import com.iailab.framework.common.util.object.ConvertUtils;
ed4f78 8 import com.iailab.framework.excel.core.util.ExcelUtils;
9 import com.iailab.module.data.api.dto.ApiPointValueQueryDTO;
8c1646 10 import com.iailab.module.data.plan.item.entity.PlanItemEntity;
11 import com.iailab.module.data.plan.item.service.PlanItemService;
12 import com.iailab.module.data.plan.item.vo.PlanItemPageReqVO;
13 import com.iailab.module.data.plan.item.vo.PlanItemRespVO;
14 import com.iailab.module.data.plan.item.vo.PlanItemSaveReqVO;
ed4f78 15 import com.iailab.module.data.point.vo.PointValueExportVO;
8c1646 16 import io.swagger.v3.oas.annotations.Operation;
17 import io.swagger.v3.oas.annotations.Parameter;
18 import io.swagger.v3.oas.annotations.tags.Tag;
19 import org.springframework.beans.factory.annotation.Autowired;
20 import org.springframework.security.access.prepost.PreAuthorize;
21 import org.springframework.validation.annotation.Validated;
22 import org.springframework.web.bind.annotation.*;
23
ed4f78 24 import javax.servlet.http.HttpServletResponse;
8c1646 25 import javax.validation.Valid;
26
ed4f78 27 import java.io.IOException;
28 import java.text.ParseException;
29 import java.text.SimpleDateFormat;
30 import java.util.ArrayList;
31 import java.util.Date;
8c1646 32 import java.util.List;
33
ed4f78 34 import static com.iailab.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
8c1646 35 import static com.iailab.framework.common.pojo.CommonResult.success;
36
37 /**
38  * @author PanZhibao
39  * @Description
40  * @createTime 2024年11月01日
41  */
42 @Tag(name = "数据平台 - 计划数据项")
43 @RestController
44 @RequestMapping("/data/plan-item")
45 @Validated
46 public class PlanItemController {
47
48     @Autowired
49     private PlanItemService planItemService;
50
51     @GetMapping("/page")
52     @Operation(summary = "获取计划项列表", description = "用于【计划项】界面")
53     @PreAuthorize("@ss.hasPermission('data:plan-item:query')")
54     public CommonResult<PageResult<PlanItemRespVO>> page(PlanItemPageReqVO reqVO) {
55         PageResult<PlanItemEntity> page = planItemService.page(reqVO);
56         PageResult<PlanItemRespVO> result = BeanUtils.toBean(page, PlanItemRespVO.class);
57         return success(result);
58     }
59
60     @PostMapping("/create")
61     @Operation(summary = "创建计划项")
62     @PreAuthorize("@ss.hasPermission('data:plan-item:create')")
63     public CommonResult<Boolean> create(@Valid @RequestBody PlanItemSaveReqVO createReqVO) {
64         planItemService.create(createReqVO);
65         return success(true);
66     }
67
68     @PutMapping("/update")
69     @Operation(summary = "修改计划项")
70     @PreAuthorize("@ss.hasPermission('data:plan-item:update')")
71     public CommonResult<Boolean> update(@Valid @RequestBody PlanItemSaveReqVO updateReqVO) {
72         planItemService.update(updateReqVO);
73         return success(true);
74     }
75
76     @DeleteMapping("/delete")
77     @Operation(summary = "删除计划项")
78     @Parameter(name = "id", description = "计划项编号", required= true, example = "1024")
79     @PreAuthorize("@ss.hasPermission('data:plan-item:delete')")
80     public CommonResult<Boolean> delete(@RequestParam("id") String id) {
81         planItemService.delete(id);
82         return success(true);
83     }
84
85     @GetMapping("/get")
86     @Operation(summary = "获取计划项信息")
87     @PreAuthorize("@ss.hasPermission('data:plan-item:query')")
88     public CommonResult<PlanItemRespVO> get(@RequestParam("id") String id) {
89         PlanItemEntity entity = planItemService.get(id);
90         PlanItemRespVO respVO = BeanUtils.toBean(entity, PlanItemRespVO.class);
91         return success(respVO);
92     }
93
94     @GetMapping("/list")
95     @Operation(summary = "获取计划项列表", description = "用于【计划项】界面")
96     @PreAuthorize("@ss.hasPermission('data:plan-item:query')")
97     public CommonResult<List<PlanItemRespVO>> getList(PlanItemPageReqVO reqVO) {
98         List<PlanItemEntity> list = planItemService.list();
99         return success(ConvertUtils.sourceToTarget(list, PlanItemRespVO.class));
100     }
101 }