mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-25 16:43:55 +08:00
update:优化判断
This commit is contained in:
+8
-5
@@ -134,10 +134,10 @@ public class DeviceServiceImpl extends BaseServiceImpl<DeviceDao, DeviceEntity>
|
|||||||
// 清理redis缓存
|
// 清理redis缓存
|
||||||
redisUtils.delete(cacheDeviceKey);
|
redisUtils.delete(cacheDeviceKey);
|
||||||
redisUtils.delete(deviceKey);
|
redisUtils.delete(deviceKey);
|
||||||
|
|
||||||
// 添加:清除智能体设备数量缓存
|
// 添加:清除智能体设备数量缓存
|
||||||
redisUtils.delete(RedisKeys.getAgentDeviceCountById(agentId));
|
redisUtils.delete(RedisKeys.getAgentDeviceCountById(agentId));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,11 +231,14 @@ public class DeviceServiceImpl extends BaseServiceImpl<DeviceDao, DeviceEntity>
|
|||||||
public void unbindDevice(Long userId, String deviceId) {
|
public void unbindDevice(Long userId, String deviceId) {
|
||||||
// 先查询设备信息,获取agentId
|
// 先查询设备信息,获取agentId
|
||||||
DeviceEntity device = baseDao.selectById(deviceId);
|
DeviceEntity device = baseDao.selectById(deviceId);
|
||||||
if (device != null && StringUtils.isNotBlank(device.getAgentId())) {
|
if (device == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(device.getAgentId())) {
|
||||||
// 清除智能体设备数量缓存
|
// 清除智能体设备数量缓存
|
||||||
redisUtils.delete(RedisKeys.getAgentDeviceCountById(device.getAgentId()));
|
redisUtils.delete(RedisKeys.getAgentDeviceCountById(device.getAgentId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateWrapper<DeviceEntity> wrapper = new UpdateWrapper<>();
|
UpdateWrapper<DeviceEntity> wrapper = new UpdateWrapper<>();
|
||||||
wrapper.eq("user_id", userId);
|
wrapper.eq("user_id", userId);
|
||||||
wrapper.eq("id", deviceId);
|
wrapper.eq("id", deviceId);
|
||||||
@@ -470,7 +473,7 @@ public class DeviceServiceImpl extends BaseServiceImpl<DeviceDao, DeviceEntity>
|
|||||||
entity.setUpdater(userId);
|
entity.setUpdater(userId);
|
||||||
entity.setAutoUpdate(1);
|
entity.setAutoUpdate(1);
|
||||||
baseDao.insert(entity);
|
baseDao.insert(entity);
|
||||||
|
|
||||||
// 添加:清除智能体设备数量缓存
|
// 添加:清除智能体设备数量缓存
|
||||||
redisUtils.delete(RedisKeys.getAgentDeviceCountById(dto.getAgentId()));
|
redisUtils.delete(RedisKeys.getAgentDeviceCountById(dto.getAgentId()));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user