提交 | 用户 | 时间
|
a6de49
|
1 |
package com.iailab.module.data.channel.opcua.controller.admin; |
H |
2 |
|
aecc49
|
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; |
a6de49
|
6 |
import com.iailab.module.data.channel.opcua.entity.ChannelOPCUADeviceEntity; |
H |
7 |
import com.iailab.module.data.channel.opcua.service.ChannelOPCUADeviceService; |
aecc49
|
8 |
import com.iailab.module.data.channel.opcua.vo.OpcUaDevicePageReqVO; |
L |
9 |
import com.iailab.module.data.channel.opcua.vo.OpcUaDeviceRespVO; |
a477ef
|
10 |
import org.springframework.security.access.prepost.PreAuthorize; |
a6de49
|
11 |
import org.springframework.web.bind.annotation.*; |
H |
12 |
|
aecc49
|
13 |
import javax.annotation.Resource; |
L |
14 |
import javax.validation.Valid; |
a6de49
|
15 |
import java.util.UUID; |
aecc49
|
16 |
|
L |
17 |
import static com.iailab.framework.common.pojo.CommonResult.success; |
a6de49
|
18 |
|
H |
19 |
/** |
|
20 |
* 操作opc ua配置 |
aecc49
|
21 |
* @author lirm |
L |
22 |
* @Description |
|
23 |
* @createTime 2024年08月26日 |
a6de49
|
24 |
*/ |
H |
25 |
@RestController |
|
26 |
@RequestMapping("/data/channel/opcua/device") |
|
27 |
public class ChannelOPCUADeviceController { |
|
28 |
@Resource |
|
29 |
private ChannelOPCUADeviceService channelOPCUADeviceService; |
|
30 |
|
a477ef
|
31 |
@PreAuthorize("@ss.hasPermission('data:channel-opcua:query')") |
aecc49
|
32 |
@GetMapping("page") |
L |
33 |
public CommonResult<PageResult<OpcUaDeviceRespVO>> list(@Valid OpcUaDevicePageReqVO reqVO) { |
|
34 |
PageResult<ChannelOPCUADeviceEntity> page = channelOPCUADeviceService.queryPage(reqVO); |
|
35 |
return success(BeanUtils.toBean(page, OpcUaDeviceRespVO.class)); |
a6de49
|
36 |
} |
H |
37 |
|
a477ef
|
38 |
@PreAuthorize("@ss.hasPermission('data:channel-opcua:query')") |
a6de49
|
39 |
@GetMapping("/info/{id}") |
aecc49
|
40 |
public CommonResult<ChannelOPCUADeviceEntity> info(@PathVariable("id") String id) { |
a6de49
|
41 |
ChannelOPCUADeviceEntity info = channelOPCUADeviceService.info(id); |
aecc49
|
42 |
return success(info); |
a6de49
|
43 |
} |
H |
44 |
|
a477ef
|
45 |
@PreAuthorize("@ss.hasPermission('data:channel-opcua:create')") |
潘 |
46 |
@PostMapping("/create") |
|
47 |
public CommonResult<Boolean> create(@RequestBody ChannelOPCUADeviceEntity channelOPCUADeviceEntity) { |
a6de49
|
48 |
String id = UUID.randomUUID().toString(); |
H |
49 |
channelOPCUADeviceEntity.setId(id); |
|
50 |
channelOPCUADeviceService.add(channelOPCUADeviceEntity); |
aecc49
|
51 |
return success(true); |
a6de49
|
52 |
} |
H |
53 |
|
a477ef
|
54 |
@PreAuthorize("@ss.hasPermission('data:channel-opcua:update')") |
aecc49
|
55 |
@PutMapping("/update") |
L |
56 |
public CommonResult<Boolean> update(@RequestBody ChannelOPCUADeviceEntity channelOPCUADeviceEntity) { |
a6de49
|
57 |
channelOPCUADeviceService.update(channelOPCUADeviceEntity); |
aecc49
|
58 |
return success(true); |
a6de49
|
59 |
} |
H |
60 |
|
a477ef
|
61 |
@PreAuthorize("@ss.hasPermission('data:channel-opcua:delete')") |
aecc49
|
62 |
@DeleteMapping("/delete") |
L |
63 |
public CommonResult<Boolean> delete(@RequestParam("id") String id) { |
a6de49
|
64 |
channelOPCUADeviceService.delete(id); |
aecc49
|
65 |
return success(true); |
a6de49
|
66 |
} |
H |
67 |
/** |
|
68 |
* 上传安全证书 |
|
69 |
* |
|
70 |
* @param file |
|
71 |
*/ |
aecc49
|
72 |
// @PostMapping("/upload") |
L |
73 |
// public R uploadFile(@RequestParam("file") MultipartFile file) { |
|
74 |
// String fileName = file.getOriginalFilename(); |
|
75 |
// String filePath = ""; |
|
76 |
// try { |
|
77 |
// File dir = new File(filePath); |
|
78 |
// if (!dir.exists()) { |
|
79 |
// dir.mkdirs(); |
|
80 |
// } |
|
81 |
// File saveFile = new File(filePath + fileName); |
|
82 |
// file.transferTo(saveFile); |
|
83 |
// return R.ok().put("data",saveFile.getAbsolutePath()); |
|
84 |
// } catch (IOException e) { |
|
85 |
// e.printStackTrace(); |
|
86 |
// return R.error(); |
|
87 |
// } |
|
88 |
// } |
a6de49
|
89 |
} |