管理员备份数据查询接口
<p>@GetMapping("/queryBackupsByAdminIdByParam")
public Result<Object> queryBackupsByAdminIdByParam(Admin admin, String text, HttpServletRequest request) {
//权限验证
String token = (String) request.getAttribute("claims_admin");
if (token == null || "".equals(token)) {
throw new RuntimeException("权限不足!");
}</p>
<pre><code>List<BackupDto> result = new ArrayList<>();//存放结果
List<Backup> backups;
if (StringUtils.isEmpty(text)) {
backups = backupService.queryBackupsByAdminId(admin.getAdminId());
} else {
backups = backupService.queryBackupsByAdminIdByDate(admin.getAdminId(), text);
}
for (Backup backup : backups) {
BackupDto backupDto = new BackupDto();
BeanUtils.copyProperties(backup, backupDto);//数据拷贝
backupDto.setIsRecover(true);
String deleteMessage = backup.getDeleteMessage();
if (!StringUtils.isEmpty(deleteMessage)) {
JSONObject jsonObject = JSON.parseObject(deleteMessage);
DeviceEntity baseDevice = jsonObject.getObject("baseDevice", DeviceEntity.class);
if (baseDevice != null) {
backupDto.setBaseDevice(baseDevice);
DeviceEntity oldBaseDevice = deviceEntityService.queryOneDeviceEntityByUniqueIDByAll(baseDevice.getUniqueId());
if (oldBaseDevice.getBindingId() != -1) {
backupDto.setIsRecover(false);
}
}
DeviceEntity mobileDevice = jsonObject.getObject("mobileDevice", DeviceEntity.class);
if (mobileDevice != null) {
backupDto.setMobileDevice(mobileDevice);
DeviceEntity oldMobileDevice = deviceEntityService.queryOneDeviceEntityByUniqueIDByAll(mobileDevice.getUniqueId());
if (oldMobileDevice.getBindingId() != -1) {
backupDto.setIsRecover(false);
}
}
List<DeviceEntity> mobileDevices = jsonObject.getObject("mobileDevices", new TypeReference<List<DeviceEntity>>() {});
if (mobileDevices != null) {
backupDto.setMobileDevices(mobileDevices);
List<String> uniqueIds = mobileDevices.stream().map(DeviceEntity::getUniqueId).toList();
List<DeviceEntity> deviceEntityList = deviceEntityService.queryDeviceEntitiesByUniqueIds(uniqueIds);
for (DeviceEntity mobileDevice1 : deviceEntityList) {
if (mobileDevice1.getBindingId() != -1) {
backupDto.setIsRecover(false);
}
}
}
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String deleteDate = sdf.format(backup.getDeleteDate());
backupDto.setDate(deleteDate);
result.add(backupDto);
}
log.info("查询备份信息成功!");
Map<String, Object> map = new HashMap<>();
map.put("total", result.size());
map.put("result", result);
return new Result<>(ResultCode.SUCCESS, map);
</code></pre>
<p>}</p>
原文地址: https://www.cveoy.top/t/topic/160 著作权归作者所有。请勿转载和采集!