From c7f70933adf89a163d0049c907492a6df60cb45f Mon Sep 17 00:00:00 2001 From: liriming <1343021927@qq.com> Date: 星期二, 27 八月 2024 17:29:14 +0800 Subject: [PATCH] http modbus data服务代码升级 --- iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/admin/ChannelModbusTagController.java | 113 ++++++++++++++++++++++++-------------------------------- 1 files changed, 49 insertions(+), 64 deletions(-) diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/admin/ChannelModbusTagController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/admin/ChannelModbusTagController.java index bdde24f..cf82388 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/admin/ChannelModbusTagController.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/admin/ChannelModbusTagController.java @@ -1,100 +1,85 @@ package com.iailab.module.data.channel.modbus.controller.admin; -import cn.hutool.core.codec.Base64; -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.modbus.entity.ChannelModBusTagEntity; import com.iailab.module.data.channel.modbus.entity.ChannelModBusTagEntity; import com.iailab.module.data.channel.modbus.service.ChannelModbusTagService; -import javax.annotation.Resource; +import com.iailab.module.data.channel.modbus.vo.ModBusTagPageReqVO; +import com.iailab.module.data.channel.modbus.vo.ModBusTagRespVO; import org.springframework.web.bind.annotation.*; -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; + /** - * 操作modbus tag配置 - * - * @author DongYukun - * @createTime 2023年04月25日 10:31:00 + * @author lirm + * @Description + * @createTime 2024年08月27日 */ @RestController @RequestMapping("/data/channel/modbus/tag") public class ChannelModbusTagController { @Resource private ChannelModbusTagService channelModbusTagService; - /** - * 分页查询tag - * - * @param params - */ - @GetMapping("/list") - public R tagList(@RequestParam Map<String, Object> params){ - PageUtils page = channelModbusTagService.queryPage(params); - return R.ok().put("page", page); + @GetMapping("/page") + public CommonResult<PageResult<ModBusTagRespVO>> list(@Valid ModBusTagPageReqVO reqVO) { + PageResult<ChannelModBusTagEntity> page = channelModbusTagService.queryPage(reqVO); + + return success(BeanUtils.toBean(page, ModBusTagRespVO.class)); } + /** - * 根据id查询tag详情 + * 根据id查询设备详情 * * @param id */ @GetMapping("/info/{id}") - public R tagInfo(@PathVariable("id") String id){ - ChannelModBusTagEntity info= channelModbusTagService.info(Base64.decodeStr(id)); - return R.ok().put("data", info); - } - /** - * 添加tag - * - * @param entity - */ - @PostMapping("/add") - public R tagAdd(@RequestBody ChannelModBusTagEntity entity){ - entity.setId(UUID.randomUUID().toString()); - channelModbusTagService.add(entity); - return R.ok(); + public CommonResult<ChannelModBusTagEntity> info(@PathVariable("id") String id) { + ChannelModBusTagEntity info = channelModbusTagService.info(id); + return success(info); } /** - * 修改tag + * 添加设备 * * @param channelModBusTagEntity */ - @PostMapping("/update") - public R tagUpdate(@RequestBody ChannelModBusTagEntity channelModBusTagEntity) { - channelModbusTagService.update(channelModBusTagEntity); - return R.ok(); + @PostMapping("/add") + public CommonResult<Boolean> add(@RequestBody ChannelModBusTagEntity channelModBusTagEntity) { + String id = UUID.randomUUID().toString(); + channelModBusTagEntity.setId(id); + channelModBusTagEntity.setCreateTime(new Date()); + channelModbusTagService.add(channelModBusTagEntity); + return success(true); } /** - * 删除tag - * @param params + * 修改设备 * + * @param channelModBusTagEntity */ - @PostMapping("/delete") - public R tagDelete(@RequestBody Map<String, Object> params) { - String id = (String)params.get("id"); - channelModbusTagService.delete(id); - return R.ok(); + @PutMapping("/update") + public CommonResult<Boolean> update(@RequestBody ChannelModBusTagEntity channelModBusTagEntity) { + channelModBusTagEntity.setUpdateTime(new Date()); + channelModbusTagService.update(channelModBusTagEntity); + 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("上传文件不能为空"); -// } -// channelModbusTagService.importTag(device, file); -// } catch (Exception ex) { -// return R.error(ex.getMessage()); -// } -// return R.ok(); -// } + /** + * 删除设备 + * + * @param id + */ + @DeleteMapping("/delete") + public CommonResult<Boolean> delete(@RequestParam("id") String id) { + channelModbusTagService.delete(id); + return success(true); + } } -- Gitblit v1.9.3