TRX 1 năm trước cách đây
mục cha
commit
bac83c6798

+ 2 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/school/DeviceBindDao.java

@@ -20,4 +20,6 @@ public interface DeviceBindDao extends MongoDao<DeviceBind>, DeviceBindDaoExtend
 
     DeviceBind findTopByDeviceIdAndOid(String deviceId, String oid);
 
+    DeviceBind findTopByDeviceId(String deviceId);
+
 }

+ 8 - 5
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/school/DeviceBindServiceImpl.java

@@ -65,7 +65,14 @@ public class DeviceBindServiceImpl extends SuperService implements DeviceBindSer
         String oid = param.getOid();
         String deviceId = param.getDeviceId();
         DeviceBind deviceBind = null;
-        DeviceBind temp = deviceBindDao.findTopByDeviceIdAndOid(deviceId, oid);
+
+        DeviceInfo deviceInfo = deviceInfoDao.findTopByDeviceId(deviceId);
+        if (ObjectUtils.isEmpty(deviceInfo)) {
+            return ResultContent.buildFail(String.format("设备不存在:%s", deviceId));
+        }
+
+        // 一个设备是否可以绑定到多个学校?!
+        DeviceBind temp = deviceBindDao.findTopByDeviceId(deviceId);
         if (StringUtils.isNotEmpty(param.getId())) {
             deviceBind = deviceBindDao.findTopById(param.getId());
             if (ObjectUtils.isEmpty(deviceBind)) {
@@ -81,10 +88,6 @@ public class DeviceBindServiceImpl extends SuperService implements DeviceBindSer
             }
         }
         BeanUtils.copyProperties(param, deviceBind);
-        DeviceInfo deviceInfo = deviceInfoDao.findTopByDeviceId(deviceId);
-        if (ObjectUtils.isEmpty(deviceInfo)) {
-            return ResultContent.buildFail(String.format("设备不存在:%s", deviceId));
-        }
 
         deviceBind.setDeviceId(deviceId);
         deviceBind.setDeviceName(deviceInfo.getDeviceName());