提交 | 用户 | 时间
|
a6de49
|
1 |
package com.iailab.module.data.channel.modbus.controller.admin; |
H |
2 |
|
0b0cb9
|
3 |
import com.iailab.framework.common.pojo.CommonResult; |
潘 |
4 |
import com.iailab.framework.common.pojo.PageResult; |
|
5 |
import com.iailab.framework.common.util.object.BeanUtils; |
|
6 |
import com.iailab.module.data.channel.modbus.vo.ModBusDevicePageReqVO; |
a6de49
|
7 |
import com.iailab.module.data.channel.modbus.entity.ChannelModBusDeviceEntity; |
H |
8 |
import com.iailab.module.data.channel.modbus.service.ChannelModbusDeviceService; |
0b0cb9
|
9 |
|
a6de49
|
10 |
import javax.annotation.Resource; |
0b0cb9
|
11 |
import javax.validation.Valid; |
潘 |
12 |
|
|
13 |
import com.iailab.module.data.channel.modbus.vo.ModBusDeviceRespVO; |
a6de49
|
14 |
import org.springframework.web.bind.annotation.*; |
H |
15 |
|
|
16 |
import java.util.UUID; |
0b0cb9
|
17 |
|
潘 |
18 |
import static com.iailab.framework.common.pojo.CommonResult.success; |
a6de49
|
19 |
|
H |
20 |
/** |
|
21 |
* 操作modbus配置 |
|
22 |
* |
|
23 |
* @author DongYukun |
|
24 |
* @createTime 2023年04月24日 14:10:00 |
|
25 |
*/ |
|
26 |
@RestController |
|
27 |
@RequestMapping("/data/channel/modbus/device") |
|
28 |
public class ChannelModbusDeviceController { |
|
29 |
@Resource |
|
30 |
private ChannelModbusDeviceService channelModbusDeviceService; |
|
31 |
|
|
32 |
/** |
|
33 |
* 分页查询设备 |
|
34 |
* |
0b0cb9
|
35 |
* @param reqVO |
a6de49
|
36 |
*/ |
0b0cb9
|
37 |
@GetMapping("/page") |
潘 |
38 |
public CommonResult<PageResult<ModBusDeviceRespVO>> list(@Valid ModBusDevicePageReqVO reqVO) { |
|
39 |
PageResult<ChannelModBusDeviceEntity> page = channelModbusDeviceService.queryPage(reqVO); |
a6de49
|
40 |
|
0b0cb9
|
41 |
return success(BeanUtils.toBean(page, ModBusDeviceRespVO.class)); |
a6de49
|
42 |
} |
0b0cb9
|
43 |
|
a6de49
|
44 |
/** |
H |
45 |
* 根据id查询设备详情 |
|
46 |
* |
|
47 |
* @param id |
|
48 |
*/ |
|
49 |
@GetMapping("/info/{id}") |
0b0cb9
|
50 |
public CommonResult<ChannelModBusDeviceEntity> info(@PathVariable("id") String id) { |
潘 |
51 |
ChannelModBusDeviceEntity info = channelModbusDeviceService.info(id); |
|
52 |
return success(info); |
a6de49
|
53 |
} |
H |
54 |
|
|
55 |
/** |
0b0cb9
|
56 |
* 添加设备 |
潘 |
57 |
* |
|
58 |
* @param channelModBusDeviceEntity |
|
59 |
*/ |
|
60 |
@PostMapping("/add") |
|
61 |
public CommonResult<Boolean> add(@RequestBody ChannelModBusDeviceEntity channelModBusDeviceEntity) { |
|
62 |
String id = UUID.randomUUID().toString(); |
|
63 |
channelModBusDeviceEntity.setId(id); |
|
64 |
channelModbusDeviceService.add(channelModBusDeviceEntity); |
|
65 |
return success(true); |
|
66 |
} |
|
67 |
|
|
68 |
/** |
|
69 |
* 修改设备 |
|
70 |
* |
|
71 |
* @param channelModBusDeviceEntity |
|
72 |
*/ |
|
73 |
@PutMapping("/update") |
|
74 |
public CommonResult<Boolean> update(@RequestBody ChannelModBusDeviceEntity channelModBusDeviceEntity) { |
a6de49
|
75 |
channelModbusDeviceService.update(channelModBusDeviceEntity); |
0b0cb9
|
76 |
return success(true); |
a6de49
|
77 |
} |
H |
78 |
|
|
79 |
/** |
|
80 |
* 删除设备 |
|
81 |
* |
0b0cb9
|
82 |
* @param id |
a6de49
|
83 |
*/ |
0b0cb9
|
84 |
@DeleteMapping("/delete") |
潘 |
85 |
public CommonResult<Boolean> delete(@RequestParam("id") String id) { |
a6de49
|
86 |
channelModbusDeviceService.delete(id); |
0b0cb9
|
87 |
return success(true); |
a6de49
|
88 |
} |
H |
89 |
|
|
90 |
|
|
91 |
} |