|
|
@@ -1,11 +1,21 @@
|
|
|
package com.middle.platform.manage.biz.service;
|
|
|
|
|
|
+import cn.hutool.core.util.IdUtil;
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
+import com.middle.platform.common.exception.BusinessException;
|
|
|
+import com.middle.platform.common.utils.PageRes;
|
|
|
import com.middle.platform.manage.biz.domain.req.DevicePage;
|
|
|
+import com.middle.platform.manage.biz.domain.req.IotDeviceFlag;
|
|
|
import com.middle.platform.manage.biz.domain.req.IotDevicePara;
|
|
|
+import com.middle.platform.manage.biz.domain.vo.IotDeviceVo;
|
|
|
+import com.middle.platform.manage.biz.entity.IotDevice;
|
|
|
import com.middle.platform.manage.biz.mapper.IotDeviceMapper;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+
|
|
|
/**
|
|
|
* @author xucaiqin
|
|
|
* @date 2023-12-19 13:43:38
|
|
|
@@ -22,11 +32,29 @@ public class IotDeviceService {
|
|
|
* @return
|
|
|
*/
|
|
|
public Object pageQuery(DevicePage devicePage) {
|
|
|
- return null;
|
|
|
+ PageHelper.startPage(devicePage.getPage(), devicePage.getPageSize());
|
|
|
+ List<IotDeviceVo> iotProductVos = iotDeviceMapper.pageQuery(devicePage);
|
|
|
+ return new PageRes<>(iotProductVos);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 保存设备
|
|
|
+ *
|
|
|
+ * @param iotDevicePara
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public Object save(IotDevicePara iotDevicePara) {
|
|
|
- return null;
|
|
|
+ IotDevice iotDevice = new IotDevice();
|
|
|
+ iotDevice.setProductId(iotDevicePara.getProductId());
|
|
|
+ iotDevice.setName(iotDevicePara.getName());
|
|
|
+ iotDevice.setSn(iotDevicePara.getSn());
|
|
|
+ iotDevice.setGuid(IdUtil.fastSimpleUUID());
|
|
|
+ iotDevice.setSubtitle(iotDevicePara.getSubtitle());
|
|
|
+ iotDevice.setStatus(0);
|
|
|
+ iotDevice.setEnableFlag(0);
|
|
|
+ iotDevice.setRemark(iotDevicePara.getRemark());
|
|
|
+ iotDeviceMapper.insert(iotDevice);
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -39,4 +67,20 @@ public class IotDeviceService {
|
|
|
iotDeviceMapper.deleteById(id);
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 启用禁用设备
|
|
|
+ *
|
|
|
+ * @param iotDeviceFlag
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Object enable(IotDeviceFlag iotDeviceFlag) {
|
|
|
+ IotDevice iotDevice = iotDeviceMapper.selectById(iotDeviceFlag.getId());
|
|
|
+ if (Objects.isNull(iotDevice)) {
|
|
|
+ throw new BusinessException("设备不存在");
|
|
|
+ }
|
|
|
+ iotDevice.setEnableFlag(iotDeviceFlag.getStatus());
|
|
|
+ iotDeviceMapper.updateById(iotDevice);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|