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