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.vo.ModBusDevicePageReqVO;
|
import com.iailab.module.data.channel.modbus.entity.ChannelModBusDeviceEntity;
|
import com.iailab.module.data.channel.modbus.service.ChannelModbusDeviceService;
|
|
import javax.annotation.Resource;
|
|
import com.iailab.module.data.channel.modbus.vo.ModBusDeviceRespVO;
|
import org.springframework.validation.annotation.Validated;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.UUID;
|
|
import static com.iailab.framework.common.pojo.CommonResult.success;
|
|
/**
|
* 操作modbus配置
|
*
|
* @author DongYukun
|
* @createTime 2023年04月24日 14:10:00
|
*/
|
@RestController
|
@RequestMapping("/data/channel/modbus/device")
|
public class ChannelModbusDeviceController {
|
@Resource
|
private ChannelModbusDeviceService channelModbusDeviceService;
|
|
/**
|
* 分页查询设备
|
*
|
* @param reqVO
|
*/
|
@GetMapping("/page")
|
public CommonResult<PageResult<ModBusDeviceRespVO>> list(@Validated ModBusDevicePageReqVO reqVO) {
|
PageResult<ChannelModBusDeviceEntity> page = channelModbusDeviceService.queryPage(reqVO);
|
|
return success(BeanUtils.toBean(page, ModBusDeviceRespVO.class));
|
}
|
|
/**
|
* 根据id查询设备详情
|
*
|
* @param id
|
*/
|
@GetMapping("/info/{id}")
|
public CommonResult<ChannelModBusDeviceEntity> info(@PathVariable("id") String id) {
|
ChannelModBusDeviceEntity info = channelModbusDeviceService.info(id);
|
return success(info);
|
}
|
|
/**
|
* 添加设备
|
*
|
* @param channelModBusDeviceEntity
|
*/
|
@PostMapping("/add")
|
public CommonResult<Boolean> add(@RequestBody ChannelModBusDeviceEntity channelModBusDeviceEntity) {
|
String id = UUID.randomUUID().toString();
|
channelModBusDeviceEntity.setId(id);
|
channelModbusDeviceService.add(channelModBusDeviceEntity);
|
return success(true);
|
}
|
|
/**
|
* 修改设备
|
*
|
* @param channelModBusDeviceEntity
|
*/
|
@PutMapping("/update")
|
public CommonResult<Boolean> update(@RequestBody ChannelModBusDeviceEntity channelModBusDeviceEntity) {
|
channelModbusDeviceService.update(channelModBusDeviceEntity);
|
return success(true);
|
}
|
|
/**
|
* 删除设备
|
*
|
* @param id
|
*/
|
@DeleteMapping("/delete")
|
public CommonResult<Boolean> delete(@RequestParam("id") String id) {
|
channelModbusDeviceService.delete(id);
|
return success(true);
|
}
|
|
|
}
|