补充操作记录相关的代码。
This commit is contained in:
parent
26954302de
commit
cbcc133c2f
|
|
@ -32,7 +32,7 @@ public class FileController {
|
||||||
public ElectromagneticResult<?> upload(@RequestParam("file") MultipartFile file, @RequestParam("path") String path) {
|
public ElectromagneticResult<?> upload(@RequestParam("file") MultipartFile file, @RequestParam("path") String path) {
|
||||||
BackupFileResLog backupFileResLog = BackupFileResLog.builder().backupStartTime(new Date()).fileName(file.getOriginalFilename()).backupStatus(true).build();
|
BackupFileResLog backupFileResLog = BackupFileResLog.builder().backupStartTime(new Date()).fileName(file.getOriginalFilename()).backupStatus(true).build();
|
||||||
try {
|
try {
|
||||||
fileService.upload(file, path);
|
fileService.upload(file);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String details = ExceptionUtil.stacktraceToString(e);
|
String details = ExceptionUtil.stacktraceToString(e);
|
||||||
backupFileResLog.setBackupStatus(false);
|
backupFileResLog.setBackupStatus(false);
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ import java.io.IOException;
|
||||||
|
|
||||||
public interface FileService {
|
public interface FileService {
|
||||||
|
|
||||||
void upload(MultipartFile file, String path) throws IOException;
|
void upload(MultipartFile file) throws IOException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,10 @@ public class FileServiceImpl implements FileService {
|
||||||
private BackupPro backupPro;
|
private BackupPro backupPro;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void upload(MultipartFile file, String path) throws IOException {
|
public void upload(MultipartFile file) throws IOException {
|
||||||
String saveFolder = backupPro.getSaveFolder();
|
String saveFolder = backupPro.getSaveFolder();
|
||||||
String fileName = file.getOriginalFilename();
|
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)) {
|
if (!FileUtil.exist(destPath)) {
|
||||||
FileUtil.writeFromStream(file.getInputStream(), destPath);
|
FileUtil.writeFromStream(file.getInputStream(), destPath);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.electromagnetic.industry.software.manage.config;
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.date.SystemClock;
|
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.annotations.UserOperation;
|
||||||
import com.electromagnetic.industry.software.common.cons.UserConstants;
|
import com.electromagnetic.industry.software.common.cons.UserConstants;
|
||||||
import com.electromagnetic.industry.software.common.enums.AdminTypeEnum;
|
import com.electromagnetic.industry.software.common.enums.AdminTypeEnum;
|
||||||
|
|
@ -131,6 +132,7 @@ public class LoginInterceptor implements HandlerInterceptor {
|
||||||
|
|
||||||
ElectromagneticResult<?> result = user.getResult();
|
ElectromagneticResult<?> result = user.getResult();
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
|
userAccessLog.setResponse(JSONUtil.toJsonStr(result));
|
||||||
if (!result.getSuccess()) {
|
if (!result.getSuccess()) {
|
||||||
userAccessLog.setAccessSuccess(false);
|
userAccessLog.setAccessSuccess(false);
|
||||||
userAccessLog.setOperationMsg(result.getErrorMessage());
|
userAccessLog.setOperationMsg(result.getErrorMessage());
|
||||||
|
|
@ -139,7 +141,6 @@ public class LoginInterceptor implements HandlerInterceptor {
|
||||||
} else { // 返回为ResponseEntity,且状态为失败。
|
} else { // 返回为ResponseEntity,且状态为失败。
|
||||||
userAccessLog.setAccessSuccess(false);
|
userAccessLog.setAccessSuccess(false);
|
||||||
}
|
}
|
||||||
userAccessLogMapper.insert(userAccessLog);
|
|
||||||
UserThreadLocal.remove();
|
UserThreadLocal.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,4 +61,7 @@ public class UserAccessLog {
|
||||||
// 父id,最权限需要
|
// 父id,最权限需要
|
||||||
private String parentId;
|
private String parentId;
|
||||||
|
|
||||||
|
// 请求返回的结果
|
||||||
|
private String response;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue