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.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; @GetMapping("page") public CommonResult<PageResult<OpcDaDeviceRespVO>> list(@Valid OpcDaDevicePageReqVO reqVO) { PageResult<ChannelOPCDADeviceEntity> page = channelOPCDADeviceService.queryPage(reqVO); return success(BeanUtils.toBean(page, OpcDaDeviceRespVO.class)); } @GetMapping("/info/{id}") public CommonResult<ChannelOPCDADeviceEntity> info(@PathVariable("id") String id) { ChannelOPCDADeviceEntity info = channelOPCDADeviceService.info(id); return success(info); } @PostMapping("/add") public CommonResult<Boolean> add(@RequestBody ChannelOPCDADeviceEntity channelOPCDADeviceEntity) { String id = UUID.randomUUID().toString(); channelOPCDADeviceEntity.setId(id); channelOPCDADeviceEntity.setCreateTime(new Date()); channelOPCDADeviceService.add(channelOPCDADeviceEntity); return success(true); } @PutMapping("/update") public CommonResult<Boolean> update(@RequestBody ChannelOPCDADeviceEntity channelOPCDADeviceEntity) { channelOPCDADeviceEntity.setUpdateTime(new Date()); channelOPCDADeviceService.update(channelOPCDADeviceEntity); return success(true); } @DeleteMapping("/delete") public CommonResult<Boolean> delete(@RequestParam("id") String id) { channelOPCDADeviceService.delete(id); return success(true); } }