补充操作记录相关的代码。

This commit is contained in:
chenxudong 2025-02-26 13:52:26 +08:00
parent 26954302de
commit cbcc133c2f
5 changed files with 9 additions and 5 deletions

View File

@ -32,7 +32,7 @@ public class FileController {
public ElectromagneticResult<?> upload(@RequestParam("file") MultipartFile file, @RequestParam("path") String path) {
BackupFileResLog backupFileResLog = BackupFileResLog.builder().backupStartTime(new Date()).fileName(file.getOriginalFilename()).backupStatus(true).build();
try {
fileService.upload(file, path);
fileService.upload(file);
} catch (Exception e) {
String details = ExceptionUtil.stacktraceToString(e);
backupFileResLog.setBackupStatus(false);

View File

@ -6,6 +6,6 @@ import java.io.IOException;
public interface FileService {
void upload(MultipartFile file, String path) throws IOException;
void upload(MultipartFile file) throws IOException;
}

View File

@ -17,10 +17,10 @@ public class FileServiceImpl implements FileService {
private BackupPro backupPro;
@Override
public void upload(MultipartFile file, String path) throws IOException {
public void upload(MultipartFile file) throws IOException {
String saveFolder = backupPro.getSaveFolder();
String fileName = file.getOriginalFilename();
String destPath = saveFolder + File.separator + path + File.separator + fileName;
String destPath = saveFolder + File.separator + File.separator + fileName;
if (!FileUtil.exist(destPath)) {
FileUtil.writeFromStream(file.getInputStream(), destPath);
}

View File

@ -2,6 +2,7 @@ package com.electromagnetic.industry.software.manage.config;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.SystemClock;
import cn.hutool.json.JSONUtil;
import com.electromagnetic.industry.software.common.annotations.UserOperation;
import com.electromagnetic.industry.software.common.cons.UserConstants;
import com.electromagnetic.industry.software.common.enums.AdminTypeEnum;
@ -131,6 +132,7 @@ public class LoginInterceptor implements HandlerInterceptor {
ElectromagneticResult<?> result = user.getResult();
if (result != null) {
userAccessLog.setResponse(JSONUtil.toJsonStr(result));
if (!result.getSuccess()) {
userAccessLog.setAccessSuccess(false);
userAccessLog.setOperationMsg(result.getErrorMessage());
@ -139,7 +141,6 @@ public class LoginInterceptor implements HandlerInterceptor {
} else { // 返回为ResponseEntity且状态为失败
userAccessLog.setAccessSuccess(false);
}
userAccessLogMapper.insert(userAccessLog);
UserThreadLocal.remove();
}

View File

@ -61,4 +61,7 @@ public class UserAccessLog {
// 父id最权限需要
private String parentId;
// 请求返回的结果
private String response;
}