Jay
2024-11-25 ee9f604388a3e77d3f4654e326f3976552e7f532
提交 | 用户 | 时间
a477ef 1 package com.iailab.module.data.channel.opcda.controller.admin;
9d7e02 2
aecc49 3 import com.iailab.framework.common.pojo.CommonResult;
L 4 import com.iailab.framework.common.pojo.PageResult;
5 import com.iailab.framework.common.util.object.BeanUtils;
9d7e02 6 import com.iailab.module.data.channel.opcda.entity.ChannelOPCDADeviceEntity;
7 import com.iailab.module.data.channel.opcda.service.ChannelOPCDADeviceService;
aecc49 8 import com.iailab.module.data.channel.opcda.vo.OpcDaDevicePageReqVO;
L 9 import com.iailab.module.data.channel.opcda.vo.OpcDaDeviceRespVO;
9d7e02 10 import org.springframework.beans.factory.annotation.Autowired;
a477ef 11 import org.springframework.security.access.prepost.PreAuthorize;
9d7e02 12 import org.springframework.web.bind.annotation.*;
13
aecc49 14 import javax.validation.Valid;
9d7e02 15 import java.util.Date;
16 import java.util.UUID;
aecc49 17
L 18 import static com.iailab.framework.common.pojo.CommonResult.success;
9d7e02 19
20 /**
21  * 操作opc ua配置
aecc49 22  * @author lirm
L 23  * @Description
24  * @createTime 2024年08月26日
9d7e02 25  */
26 @RestController
aecc49 27 @RequestMapping("/data/channel/opcda/device")
9d7e02 28 public class ChannelOPCDADeviceController {
29     @Autowired
30     private ChannelOPCDADeviceService channelOPCDADeviceService;
31
a477ef 32     @PreAuthorize("@ss.hasPermission('data:channel-opcda:query')")
aecc49 33     @GetMapping("page")
L 34     public CommonResult<PageResult<OpcDaDeviceRespVO>> list(@Valid OpcDaDevicePageReqVO reqVO) {
35         PageResult<ChannelOPCDADeviceEntity> page = channelOPCDADeviceService.queryPage(reqVO);
36         return success(BeanUtils.toBean(page, OpcDaDeviceRespVO.class));
9d7e02 37     }
38
a477ef 39     @PreAuthorize("@ss.hasPermission('data:channel-opcda:query')")
9d7e02 40     @GetMapping("/info/{id}")
aecc49 41     public CommonResult<ChannelOPCDADeviceEntity> info(@PathVariable("id") String id) {
9d7e02 42         ChannelOPCDADeviceEntity info = channelOPCDADeviceService.info(id);
aecc49 43         return success(info);
9d7e02 44     }
45
a477ef 46     @PreAuthorize("@ss.hasPermission('data:channel-opcda:create')")
47     @PostMapping("/create")
48     public CommonResult<Boolean> create(@RequestBody ChannelOPCDADeviceEntity channelOPCDADeviceEntity) {
9d7e02 49         String id = UUID.randomUUID().toString();
50         channelOPCDADeviceEntity.setId(id);
51         channelOPCDADeviceEntity.setCreateTime(new Date());
52         channelOPCDADeviceService.add(channelOPCDADeviceEntity);
aecc49 53         return success(true);
9d7e02 54     }
55
a477ef 56     @PreAuthorize("@ss.hasPermission('data:channel-opcda:update')")
aecc49 57     @PutMapping("/update")
L 58     public CommonResult<Boolean> update(@RequestBody ChannelOPCDADeviceEntity channelOPCDADeviceEntity) {
9d7e02 59         channelOPCDADeviceEntity.setUpdateTime(new Date());
60         channelOPCDADeviceService.update(channelOPCDADeviceEntity);
aecc49 61         return success(true);
9d7e02 62     }
63
a477ef 64     @PreAuthorize("@ss.hasPermission('data:channel-opcda:delete')")
aecc49 65     @DeleteMapping("/delete")
L 66     public CommonResult<Boolean> delete(@RequestParam("id") String id) {
9d7e02 67         channelOPCDADeviceService.delete(id);
aecc49 68         return success(true);
9d7e02 69     }
70 }