新增备份日志查询
This commit is contained in:
parent
4d201505dc
commit
77fdd99e69
|
|
@ -0,0 +1,25 @@
|
|||
package com.electromagnetic.industry.software.manage.controller;
|
||||
|
||||
import com.electromagnetic.industry.software.common.annotations.UserOperation;
|
||||
import com.electromagnetic.industry.software.common.enums.UserOperationModuleEnum;
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.manage.service.FileBackLogService;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/data/ed/backup/")
|
||||
public class FileBackupLogController {
|
||||
|
||||
@Resource
|
||||
private FileBackLogService fileBackLogService;
|
||||
|
||||
@RequestMapping(value = "list")
|
||||
@UserOperation(value="查询了备份日志", modelName = UserOperationModuleEnum.BACKUP_FILE)
|
||||
public ElectromagneticResult<?> list(@RequestParam int pageNum, @RequestParam int pageSize) {
|
||||
return fileBackLogService.query(pageNum, pageSize);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class FileBackLogVO {
|
||||
|
||||
private String id;
|
||||
|
||||
private String fileId;
|
||||
|
||||
private String fileCode;
|
||||
|
||||
private String fileName;
|
||||
|
||||
private Date backStartTime;
|
||||
|
||||
private Date backEndTime;
|
||||
|
||||
}
|
||||
|
|
@ -198,5 +198,5 @@ public interface EdFileInfoService {
|
|||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public boolean isFolder(String id);
|
||||
boolean isFolder(String id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
package com.electromagnetic.industry.software.manage.service;
|
||||
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
|
||||
public interface FileBackLogService {
|
||||
|
||||
ElectromagneticResult<?> query(Integer pageNumber, Integer pageSize);
|
||||
|
||||
}
|
||||
|
|
@ -440,11 +440,11 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
String info = FileUtil.readString(prjDirPath + File.separator + "mysql.info", Charset.defaultCharset());
|
||||
List<EdFileInfo> importAllFiles = JSONUtil.toList(info, EdFileInfo.class);
|
||||
// 找出层级文件夹
|
||||
List<EdFileInfo> prjFolders = importAllFiles.stream().filter(e -> ObjUtil.equals(e.getDataOwn(), dataOwnCode))
|
||||
List<EdFileInfo> prjFolders = importAllFiles.stream().filter(e -> DataOwnEnum.isPrjCode(e.getDataOwn()))
|
||||
.collect(Collectors.toList());
|
||||
// 找出用户创建的文件夹
|
||||
List<EdFileInfo> userFolders = importAllFiles.stream().filter(e -> ObjUtil.equals(e.getDataType(), EleDataTypeEnum.FOLDER.code))
|
||||
.filter(e -> ObjUtil.equals(e.getDataOwn(), dataOwnCode))
|
||||
.filter(e -> DataOwnEnum.isFileCode(e.getDataOwn()))
|
||||
.collect(Collectors.toList());
|
||||
// 找出所有文件
|
||||
List<EdFileInfo> allFiles = importAllFiles.stream().filter(e -> ObjUtil.equals(e.getDataType(), EleDataTypeEnum.FILE.code)).collect(Collectors.toList());
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
package com.electromagnetic.industry.software.manage.service.serviceimpl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.electromagnetic.industry.software.common.enums.FileBackupSource;
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
|
||||
import com.electromagnetic.industry.software.manage.mapper.FileBackupLogMapper;
|
||||
import com.electromagnetic.industry.software.manage.pojo.resp.FileBackLogVO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.resp.RespPageVO;
|
||||
import com.electromagnetic.industry.software.manage.service.FileBackLogService;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.FileBackupLog;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class FileBackLogServiceImpl extends ServiceImpl<FileBackupLogMapper, FileBackupLog> implements FileBackLogService {
|
||||
|
||||
|
||||
@Override
|
||||
public ElectromagneticResult<?> query(Integer pageNumber, Integer pageSize) {
|
||||
|
||||
Page<FileBackupLog> fileBackupLogPage = this.baseMapper.selectPage(new Page<>(pageNumber, pageSize), Wrappers.<FileBackupLog>lambdaQuery().eq(FileBackupLog::getSource, FileBackupSource.SYS_BACKUP.code));
|
||||
List<FileBackupLog> records = fileBackupLogPage.getRecords();
|
||||
|
||||
if (CollUtil.isEmpty(records)) {
|
||||
return ElectromagneticResultUtil.success(new RespPageVO<>(0L, records));
|
||||
}
|
||||
|
||||
long total = fileBackupLogPage.getTotal();
|
||||
List<FileBackLogVO> list = new ArrayList<>();
|
||||
for (FileBackupLog fileBackupLog : records) {
|
||||
FileBackLogVO fileBackLogVO = BeanUtil.copyProperties(fileBackupLog, FileBackLogVO.class);
|
||||
fileBackLogVO.setBackStartTime(DateUtil.date(fileBackupLog.getStartTime()));
|
||||
fileBackLogVO.setBackEndTime(DateUtil.date(fileBackupLog.getEndTime()));
|
||||
list.add(fileBackLogVO);
|
||||
}
|
||||
return ElectromagneticResultUtil.success(new RespPageVO<>(total, list));
|
||||
}
|
||||
}
|
||||
|
|
@ -8,7 +8,6 @@ import cn.hutool.core.text.StrFormatter;
|
|||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.electromagnetic.industry.software.common.enums.EleDataTypeEnum;
|
||||
import com.electromagnetic.industry.software.common.enums.FileBackupSource;
|
||||
import com.electromagnetic.industry.software.common.enums.UserOperationModuleEnum;
|
||||
|
|
@ -36,7 +35,7 @@ import java.util.Map;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class BackupTask extends ServiceImpl<FileBackupLogMapper, FileBackupLog> {
|
||||
public class BackupTask {
|
||||
|
||||
@Resource
|
||||
private ElePropertyConfig elePropertyConfig;
|
||||
|
|
|
|||
|
|
@ -15,4 +15,14 @@ public enum DataOwnEnum {
|
|||
public int code;
|
||||
public String desc;
|
||||
|
||||
|
||||
public static boolean isPrjCode(int code) {
|
||||
return code == SYS_PRJ.code || code == USER_PRJ.code || code == REPO_PRJ.code;
|
||||
}
|
||||
|
||||
public static boolean isFileCode(int code) {
|
||||
return code == SYS_FILE.code || code == USER_FILE.code || code == REPO_FILE.code;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -15,8 +15,10 @@ public enum UserOperationModuleEnum {
|
|||
TAG("tag","标签管理"),
|
||||
LOG("log", "操作记录审计"),
|
||||
TMP("tmp", "临时文件"),
|
||||
BACKUP_FILE("backupFile", "系统文件备份"),
|
||||
PERMISSION("permission", "权限管理");
|
||||
|
||||
|
||||
public final String key;
|
||||
public final String desc;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue