From 19eb2e43f1122bcca6c25effa6657f90651ae250 Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期二, 15 十月 2024 10:44:01 +0800 Subject: [PATCH] HttpCollectorIhDB --- iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/controller/admin/ChannelOPCUATagController.java | 129 ++++++++++++++++++------------------------ 1 files changed, 55 insertions(+), 74 deletions(-) diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/controller/admin/ChannelOPCUATagController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/controller/admin/ChannelOPCUATagController.java index 94f65c7..981ef30 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/controller/admin/ChannelOPCUATagController.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/controller/admin/ChannelOPCUATagController.java @@ -1,102 +1,83 @@ package com.iailab.module.data.channel.opcua.controller.admin; -import cn.hutool.core.codec.Base64; -import com.iailab.module.data.common.exception.RRException; -import com.iailab.module.data.common.utils.PageUtils; -import com.iailab.module.data.common.utils.R; +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.ChannelOPCUATagEntity; import com.iailab.module.data.channel.opcua.service.ChannelOPCUATagService; -import javax.annotation.Resource; +import com.iailab.module.data.channel.opcua.vo.OpcUaTagPageReqVO; +import com.iailab.module.data.channel.opcua.vo.OpcUaTagRespVO; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; -import java.util.Map; +import javax.annotation.Resource; +import javax.validation.Valid; +import java.util.Date; import java.util.UUID; + +import static com.iailab.framework.common.pojo.CommonResult.success; /** * 操作opcua tag配置 - * - * @author DongYukun - * @createTime 2023年05月6日 17:44:00 + * @author lirm + * @Description + * @createTime 2024年08月26日 */ @RestController @RequestMapping("/data/channel/opcua/tag") public class ChannelOPCUATagController { @Resource private ChannelOPCUATagService channelOpcuaTagService; - /** - * 分页查询tag - * - * @param params - */ - @GetMapping("/list") - public R tagList(@RequestParam Map<String, Object> params){ - PageUtils page = channelOpcuaTagService.queryPage(params); - return R.ok().put("page", page); + @PreAuthorize("@ss.hasPermission('data:channel-opcua:query')") + @GetMapping("page") + public CommonResult<PageResult<OpcUaTagRespVO>> list(@Valid OpcUaTagPageReqVO reqVO) { + PageResult<ChannelOPCUATagEntity> page = channelOpcuaTagService.queryPage(reqVO); + return success(BeanUtils.toBean(page, OpcUaTagRespVO.class)); } - /** - * 根据id查询tag详情 - * - * @param id - */ + + @PreAuthorize("@ss.hasPermission('data:channel-opcua:query')") @GetMapping("/info/{id}") - public R tagInfo(@PathVariable("id") String id){ - ChannelOPCUATagEntity info= channelOpcuaTagService.info(Base64.decodeStr(id)); - return R.ok().put("data", info); - } - /** - * 添加tag - * - * @param entity - */ - @PostMapping("/add") - public R tagAdd(@RequestBody ChannelOPCUATagEntity entity){ - entity.setId(UUID.randomUUID().toString()); - channelOpcuaTagService.add(entity); - return R.ok(); + public CommonResult<ChannelOPCUATagEntity> info(@PathVariable("id") String id) { + ChannelOPCUATagEntity info = channelOpcuaTagService.info(id); + return success(info); } - /** - * 修改tag - * - * @param channelOPCUATagEntity - */ - @PostMapping("/update") - public R tagUpdate(@RequestBody ChannelOPCUATagEntity channelOPCUATagEntity) { + @PreAuthorize("@ss.hasPermission('data:channel-opcua:create')") + @PostMapping("/create") + public CommonResult<Boolean> create(@RequestBody ChannelOPCUATagEntity channelOPCUATagEntity) { + String id = UUID.randomUUID().toString(); + channelOPCUATagEntity.setId(id); + channelOPCUATagEntity.setCreateTime(new Date()); + channelOpcuaTagService.add(channelOPCUATagEntity); + return success(true); + } + + @PreAuthorize("@ss.hasPermission('data:channel-opcua:update')") + @PutMapping("/update") + public CommonResult<Boolean> update(@RequestBody ChannelOPCUATagEntity channelOPCUATagEntity) { + channelOPCUATagEntity.setUpdateTime(new Date()); channelOpcuaTagService.update(channelOPCUATagEntity); - return R.ok(); + return success(true); } - /** - * 删除tag - * @param params - * - */ - @PostMapping("/delete") - public R tagDelete(@RequestBody Map<String, Object> params) { - String id = (String)params.get("id"); + @PreAuthorize("@ss.hasPermission('data:channel-opcua:delete')") + @DeleteMapping("/delete") + public CommonResult<Boolean> delete(@RequestParam("id") String id) { channelOpcuaTagService.delete(id); - return R.ok(); + return success(true); } - /** - * 导入 - * - * @param device - * @param file - * @return - */ - @PostMapping("/import/{device}") - public R importTag(@PathVariable("device") String device, @RequestParam("file") MultipartFile file) { - try { - if (file.isEmpty()) { - throw new RRException("上传文件不能为空"); - } - channelOpcuaTagService.importTag(device, file); - } catch (Exception ex) { - return R.error(ex.getMessage()); - } - return R.ok(); - } +// @PostMapping("/import/{device}") +// public R importTag(@PathVariable("device") String device, @RequestParam("file") MultipartFile file) { +// try { +// if (file.isEmpty()) { +// throw new RRException("上传文件不能为空"); +// } +// channelOpcuaTagService.importTag(device, file); +// } catch (Exception ex) { +// return R.error(ex.getMessage()); +// } +// return R.ok(); +// } } -- Gitblit v1.9.3