Sfoglia il codice sorgente

Merge remote-tracking branch 'origin/master'

李进 2 anni fa
parent
commit
9ea493e671

+ 17 - 3
device-api-service-merc-mini/src/main/java/com/xy/controller/MercMiniDeviceController.java

@@ -14,9 +14,11 @@ import com.xy.dto.common.MercPlaceDto;
 import com.xy.dto.mini.MiniMercRegionDto;
 import com.xy.entity.DeviceBluetoothAuth;
 import com.xy.entity.DeviceInfo;
+import com.xy.entity.DeviceSysinfo;
 import com.xy.enums.MercStatus;
 import com.xy.service.DeviceBluetoothAuthServiceImpl;
 import com.xy.service.DeviceInfoServiceImpl;
+import com.xy.service.DeviceSysinfoServiceImpl;
 import com.xy.service.be.MercFeignService;
 import com.xy.service.common.MercLineService;
 import com.xy.service.common.MercPlaceService;
@@ -57,6 +59,8 @@ public class MercMiniDeviceController {
     private final MercFeignService mercFeignService;
 
     private final DeviceInfoServiceImpl deviceInfoService;
+
+    private final DeviceSysinfoServiceImpl deviceSysinfoService;
     private final MercPlaceService mercPlaceService;
     private final MercLineService mercLineService;
 
@@ -203,7 +207,12 @@ public class MercMiniDeviceController {
     @PostMapping("genCode")
     @ApiOperation("蓝牙开门-生成授权码")
     public R<Boolean> genCode(@RequestBody @Validated DeviceBluetoothAuthDto.GenCode dto) {
-        Long deviceId = dto.getDeviceId();
+        String deviceSn = dto.getDeviceSn();
+        DeviceSysinfo deviceSysinfo = deviceSysinfoService.getOne(Wrappers.<DeviceSysinfo>lambdaQuery().eq(DeviceSysinfo::getDeviceSn, deviceSn));
+        if (deviceSysinfo == null) {
+            return R.fail("设备不存在!");
+        }
+        Long deviceId = deviceSysinfo.getDeviceId();
         //用户输入的
         String authCode = dto.getAuthCode();
         List<Long> myDevices = getMyDevices();
@@ -241,7 +250,12 @@ public class MercMiniDeviceController {
     @PostMapping("verificationCode")
     @ApiOperation("蓝牙开门-校验并使用授权码")
     public R<Boolean> verificationCode(@RequestBody @Validated DeviceBluetoothAuthDto.VerificationCode dto) {
-        Long deviceId = dto.getDeviceId();
+        String deviceSn = dto.getDeviceSn();
+        DeviceSysinfo deviceSysinfo = deviceSysinfoService.getOne(Wrappers.<DeviceSysinfo>lambdaQuery().eq(DeviceSysinfo::getDeviceSn, deviceSn));
+        if (deviceSysinfo == null) {
+            return R.fail("设备不存在!");
+        }
+        Long deviceId = deviceSysinfo.getDeviceId();
         String authCode = dto.getAuthCode();
         String cacheAuthCode = getCacheAuthCode(deviceId);
         if (!authCode.equals(cacheAuthCode)) {
@@ -266,7 +280,7 @@ public class MercMiniDeviceController {
         return R.ok(deviceBluetoothAuthService.saveOrUpdate(deviceBluetoothAuth));
     }
 
- 
+
     /**
      * auth-code有效期30分钟,单位:s ,
      */

+ 8 - 6
device-api/src/main/java/com/xy/dto/DeviceBluetoothAuthDto.java

@@ -38,9 +38,10 @@ public class DeviceBluetoothAuthDto {
     @Data
     @Accessors(chain = true)
     public static class GenCode {
-        @NotNull(message = "设备ID不可为空")
-        @ApiModelProperty(value = "设备ID")
-        private Long deviceId;
+
+        @NotNull(message = "设备SN不可为空")
+        @ApiModelProperty(value = "设备SN")
+        private String deviceSn;
 
 
         @NotNull(message = "请输入授权码")
@@ -52,9 +53,10 @@ public class DeviceBluetoothAuthDto {
     @Data
     @Accessors(chain = true)
     public static class VerificationCode {
-        @NotNull(message = "设备ID不可为空")
-        @ApiModelProperty(value = "设备ID")
-        private Long deviceId;
+        
+        @NotNull(message = "设备SN不可为空")
+        @ApiModelProperty(value = "设备SN")
+        private String deviceSn;
 
 
         @NotNull(message = "授权码不可为空")