update:优化获取新固件方法

This commit is contained in:
hrz
2025-04-24 18:36:04 +08:00
parent 04154162c6
commit d39c595828
2 changed files with 6 additions and 2 deletions
@@ -138,7 +138,7 @@ public class DeviceServiceImpl extends BaseServiceImpl<DeviceDao, DeviceEntity>
}
DeviceReportRespDTO.Firmware firmware = new DeviceReportRespDTO.Firmware();
firmware.setVersion(ota.getVersion());
firmware.setVersion(ota == null ? null : ota.getVersion());
firmware.setUrl(downloadUrl);
response.setFirmware(firmware);
@@ -74,6 +74,10 @@ public class OtaServiceImpl extends BaseServiceImpl<OtaDao, OtaEntity> implement
@Override
public OtaEntity getLatestOta(String type) {
return baseDao.selectOne(new QueryWrapper<OtaEntity>().eq("type", type).orderByDesc("update_date"));
QueryWrapper<OtaEntity> wrapper = new QueryWrapper<>();
wrapper.eq("type", type)
.orderByDesc("update_date")
.last("LIMIT 1");
return baseDao.selectOne(wrapper);
}
}