dengzedong
2024-10-14 3e18d4bfbf2c657b08b21512c2d884cc9d59df7b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package com.iailab.module.data.channel.opcda.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.opcda.entity.ChannelOPCDADeviceEntity;
import com.iailab.module.data.channel.opcda.service.ChannelOPCDADeviceService;
import com.iailab.module.data.channel.opcda.vo.OpcDaDevicePageReqVO;
import com.iailab.module.data.channel.opcda.vo.OpcDaDeviceRespVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
 
import javax.validation.Valid;
import java.util.Date;
import java.util.UUID;
 
import static com.iailab.framework.common.pojo.CommonResult.success;
 
/**
 * 操作opc ua配置
 * @author lirm
 * @Description
 * @createTime 2024年08月26日
 */
@RestController
@RequestMapping("/data/channel/opcda/device")
public class ChannelOPCDADeviceController {
    @Autowired
    private ChannelOPCDADeviceService channelOPCDADeviceService;
 
    @PreAuthorize("@ss.hasPermission('data:channel-opcda:query')")
    @GetMapping("page")
    public CommonResult<PageResult<OpcDaDeviceRespVO>> list(@Valid OpcDaDevicePageReqVO reqVO) {
        PageResult<ChannelOPCDADeviceEntity> page = channelOPCDADeviceService.queryPage(reqVO);
        return success(BeanUtils.toBean(page, OpcDaDeviceRespVO.class));
    }
 
    @PreAuthorize("@ss.hasPermission('data:channel-opcda:query')")
    @GetMapping("/info/{id}")
    public CommonResult<ChannelOPCDADeviceEntity> info(@PathVariable("id") String id) {
        ChannelOPCDADeviceEntity info = channelOPCDADeviceService.info(id);
        return success(info);
    }
 
    @PreAuthorize("@ss.hasPermission('data:channel-opcda:create')")
    @PostMapping("/create")
    public CommonResult<Boolean> create(@RequestBody ChannelOPCDADeviceEntity channelOPCDADeviceEntity) {
        String id = UUID.randomUUID().toString();
        channelOPCDADeviceEntity.setId(id);
        channelOPCDADeviceEntity.setCreateTime(new Date());
        channelOPCDADeviceService.add(channelOPCDADeviceEntity);
        return success(true);
    }
 
    @PreAuthorize("@ss.hasPermission('data:channel-opcda:update')")
    @PutMapping("/update")
    public CommonResult<Boolean> update(@RequestBody ChannelOPCDADeviceEntity channelOPCDADeviceEntity) {
        channelOPCDADeviceEntity.setUpdateTime(new Date());
        channelOPCDADeviceService.update(channelOPCDADeviceEntity);
        return success(true);
    }
 
    @PreAuthorize("@ss.hasPermission('data:channel-opcda:delete')")
    @DeleteMapping("/delete")
    public CommonResult<Boolean> delete(@RequestParam("id") String id) {
        channelOPCDADeviceService.delete(id);
        return success(true);
    }
}