package com.iailab.module.data.channel.opcua.controller.admin; 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.module.data.channel.opcua.entity.ChannelOPCUADeviceEntity; import com.iailab.module.data.channel.opcua.service.ChannelOPCUADeviceService; import com.iailab.module.data.channel.opcua.vo.OpcUaDevicePageReqVO; import com.iailab.module.data.channel.opcua.vo.OpcUaDeviceRespVO; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.validation.Valid; import java.util.UUID; import static com.iailab.framework.common.pojo.CommonResult.success; /** * 操作opc ua配置 * @author lirm * @Description * @createTime 2024年08月26日 */ @RestController @RequestMapping("/data/channel/opcua/device") public class ChannelOPCUADeviceController { @Resource private ChannelOPCUADeviceService channelOPCUADeviceService; @PreAuthorize("@ss.hasPermission('data:channel-opcua:query')") @GetMapping("page") public CommonResult> list(@Valid OpcUaDevicePageReqVO reqVO) { PageResult page = channelOPCUADeviceService.queryPage(reqVO); return success(BeanUtils.toBean(page, OpcUaDeviceRespVO.class)); } @PreAuthorize("@ss.hasPermission('data:channel-opcua:query')") @GetMapping("/info/{id}") public CommonResult info(@PathVariable("id") String id) { ChannelOPCUADeviceEntity info = channelOPCUADeviceService.info(id); return success(info); } @PreAuthorize("@ss.hasPermission('data:channel-opcua:create')") @PostMapping("/create") public CommonResult create(@RequestBody ChannelOPCUADeviceEntity channelOPCUADeviceEntity) { String id = UUID.randomUUID().toString(); channelOPCUADeviceEntity.setId(id); channelOPCUADeviceService.add(channelOPCUADeviceEntity); return success(true); } @PreAuthorize("@ss.hasPermission('data:channel-opcua:update')") @PutMapping("/update") public CommonResult update(@RequestBody ChannelOPCUADeviceEntity channelOPCUADeviceEntity) { channelOPCUADeviceService.update(channelOPCUADeviceEntity); return success(true); } @PreAuthorize("@ss.hasPermission('data:channel-opcua:delete')") @DeleteMapping("/delete") public CommonResult delete(@RequestParam("id") String id) { channelOPCUADeviceService.delete(id); return success(true); } /** * 上传安全证书 * * @param file */ // @PostMapping("/upload") // public R uploadFile(@RequestParam("file") MultipartFile file) { // String fileName = file.getOriginalFilename(); // String filePath = ""; // try { // File dir = new File(filePath); // if (!dir.exists()) { // dir.mkdirs(); // } // File saveFile = new File(filePath + fileName); // file.transferTo(saveFile); // return R.ok().put("data",saveFile.getAbsolutePath()); // } catch (IOException e) { // e.printStackTrace(); // return R.error(); // } // } }