Commit 40ab819f authored by ma's avatar ma

限制SN唯一

parent c3ecba23
...@@ -156,7 +156,17 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme ...@@ -156,7 +156,17 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
if (deviceId.equals(device.getDeviceId())) { if (deviceId.equals(device.getDeviceId())) {
return BaseResult.success(); return BaseResult.success();
} else { } else {
return BaseResult.failed().setMsgValue("设备sn已被绑定"); return BaseResult.failed().setMsgValue("设备编码已被绑定");
}
}
LambdaQueryWrapper<Device> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(Device::getSn, sn).last("limit 1");
Device device1 = deviceMapper.selectOne(lambdaQueryWrapper);
if (device1 != null) {
if (deviceId.equals(device1.getDeviceId())) {
return BaseResult.success();
} else {
return BaseResult.failed().setMsgValue("SN已被绑定");
} }
} }
LambdaQueryWrapper<Device> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Device> wrapper = new LambdaQueryWrapper<>();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment