提交 | 用户 | 时间
|
a6de49
|
1 |
package com.iailab.module.data.channel.modbus.controller.admin; |
H |
2 |
|
c7f709
|
3 |
import com.iailab.framework.common.pojo.CommonResult; |
L |
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.entity.ChannelModBusTagEntity; |
a6de49
|
7 |
import com.iailab.module.data.channel.modbus.entity.ChannelModBusTagEntity; |
H |
8 |
import com.iailab.module.data.channel.modbus.service.ChannelModbusTagService; |
c7f709
|
9 |
import com.iailab.module.data.channel.modbus.vo.ModBusTagPageReqVO; |
L |
10 |
import com.iailab.module.data.channel.modbus.vo.ModBusTagRespVO; |
a6de49
|
11 |
import org.springframework.web.bind.annotation.*; |
H |
12 |
|
c7f709
|
13 |
import javax.annotation.Resource; |
L |
14 |
import javax.validation.Valid; |
|
15 |
import java.util.Date; |
a6de49
|
16 |
import java.util.UUID; |
H |
17 |
|
c7f709
|
18 |
import static com.iailab.framework.common.pojo.CommonResult.success; |
L |
19 |
|
a6de49
|
20 |
/** |
c7f709
|
21 |
* @author lirm |
L |
22 |
* @Description |
|
23 |
* @createTime 2024年08月27日 |
a6de49
|
24 |
*/ |
H |
25 |
@RestController |
|
26 |
@RequestMapping("/data/channel/modbus/tag") |
|
27 |
public class ChannelModbusTagController { |
|
28 |
@Resource |
|
29 |
private ChannelModbusTagService channelModbusTagService; |
|
30 |
|
c7f709
|
31 |
@GetMapping("/page") |
L |
32 |
public CommonResult<PageResult<ModBusTagRespVO>> list(@Valid ModBusTagPageReqVO reqVO) { |
|
33 |
PageResult<ChannelModBusTagEntity> page = channelModbusTagService.queryPage(reqVO); |
|
34 |
|
|
35 |
return success(BeanUtils.toBean(page, ModBusTagRespVO.class)); |
a6de49
|
36 |
} |
c7f709
|
37 |
|
a6de49
|
38 |
/** |
c7f709
|
39 |
* 根据id查询设备详情 |
a6de49
|
40 |
* |
H |
41 |
* @param id |
|
42 |
*/ |
|
43 |
@GetMapping("/info/{id}") |
c7f709
|
44 |
public CommonResult<ChannelModBusTagEntity> info(@PathVariable("id") String id) { |
L |
45 |
ChannelModBusTagEntity info = channelModbusTagService.info(id); |
|
46 |
return success(info); |
a6de49
|
47 |
} |
H |
48 |
|
|
49 |
/** |
c7f709
|
50 |
* 添加设备 |
a6de49
|
51 |
* |
H |
52 |
* @param channelModBusTagEntity |
|
53 |
*/ |
c7f709
|
54 |
@PostMapping("/add") |
L |
55 |
public CommonResult<Boolean> add(@RequestBody ChannelModBusTagEntity channelModBusTagEntity) { |
|
56 |
String id = UUID.randomUUID().toString(); |
|
57 |
channelModBusTagEntity.setId(id); |
|
58 |
channelModBusTagEntity.setCreateTime(new Date()); |
|
59 |
channelModbusTagService.add(channelModBusTagEntity); |
|
60 |
return success(true); |
a6de49
|
61 |
} |
H |
62 |
|
|
63 |
/** |
c7f709
|
64 |
* 修改设备 |
a6de49
|
65 |
* |
c7f709
|
66 |
* @param channelModBusTagEntity |
a6de49
|
67 |
*/ |
c7f709
|
68 |
@PutMapping("/update") |
L |
69 |
public CommonResult<Boolean> update(@RequestBody ChannelModBusTagEntity channelModBusTagEntity) { |
|
70 |
channelModBusTagEntity.setUpdateTime(new Date()); |
|
71 |
channelModbusTagService.update(channelModBusTagEntity); |
|
72 |
return success(true); |
a6de49
|
73 |
} |
H |
74 |
|
c7f709
|
75 |
/** |
L |
76 |
* 删除设备 |
|
77 |
* |
|
78 |
* @param id |
|
79 |
*/ |
|
80 |
@DeleteMapping("/delete") |
|
81 |
public CommonResult<Boolean> delete(@RequestParam("id") String id) { |
|
82 |
channelModbusTagService.delete(id); |
|
83 |
return success(true); |
|
84 |
} |
a6de49
|
85 |
} |