hxd 2 miesięcy temu
rodzic
commit
fcecc60032

+ 2 - 2
portal-service-application/src/main/java/com/hfln/portal/application/controller/wap/DeviceController.java

@@ -95,8 +95,8 @@ public class DeviceController {
 
     @PostMapping("/statusLight")
     @Operation(summary = "设备指示灯开关")
-    public ApiResult<Boolean> statusLight(@RequestParam("devId") Long devId, @RequestParam("statusLight") Integer statusLight) {
-        return ApiResult.success(deviceGateway.statusLight(devId, statusLight));
+    public ApiResult<Boolean> statusLight(@RequestBody @Valid StatusLightParams params) {
+        return ApiResult.success(deviceGateway.statusLight(params));
     }
 /*
 

+ 22 - 0
portal-service-common/src/main/java/com/hfln/portal/common/request/device/StatusLightParams.java

@@ -0,0 +1,22 @@
+package com.hfln.portal.common.request.device;
+
+
+import com.hfln.portal.common.vo.BaseVO;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import javax.validation.constraints.NotNull;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class StatusLightParams extends BaseVO {
+
+    @Schema(description = "设备表主键id")
+    @NotNull
+    private Long devId;
+
+    @Schema(description = "设备指示灯状态: 0-关闭, 1-开启")
+    @NotNull
+    private Integer statusLight;
+}

+ 2 - 6
portal-service-domain/src/main/java/com/hfln/portal/domain/gateway/DeviceGateway.java

@@ -1,18 +1,15 @@
 package com.hfln.portal.domain.gateway;
 
 import com.hfln.portal.common.dto.data.device.DeviceDTO;
-import com.hfln.portal.common.dto.data.event.EventListDTO;
 import com.hfln.portal.common.dto.data.home.HomeInfoDTO;
 import com.hfln.portal.common.dto.data.room.RoomDTO;
-import com.hfln.portal.common.request.room.RoomParam;
 import com.hfln.portal.common.dto.data.share.ShareDto;
 import com.hfln.portal.common.request.device.*;
-import com.hfln.portal.common.request.event.EventListParams;
+import com.hfln.portal.common.request.room.RoomParam;
 import com.hfln.portal.common.request.share.ShareConfirmParam;
 import com.hfln.portal.common.request.share.ShareParam;
 import com.hfln.portal.common.request.share.updateShareParam;
 import com.hfln.portal.common.response.device.WcTimesQueryRes;
-import com.hfln.portal.common.vo.PageRecord;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.IOException;
@@ -33,7 +30,6 @@ public interface DeviceGateway {
 
     DeviceDTO queryDeviceById(String devId);
 
-    PageRecord<EventListDTO> queryEventByPage(EventListParams request);
 
     Boolean handleEvent(Long eventListId);
 
@@ -43,7 +39,7 @@ public interface DeviceGateway {
 
     Boolean checkDevByUserId(Long userId, Long devId);
 
-    Boolean statusLight(Long devId, Integer statusLight);
+    Boolean statusLight(StatusLightParams params);
 
     Boolean deviceTransfer(DeviceTransferParams params);
 

+ 6 - 19
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/gateway/impl/DeviceGatewayImpl.java

@@ -18,7 +18,6 @@ import com.hfln.portal.common.dto.data.room.RoomDTO;
 import com.hfln.portal.common.dto.data.room.SubRegionDTO;
 import com.hfln.portal.common.dto.data.share.ShareDto;
 import com.hfln.portal.common.request.device.*;
-import com.hfln.portal.common.request.event.EventListParams;
 import com.hfln.portal.common.request.room.RoomParam;
 import com.hfln.portal.common.request.room.SubRegionInfo;
 import com.hfln.portal.common.request.share.ShareConfirmParam;
@@ -297,18 +296,6 @@ public class DeviceGatewayImpl implements DeviceGateway {
     }
 
 
-    @Override
-    public PageRecord<EventListDTO> queryEventByPage(EventListParams request) {
-        Integer pageNo = Optional.ofNullable(request.getPageNo()).orElse(1);
-        Integer pageSize = Optional.ofNullable(request.getPageSize()).orElse(10);
-
-        // 执行分页查询
-        Page<EventList> eventPage = eventService.queryEventListByDevId(request.getDevId(),
-                request.getStartTime(), request.getEndTime(), pageNo, pageSize);
-        // 换为目标VO
-        List<EventListDTO> targets = convertToTargetVO(eventPage.getRecords());
-        return getEventListDTOPageRecord(eventPage, targets);
-    }
 
     // 填充PageRecord
     private PageRecord<EventListDTO> getEventListDTOPageRecord(Page<EventList> eventPage, List<EventListDTO> targets) {
@@ -439,23 +426,23 @@ public class DeviceGatewayImpl implements DeviceGateway {
 
     @Override
     @Transactional
-    public Boolean statusLight(Long devId, Integer statusLight) {
+    public Boolean statusLight(StatusLightParams params) {
         //1.校验设备是否存在
-        DevInfo devInfo = devInfoService.getById(devId);
+        DevInfo devInfo = devInfoService.getById(params.getDevId());
         if(devInfo == null){
             throw new BizException(ErrorEnum.DEVICE_IS_NOT_EXIST.getErrorCode(), ErrorEnum.DEVICE_IS_NOT_EXIST.getErrorMessage());
         }
 
         //2.校验status_light值,只能传 0 与 1
-        if (statusLight == null || statusLight != 0 && statusLight != 1){
+        if (params.getStatusLight() ==  null || params.getStatusLight() != 0 && params.getStatusLight() != 1){
             throw new BizException(ErrorEnum.STATUS_LIGHT_IS_NOT_EXIST.getErrorCode(), ErrorEnum.STATUS_LIGHT_IS_NOT_EXIST.getErrorMessage());
         }
 
         //3.更新设备指示灯状态
         boolean updateResult = devInfoService.update(
                 Wrappers.<DevInfo>lambdaUpdate()
-                        .set(DevInfo::getStatusLight, statusLight)
-                        .eq(DevInfo::getDevId, devId)
+                        .set(DevInfo::getStatusLight, params.getStatusLight())
+                        .eq(DevInfo::getDevId, params.getDevId())
         );
 
         //4.通过MQTT把信息参数发送到设备
@@ -463,7 +450,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
         JSONObject msg = new JSONObject();
         int indicatorLed = 0;
 
-        if (statusLight == 0){
+        if (params.getStatusLight() == 0){
             indicatorLed = 1;
         }
         msg.put("indicator_led", indicatorLed);