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