dengzedong
2024-10-14 3e18d4bfbf2c657b08b21512c2d884cc9d59df7b
提交 | 用户 | 时间
a6de49 1 package com.iailab.module.data.channel.opcua.controller.admin;
H 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;
a6de49 6 import com.iailab.module.data.channel.opcua.entity.ChannelOPCUATagEntity;
H 7 import com.iailab.module.data.channel.opcua.service.ChannelOPCUATagService;
aecc49 8 import com.iailab.module.data.channel.opcua.vo.OpcUaTagPageReqVO;
L 9 import com.iailab.module.data.channel.opcua.vo.OpcUaTagRespVO;
a477ef 10 import org.springframework.security.access.prepost.PreAuthorize;
a6de49 11 import org.springframework.web.bind.annotation.*;
H 12
aecc49 13 import javax.annotation.Resource;
L 14 import javax.validation.Valid;
15 import java.util.Date;
a6de49 16 import java.util.UUID;
aecc49 17
L 18 import static com.iailab.framework.common.pojo.CommonResult.success;
a6de49 19
H 20 /**
21  * 操作opcua tag配置
aecc49 22  * @author lirm
L 23  * @Description
24  * @createTime 2024年08月26日
a6de49 25  */
H 26 @RestController
27 @RequestMapping("/data/channel/opcua/tag")
28 public class ChannelOPCUATagController {
29     @Resource
30     private ChannelOPCUATagService channelOpcuaTagService;
31
a477ef 32     @PreAuthorize("@ss.hasPermission('data:channel-opcua:query')")
aecc49 33     @GetMapping("page")
L 34     public CommonResult<PageResult<OpcUaTagRespVO>> list(@Valid OpcUaTagPageReqVO reqVO) {
35         PageResult<ChannelOPCUATagEntity> page = channelOpcuaTagService.queryPage(reqVO);
36         return success(BeanUtils.toBean(page, OpcUaTagRespVO.class));
a6de49 37     }
aecc49 38
a477ef 39     @PreAuthorize("@ss.hasPermission('data:channel-opcua:query')")
a6de49 40     @GetMapping("/info/{id}")
aecc49 41     public CommonResult<ChannelOPCUATagEntity> info(@PathVariable("id") String id) {
L 42         ChannelOPCUATagEntity info = channelOpcuaTagService.info(id);
43         return success(info);
a6de49 44     }
aecc49 45
a477ef 46     @PreAuthorize("@ss.hasPermission('data:channel-opcua:create')")
47     @PostMapping("/create")
48     public CommonResult<Boolean> create(@RequestBody ChannelOPCUATagEntity channelOPCUATagEntity) {
aecc49 49         String id = UUID.randomUUID().toString();
L 50         channelOPCUATagEntity.setId(id);
51         channelOPCUATagEntity.setCreateTime(new Date());
52         channelOpcuaTagService.add(channelOPCUATagEntity);
53         return success(true);
a6de49 54     }
H 55
a477ef 56     @PreAuthorize("@ss.hasPermission('data:channel-opcua:update')")
aecc49 57     @PutMapping("/update")
L 58     public CommonResult<Boolean> update(@RequestBody ChannelOPCUATagEntity channelOPCUATagEntity) {
59         channelOPCUATagEntity.setUpdateTime(new Date());
a6de49 60         channelOpcuaTagService.update(channelOPCUATagEntity);
aecc49 61         return success(true);
a6de49 62     }
H 63
a477ef 64     @PreAuthorize("@ss.hasPermission('data:channel-opcua:delete')")
aecc49 65     @DeleteMapping("/delete")
L 66     public CommonResult<Boolean> delete(@RequestParam("id") String id) {
a6de49 67         channelOpcuaTagService.delete(id);
aecc49 68         return success(true);
a6de49 69     }
H 70
aecc49 71 //    @PostMapping("/import/{device}")
L 72 //    public R importTag(@PathVariable("device") String device, @RequestParam("file") MultipartFile file) {
73 //        try {
74 //            if (file.isEmpty()) {
75 //                throw new RRException("上传文件不能为空");
76 //            }
77 //            channelOpcuaTagService.importTag(device, file);
78 //        } catch (Exception ex) {
79 //            return R.error(ex.getMessage());
80 //        }
81 //        return R.ok();
82 //    }
a6de49 83 }