liriming
2024-09-26 2070c06b8cc7b370c3a149669017f4f183f0f172
提交 | 用户 | 时间
a6de49 1 package com.iailab.module.data.point.controller.admin;
H 2
3 import com.iailab.framework.common.pojo.CommonResult;
6bf63b 4 import com.iailab.framework.common.pojo.PageResult;
L 5 import com.iailab.framework.common.util.object.BeanUtils;
a6de49 6 import com.iailab.module.data.point.dto.DaPointDTO;
6bf63b 7 import com.iailab.module.data.point.entity.DaPointEntity;
a6de49 8 import com.iailab.module.data.point.service.DaPointService;
6bf63b 9 import com.iailab.module.data.point.vo.DaPointPageReqVO;
L 10 import com.iailab.module.data.point.vo.DaPointRespVO;
a6de49 11 import io.swagger.v3.oas.annotations.Operation;
H 12 import io.swagger.v3.oas.annotations.tags.Tag;
edac2e 13 import org.springframework.security.access.prepost.PreAuthorize;
a6de49 14 import org.springframework.transaction.annotation.Transactional;
H 15 import org.springframework.validation.annotation.Validated;
16 import org.springframework.web.bind.annotation.*;
17
6bf63b 18 import javax.annotation.Resource;
L 19 import javax.validation.Valid;
a6de49 20 import java.util.List;
H 21 import java.util.Map;
6bf63b 22 import java.util.UUID;
a6de49 23
H 24 import static com.iailab.framework.common.pojo.CommonResult.success;
25
26
27 /**
6bf63b 28  * @author lirm
a6de49 29  * @Description
6bf63b 30  * @createTime 2024年09月2日
a6de49 31  */
H 32 @Tag(name = "数据采集,测点")
33 @RestController
34 @RequestMapping("/data/da/point")
35 @Validated
36 public class DaPointController {
37
38     @Resource
39     private DaPointService daPointService;
40
edac2e 41     @PreAuthorize("@ss.hasPermission('data:point:query')")
a6de49 42     @GetMapping("page")
250190 43     public CommonResult<PageResult<DaPointDTO>> page(@Valid DaPointPageReqVO reqVO){
44         PageResult<DaPointDTO> page = daPointService.queryPage(reqVO);
45         return success(page);
a6de49 46     }
H 47
edac2e 48     @PreAuthorize("@ss.hasPermission('data:point:query')")
a6de49 49     @GetMapping("/list")
H 50     @Operation(summary = "列表")
51     public CommonResult<List<DaPointDTO>> list(@Valid @RequestParam Map<String, Object> params) {
52         List<DaPointDTO> list = daPointService.list(params);
53         return success(list);
54     }
55
edac2e 56     @PreAuthorize("@ss.hasPermission('data:point:query')")
6bf63b 57     @GetMapping("/info/{id}")
L 58     public CommonResult<DaPointDTO> info(@PathVariable("id") String id){
59         DaPointDTO info= daPointService.info(id);
60         return success(info);
a6de49 61     }
H 62
edac2e 63     @PreAuthorize("@ss.hasPermission('data:point:create')")
2070c0 64     @PostMapping("create")
edac2e 65     public CommonResult<Boolean> create(@RequestBody DaPointDTO daPointDTO){
6bf63b 66         String id = UUID.randomUUID().toString();
L 67         daPointDTO.setId(id);
68         daPointService.add(daPointDTO);
69         return success(true);
a6de49 70     }
H 71
edac2e 72     @PreAuthorize("@ss.hasPermission('data:point:update')")
6bf63b 73     @PutMapping("/update")
L 74     public CommonResult<Boolean> update(@RequestBody DaPointDTO daPointDTO) {
75         daPointService.update(daPointDTO);
76         return success(true);
77     }
78
edac2e 79     @PreAuthorize("@ss.hasPermission('data:point:delete')")
6bf63b 80     @DeleteMapping("/delete")
2070c0 81     public CommonResult<Boolean> delete(String id) {
L 82         daPointService.delete(new String[]{id});
6bf63b 83         return success(true);
a6de49 84     }
H 85
edac2e 86     @PreAuthorize("@ss.hasPermission('data:point:query')")
a6de49 87     @GetMapping("pointNo")
H 88     public CommonResult<List<DaPointDTO>> getpoint(@RequestParam Map<String, Object> params){
89         List<DaPointDTO> list = daPointService.list(params);
90
91         return new CommonResult<List<DaPointDTO>>().setData(list);
92     }
93
edac2e 94     @PreAuthorize("@ss.hasPermission('data:point:update')")
a6de49 95     @PutMapping("/enable")
H 96     @Operation(summary = "启用")
97     @Transactional
6bf63b 98     public CommonResult<Boolean> enable(@RequestBody String[] ids) {
a6de49 99         daPointService.enableByIds(ids);
6bf63b 100         return success(true);
a6de49 101     }
H 102
edac2e 103     @PreAuthorize("@ss.hasPermission('data:point:update')")
a6de49 104     @PutMapping("/disable")
H 105     @Operation(summary = "禁用")
106     @Transactional
6bf63b 107     public CommonResult<Boolean> disable(@RequestBody String[] ids) {
a6de49 108         daPointService.disableByIds(ids);
6bf63b 109         return success(true);
a6de49 110     }
H 111
112 }