UpdateWrapper

This commit is contained in:
Tink
2025-06-26 15:54:26 +08:00
parent 32fa71e8f1
commit 7e86a9f8a9
@@ -60,14 +60,16 @@ public class DeviceServiceImpl extends BaseServiceImpl<DeviceDao, DeviceEntity>
@Async @Async
public void updateDeviceConnectionInfo(String agentId, String deviceId, String appVersion) { public void updateDeviceConnectionInfo(String agentId, String deviceId, String appVersion) {
try { try {
DeviceEntity device = new DeviceEntity(); UpdateWrapper<DeviceEntity> updateWrapper = new UpdateWrapper<>();
device.setId(deviceId); updateWrapper.eq("id", deviceId)
device.setLastConnectedAt(new Date()); .set("last_connected_at", new Date())
device.setUpdateDate(new Date()); .set("update_date", new Date());
if (StringUtils.isNotBlank(appVersion)) { if (StringUtils.isNotBlank(appVersion)) {
device.setAppVersion(appVersion); updateWrapper.set("app_version", appVersion);
} }
deviceDao.updateById(device); deviceDao.update(null, updateWrapper);
if (StringUtils.isNotBlank(agentId)) { if (StringUtils.isNotBlank(agentId)) {
redisUtils.set(RedisKeys.getAgentDeviceLastConnectedAtById(agentId), new Date()); redisUtils.set(RedisKeys.getAgentDeviceLastConnectedAtById(agentId), new Date());
} }