潘志宝
2024-09-12 ac6fb5406fccf2d9a0e39ae5e299c7fa207978da
提交 | 用户 | 时间
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.ChannelOPCUADeviceEntity;
H 7 import com.iailab.module.data.channel.opcua.service.ChannelOPCUADeviceService;
aecc49 8 import com.iailab.module.data.channel.opcua.vo.OpcUaDevicePageReqVO;
L 9 import com.iailab.module.data.channel.opcua.vo.OpcUaDeviceRespVO;
a6de49 10 import org.springframework.web.bind.annotation.*;
H 11
aecc49 12 import javax.annotation.Resource;
L 13 import javax.validation.Valid;
a6de49 14 import java.util.UUID;
aecc49 15
L 16 import static com.iailab.framework.common.pojo.CommonResult.success;
a6de49 17
H 18 /**
19  * 操作opc ua配置
aecc49 20  * @author lirm
L 21  * @Description
22  * @createTime 2024年08月26日
a6de49 23  */
H 24 @RestController
25 @RequestMapping("/data/channel/opcua/device")
26 public class ChannelOPCUADeviceController {
27     @Resource
28     private ChannelOPCUADeviceService channelOPCUADeviceService;
29
aecc49 30     @GetMapping("page")
L 31     public CommonResult<PageResult<OpcUaDeviceRespVO>> list(@Valid OpcUaDevicePageReqVO reqVO) {
32         PageResult<ChannelOPCUADeviceEntity> page = channelOPCUADeviceService.queryPage(reqVO);
33         return success(BeanUtils.toBean(page, OpcUaDeviceRespVO.class));
a6de49 34     }
H 35
36     @GetMapping("/info/{id}")
aecc49 37     public CommonResult<ChannelOPCUADeviceEntity> info(@PathVariable("id") String id) {
a6de49 38         ChannelOPCUADeviceEntity info = channelOPCUADeviceService.info(id);
aecc49 39         return success(info);
a6de49 40     }
H 41
42     @PostMapping("/add")
aecc49 43     public CommonResult<Boolean> add(@RequestBody ChannelOPCUADeviceEntity channelOPCUADeviceEntity) {
a6de49 44         String id = UUID.randomUUID().toString();
H 45         channelOPCUADeviceEntity.setId(id);
46         channelOPCUADeviceService.add(channelOPCUADeviceEntity);
aecc49 47         return success(true);
a6de49 48     }
H 49
aecc49 50     @PutMapping("/update")
L 51     public CommonResult<Boolean> update(@RequestBody ChannelOPCUADeviceEntity channelOPCUADeviceEntity) {
a6de49 52         channelOPCUADeviceService.update(channelOPCUADeviceEntity);
aecc49 53         return success(true);
a6de49 54     }
H 55
aecc49 56     @DeleteMapping("/delete")
L 57     public CommonResult<Boolean> delete(@RequestParam("id") String id) {
a6de49 58         channelOPCUADeviceService.delete(id);
aecc49 59         return success(true);
a6de49 60     }
H 61     /**
62      * 上传安全证书
63      *
64      * @param file
65      */
aecc49 66 //    @PostMapping("/upload")
L 67 //    public R uploadFile(@RequestParam("file") MultipartFile file) {
68 //        String fileName = file.getOriginalFilename();
69 //        String filePath = "";
70 //        try {
71 //            File dir = new File(filePath);
72 //            if (!dir.exists()) {
73 //                dir.mkdirs();
74 //            }
75 //            File saveFile = new File(filePath + fileName);
76 //            file.transferTo(saveFile);
77 //            return R.ok().put("data",saveFile.getAbsolutePath());
78 //        } catch (IOException e) {
79 //            e.printStackTrace();
80 //            return R.error();
81 //        }
82 //    }
a6de49 83 }