package com.iailab.module.data.channel.modbus.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.modbus.entity.ChannelModBusTagEntity;
|
import com.iailab.module.data.channel.modbus.entity.ChannelModBusTagEntity;
|
import com.iailab.module.data.channel.modbus.service.ChannelModbusTagService;
|
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 javax.annotation.Resource;
|
import javax.validation.Valid;
|
import java.util.Date;
|
import java.util.UUID;
|
|
import static com.iailab.framework.common.pojo.CommonResult.success;
|
|
/**
|
* @author lirm
|
* @Description
|
* @createTime 2024年08月27日
|
*/
|
@RestController
|
@RequestMapping("/data/channel/modbus/tag")
|
public class ChannelModbusTagController {
|
@Resource
|
private ChannelModbusTagService channelModbusTagService;
|
|
@GetMapping("/page")
|
public CommonResult<PageResult<ModBusTagRespVO>> list(@Valid ModBusTagPageReqVO reqVO) {
|
PageResult<ChannelModBusTagEntity> page = channelModbusTagService.queryPage(reqVO);
|
|
return success(BeanUtils.toBean(page, ModBusTagRespVO.class));
|
}
|
|
/**
|
* 根据id查询设备详情
|
*
|
* @param id
|
*/
|
@GetMapping("/info/{id}")
|
public CommonResult<ChannelModBusTagEntity> info(@PathVariable("id") String id) {
|
ChannelModBusTagEntity info = channelModbusTagService.info(id);
|
return success(info);
|
}
|
|
/**
|
* 添加设备
|
*
|
* @param channelModBusTagEntity
|
*/
|
@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);
|
}
|
|
/**
|
* 修改设备
|
*
|
* @param channelModBusTagEntity
|
*/
|
@PutMapping("/update")
|
public CommonResult<Boolean> update(@RequestBody ChannelModBusTagEntity channelModBusTagEntity) {
|
channelModBusTagEntity.setUpdateTime(new Date());
|
channelModbusTagService.update(channelModBusTagEntity);
|
return success(true);
|
}
|
|
/**
|
* 删除设备
|
*
|
* @param id
|
*/
|
@DeleteMapping("/delete")
|
public CommonResult<Boolean> delete(@RequestParam("id") String id) {
|
channelModbusTagService.delete(id);
|
return success(true);
|
}
|
}
|