适配更新自动填充

This commit is contained in:
chenxudong 2025-03-05 15:20:45 +08:00
parent 6c569dbccf
commit 82acc597e6
9 changed files with 56 additions and 61 deletions

View File

@ -111,24 +111,23 @@ public class LoginInterceptor implements HandlerInterceptor {
UserLoginInfo user = Optional.of(UserThreadLocal.getUser()).orElse(new UserLoginInfo()); UserLoginInfo user = Optional.of(UserThreadLocal.getUser()).orElse(new UserLoginInfo());
UserAccessLog userAccessLog = UserAccessLog.builder() UserAccessLog userAccessLog = new UserAccessLog()
.id(IdWorker.getSnowFlakeIdString()) .setId(IdWorker.getSnowFlakeIdString())
.userId(user.getUserId()) .setUserId(user.getUserId())
.accessStartTime(DateUtil.date(accessStartTime)) .setAccessStartTime(DateUtil.date(accessStartTime))
.accessEndTime(DateUtil.date(accessEndTime)) .setAccessEndTime(DateUtil.date(accessEndTime))
.accessDuration(accessEndTime - accessStartTime) .setAccessDuration(accessEndTime - accessStartTime)
.action(userOperation.value()) .setAction(userOperation.value())
.requestUrl(request.getRequestURL().toString()) .setRequestUrl(request.getRequestURL().toString())
.requestIp(parseIpFromUrl(request.getRequestURL().toString())) .setRequestIp(parseIpFromUrl(request.getRequestURL().toString()))
.reqArgs(reqArgs) .setReqArgs(reqArgs)
.remoteAddr(getRealIp(request)) .setRemoteAddr(getRealIp(request))
.accessSuccess(true) .setAccessSuccess(true)
.createTime(new Date()) .setCreateTime(new Date())
.operationModule(userOperation.modelName().key) .setOperationModule(userOperation.modelName().key)
.operationMsg(UserThreadLocal.getUser().getSuccessMsg()) .setOperationMsg(UserThreadLocal.getUser().getSuccessMsg())
.dataId(user.getDataId()) .setDataId(user.getDataId())
.parentId(user.getParentId()) .setParentId(user.getParentId());
.build();
ElectromagneticResult<?> result = user.getResult(); ElectromagneticResult<?> result = user.getResult();
if (result != null) { if (result != null) {

View File

@ -3,11 +3,12 @@ package com.electromagnetic.industry.software.manage.pojo.models;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date; import java.util.Date;
@Data @Data
@Builder @Accessors(chain = true)
@TableName("user_access_log") @TableName("user_access_log")
public class UserAccessLog { public class UserAccessLog {

View File

@ -292,7 +292,7 @@ public class CommonService {
return ElectromagneticResultUtil.fail("-1", info); return ElectromagneticResultUtil.fail("-1", info);
} else { } else {
// 先设置dataStatus状态为删除状态 // 先设置dataStatus状态为删除状态
edFileInfoMapper.update(null, Wrappers.<EdFileInfo>lambdaUpdate() edFileInfoMapper.update(new EdFileInfo(), Wrappers.<EdFileInfo>lambdaUpdate()
.like(EdFileInfo::getFilePath, id) .like(EdFileInfo::getFilePath, id)
.set(EdFileInfo::getSort, -1) .set(EdFileInfo::getSort, -1)
.set(EdFileInfo::getDataStatus, EleDataStatusEnum.DELETED.code)); .set(EdFileInfo::getDataStatus, EleDataStatusEnum.DELETED.code));
@ -306,7 +306,7 @@ public class CommonService {
for (int i = 0; i < edFileInfos1.size(); i++) { for (int i = 0; i < edFileInfos1.size(); i++) {
String tmp = edFileInfos1.get(i).getId(); String tmp = edFileInfos1.get(i).getId();
edFileInfoMapper.update(null, Wrappers.lambdaUpdate(EdFileInfo.class) edFileInfoMapper.update(new EdFileInfo(), Wrappers.lambdaUpdate(EdFileInfo.class)
.set(EdFileInfo::getSort, i + 1) .set(EdFileInfo::getSort, i + 1)
.eq(EdFileInfo::getId, tmp)); .eq(EdFileInfo::getId, tmp));
} }
@ -322,7 +322,7 @@ public class CommonService {
return ElectromagneticResultUtil.fail("-1", info); return ElectromagneticResultUtil.fail("-1", info);
} else { } else {
// 逻辑删除文件夹 // 逻辑删除文件夹
edFileInfoMapper.update(null, Wrappers.<EdFileInfo>lambdaUpdate() edFileInfoMapper.update(new EdFileInfo(), Wrappers.<EdFileInfo>lambdaUpdate()
.eq(EdFileInfo::getId, id) .eq(EdFileInfo::getId, id)
.set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code)); .set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code));
fileSystemService.renameFile(srcFilePath, srcPrjName + "_" + IdUtil.fastSimpleUUID() + DELETE_FLAG); fileSystemService.renameFile(srcFilePath, srcPrjName + "_" + IdUtil.fastSimpleUUID() + DELETE_FLAG);

View File

@ -226,7 +226,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
UserThreadLocal.setSuccessInfo(fileInfo.getParentId(), id, "作废目录 {} 成功", fileInfo.getFileName()); UserThreadLocal.setSuccessInfo(fileInfo.getParentId(), id, "作废目录 {} 成功", fileInfo.getFileName());
return res; return res;
} }
this.baseMapper.update(null, Wrappers.lambdaUpdate(EdFileInfo.class) this.baseMapper.update(new EdFileInfo(), Wrappers.lambdaUpdate(EdFileInfo.class)
.set(EdFileInfo::getEffectFlag, false) .set(EdFileInfo::getEffectFlag, false)
.set(EdFileInfo::getAllDeleted, true) .set(EdFileInfo::getAllDeleted, true)
.eq(EdFileInfo::getFileId, fileInfo.getFileId())); .eq(EdFileInfo::getFileId, fileInfo.getFileId()));
@ -314,7 +314,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
} }
String srcFilePath = commonService.getFileSysPath(fileInfo.getFilePath(), dataOwnCode); String srcFilePath = commonService.getFileSysPath(fileInfo.getFilePath(), dataOwnCode);
this.baseMapper.update(null, Wrappers.lambdaUpdate(EdFileInfo.class) this.baseMapper.update(new EdFileInfo(), Wrappers.lambdaUpdate(EdFileInfo.class)
.eq(EdFileInfo::getId, updateFileInfoDTO.getId()) .eq(EdFileInfo::getId, updateFileInfoDTO.getId())
.set(EdFileInfo::getFileName, updateFileInfoDTO.getFileName()) .set(EdFileInfo::getFileName, updateFileInfoDTO.getFileName())
.set(EdFileInfo::getFileNote, updateFileInfoDTO.getFileNote())); .set(EdFileInfo::getFileNote, updateFileInfoDTO.getFileNote()));
@ -341,10 +341,10 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
public ElectromagneticResult<?> versionBack(String fileId, int targetVersion) { public ElectromagneticResult<?> versionBack(String fileId, int targetVersion) {
EdFileInfo fileInfo = this.baseMapper.selectList(Wrappers.<EdFileInfo>lambdaQuery().eq(EdFileInfo::getFileId, fileId).last("limit 1")).get(0); EdFileInfo fileInfo = this.baseMapper.selectList(Wrappers.<EdFileInfo>lambdaQuery().eq(EdFileInfo::getFileId, fileId).last("limit 1")).get(0);
try { try {
this.baseMapper.update(null, Wrappers.lambdaUpdate(EdFileInfo.class) this.baseMapper.update(new EdFileInfo(), Wrappers.lambdaUpdate(EdFileInfo.class)
.eq(EdFileInfo::getFileId, fileId) .eq(EdFileInfo::getFileId, fileId)
.set(EdFileInfo::getEffectFlag, false)); .set(EdFileInfo::getEffectFlag, false));
this.baseMapper.update(null, Wrappers.lambdaUpdate(EdFileInfo.class) this.baseMapper.update(new EdFileInfo(), Wrappers.lambdaUpdate(EdFileInfo.class)
.set(EdFileInfo::getEffectFlag, true) .set(EdFileInfo::getEffectFlag, true)
.eq(EdFileInfo::getFileId, fileId) .eq(EdFileInfo::getFileId, fileId)
.eq(EdFileInfo::getFileVersion, targetVersion)); .eq(EdFileInfo::getFileVersion, targetVersion));
@ -921,7 +921,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
String destFilePath = commonService.getFileSysPath(destSaveFileInfo.getFilePath(), dataOwnCode); String destFilePath = commonService.getFileSysPath(destSaveFileInfo.getFilePath(), dataOwnCode);
fileSystemService.copyFile(srcFilePath, destFilePath); fileSystemService.copyFile(srcFilePath, destFilePath);
this.baseMapper.deleteById(srcFileInfo.getId()); this.baseMapper.deleteById(srcFileInfo.getId());
this.baseMapper.update(null, Wrappers.lambdaUpdate(EdFileInfo.class) this.baseMapper.update(new EdFileInfo(), Wrappers.lambdaUpdate(EdFileInfo.class)
.set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code) .set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code)
.eq(EdFileInfo::getId, fileInfoTmp.getId())); .eq(EdFileInfo::getId, fileInfoTmp.getId()));
return destSaveFileInfo; return destSaveFileInfo;
@ -1084,7 +1084,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
.setPreVersion(maxFileVersion) .setPreVersion(maxFileVersion)
.setEffectFlag(EffectFlagEnum.EFFECT.code) .setEffectFlag(EffectFlagEnum.EFFECT.code)
.setFileCode(fileCode); .setFileCode(fileCode);
this.baseMapper.update(null, Wrappers.lambdaUpdate(EdFileInfo.class).eq(EdFileInfo::getParentId, targetFolderId) this.baseMapper.update(new EdFileInfo(), Wrappers.lambdaUpdate(EdFileInfo.class).eq(EdFileInfo::getParentId, targetFolderId)
.eq(EdFileInfo::getFileName, srcFileInfo.getFileName()) .eq(EdFileInfo::getFileName, srcFileInfo.getFileName())
.eq(EdFileInfo::getFileType, srcFileInfo.getFileType()).set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code)); .eq(EdFileInfo::getFileType, srcFileInfo.getFileType()).set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code));
this.baseMapper.insert(destSaveFileInfo); this.baseMapper.insert(destSaveFileInfo);
@ -1137,7 +1137,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
String timeStr = EleCommonUtil.getNowTimeStr(); String timeStr = EleCommonUtil.getNowTimeStr();
String fileCode = commonService.createFileCode(codePathByDbPath, suffix, FILE_START_VERSION, timeStr); String fileCode = commonService.createFileCode(codePathByDbPath, suffix, FILE_START_VERSION, timeStr);
// 将原有效的版本置为false // 将原有效的版本置为false
this.baseMapper.update(null, Wrappers.lambdaUpdate(EdFileInfo.class) this.baseMapper.update(new EdFileInfo(), Wrappers.lambdaUpdate(EdFileInfo.class)
.set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code) .set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code)
.eq(EdFileInfo::getId, effectFileInfo.getId())); .eq(EdFileInfo::getId, effectFileInfo.getId()));
// 新增文件 // 新增文件

View File

@ -143,7 +143,7 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
String tmpPath = newPrjName + "_" + IdUtil.fastSimpleUUID() + DELETE_FLAG; String tmpPath = newPrjName + "_" + IdUtil.fastSimpleUUID() + DELETE_FLAG;
fileSystemService.renameFile(newPath, tmpPath); fileSystemService.renameFile(newPath, tmpPath);
} }
this.baseMapper.update(null, Wrappers.lambdaUpdate(EdFileInfo.class) this.baseMapper.update(new EdFileInfo(), Wrappers.lambdaUpdate(EdFileInfo.class)
.eq(EdFileInfo::getId, prjId) .eq(EdFileInfo::getId, prjId)
.set(EdFileInfo::getFileName, newPrjName)); .set(EdFileInfo::getFileName, newPrjName));
fileSystemService.renameFile(commonService.getEleDataPath(dataOwnCode), oldPrjName, newPrjName); fileSystemService.renameFile(commonService.getEleDataPath(dataOwnCode), oldPrjName, newPrjName);
@ -184,7 +184,7 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
List<EdFileInfo> edFileInfos = this.baseMapper.selectList(queryWrapper); List<EdFileInfo> edFileInfos = this.baseMapper.selectList(queryWrapper);
List<String> ids = edFileInfos.stream().map(EdFileInfo::getId).collect(Collectors.toList()); List<String> ids = edFileInfos.stream().map(EdFileInfo::getId).collect(Collectors.toList());
ids.add(prjId); ids.add(prjId);
this.baseMapper.update(null, Wrappers.lambdaUpdate(EdFileInfo.class).set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code).in(EdFileInfo::getId, ids)); this.baseMapper.update(new EdFileInfo(), Wrappers.lambdaUpdate(EdFileInfo.class).set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code).in(EdFileInfo::getId, ids));
// 对原文件进行处理 // 对原文件进行处理
EdFileInfo prjFile = this.getById(prjId); EdFileInfo prjFile = this.getById(prjId);
fileSystemService.renameFile(commonService.getFileSysPath(prjId, dataOwnCode), prjFile + "_" + IdUtil.fastSimpleUUID() + DELETE_FLAG); fileSystemService.renameFile(commonService.getFileSysPath(prjId, dataOwnCode), prjFile + "_" + IdUtil.fastSimpleUUID() + DELETE_FLAG);
@ -257,7 +257,7 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
LambdaUpdateWrapper<EdFileInfo> updateWrapper = Wrappers.lambdaUpdate(EdFileInfo.class) LambdaUpdateWrapper<EdFileInfo> updateWrapper = Wrappers.lambdaUpdate(EdFileInfo.class)
.set(EdFileInfo::getSort, folderResortDTO.getSort()) .set(EdFileInfo::getSort, folderResortDTO.getSort())
.eq(EdFileInfo::getId, folderResortDTO.getId()); .eq(EdFileInfo::getId, folderResortDTO.getId());
this.update(updateWrapper); this.update(new EdFileInfo(), updateWrapper);
} }
UserThreadLocal.setSuccessInfo("", "", "子集重排序成功"); UserThreadLocal.setSuccessInfo("", "", "子集重排序成功");
return ElectromagneticResultUtil.success(true); return ElectromagneticResultUtil.success(true);
@ -291,7 +291,7 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
fileSysPaths.add(fileSysPath); fileSysPaths.add(fileSysPath);
}); });
this.update(Wrappers.lambdaUpdate(EdFileInfo.class) this.update(new EdFileInfo(), Wrappers.lambdaUpdate(EdFileInfo.class)
.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.DELETED.code) .eq(EdFileInfo::getDataStatus, EleDataStatusEnum.DELETED.code)
.set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code) .set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code)
.likeRight(EdFileInfo::getFilePath, prjId)); .likeRight(EdFileInfo::getFilePath, prjId));
@ -300,7 +300,7 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
.set(EdFileInfo::getDataStatus, EleDataStatusEnum.PUBLISHED.code) .set(EdFileInfo::getDataStatus, EleDataStatusEnum.PUBLISHED.code)
.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.NOT_PUBLISHED.code) .eq(EdFileInfo::getDataStatus, EleDataStatusEnum.NOT_PUBLISHED.code)
.likeRight(EdFileInfo::getFilePath, prjId); .likeRight(EdFileInfo::getFilePath, prjId);
this.update(updateWrapper); this.update(new EdFileInfo(), updateWrapper);
commonService.deletePrjSysDir(fileSysPaths); commonService.deletePrjSysDir(fileSysPaths);
UserThreadLocal.setSuccessInfo("", prjId, "项目 {} 发布成功", fileInfo.getFileName()); UserThreadLocal.setSuccessInfo("", prjId, "项目 {} 发布成功", fileInfo.getFileName());
return ElectromagneticResultUtil.success(true); return ElectromagneticResultUtil.success(true);
@ -433,7 +433,7 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
EdFileInfo fileInfo = this.baseMapper.selectOne(Wrappers.lambdaQuery(EdFileInfo.class) EdFileInfo fileInfo = this.baseMapper.selectOne(Wrappers.lambdaQuery(EdFileInfo.class)
.eq(EdFileInfo::getId, id)); .eq(EdFileInfo::getId, id));
String sysFilePath = commonService.getFileSysPath(fileInfo.getFilePath(), dataOwnCode); String sysFilePath = commonService.getFileSysPath(fileInfo.getFilePath(), dataOwnCode);
this.baseMapper.update(null, Wrappers.lambdaUpdate(EdFileInfo.class) this.baseMapper.update(new EdFileInfo(), Wrappers.lambdaUpdate(EdFileInfo.class)
.eq(EdFileInfo::getId, id) .eq(EdFileInfo::getId, id)
.set(EdFileInfo::getFileName, newFolderName)); .set(EdFileInfo::getFileName, newFolderName));
fileSystemService.renameFile(sysFilePath, newFolderName); fileSystemService.renameFile(sysFilePath, newFolderName);

View File

@ -34,7 +34,7 @@ public class FileFormatServiceImpl extends ServiceImpl<FileFormatMapper, FileFor
// 有可能是被废除了现在恢复 // 有可能是被废除了现在恢复
if (names.contains(suffixName)) { if (names.contains(suffixName)) {
this.baseMapper.update(null, Wrappers.<FileFormat>lambdaUpdate().set(FileFormat::getEffectFlag, EffectFlagEnum.EFFECT.code)); this.baseMapper.update(new FileFormat(), Wrappers.<FileFormat>lambdaUpdate().set(FileFormat::getEffectFlag, EffectFlagEnum.EFFECT.code));
} else { } else {
FileFormat fileFormat = new FileFormat(); FileFormat fileFormat = new FileFormat();
fileFormat.setSuffixName(suffixName); fileFormat.setSuffixName(suffixName);
@ -63,7 +63,7 @@ public class FileFormatServiceImpl extends ServiceImpl<FileFormatMapper, FileFor
*/ */
@Override @Override
public boolean deleteFileFormat(String id) { public boolean deleteFileFormat(String id) {
this.baseMapper.update(null, Wrappers.<FileFormat>lambdaUpdate().eq(FileFormat::getId, id).set(FileFormat::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code)); this.baseMapper.update(new FileFormat(), Wrappers.<FileFormat>lambdaUpdate().eq(FileFormat::getId, id).set(FileFormat::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code));
UserThreadLocal.setSuccessInfo("","", StrFormatter.format("废除了文件格式id {} ", id)); UserThreadLocal.setSuccessInfo("","", StrFormatter.format("废除了文件格式id {} ", id));
return true; return true;
} }

View File

@ -194,7 +194,7 @@ public class FileRecycleServiceImpl implements FileRecycleService {
} }
// 更新MySQL数据库 // 更新MySQL数据库
this.edFileInfoMapper.update(null, Wrappers.lambdaUpdate(EdFileInfo.class) this.edFileInfoMapper.update(new EdFileInfo(), Wrappers.lambdaUpdate(EdFileInfo.class)
.eq(EdFileInfo::getFileId, fileId) .eq(EdFileInfo::getFileId, fileId)
.set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code) .set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code)
.set(EdFileInfo::getPermanentDeleted, true) .set(EdFileInfo::getPermanentDeleted, true)

View File

@ -32,10 +32,6 @@ public class UserAccessLogServiceImpl extends ServiceImpl<UserAccessLogMapper, U
@Resource @Resource
private UserMapper userMapper; private UserMapper userMapper;
@Resource
private PermissionService permissionService;
/** /**
* 分页查询操作记录审计 * 分页查询操作记录审计
* *

View File

@ -135,25 +135,24 @@ public class BackupTask {
List<File> files = FileUtil.loopFiles(elePropertyConfig.getTmpDir(), filter); List<File> files = FileUtil.loopFiles(elePropertyConfig.getTmpDir(), filter);
for (File file : files) { for (File file : files) {
fileSystemService.deleteFile(file.getAbsolutePath()); fileSystemService.deleteFile(file.getAbsolutePath());
UserAccessLog userAccessLog = UserAccessLog.builder() UserAccessLog userAccessLog = new UserAccessLog()
.id(IdWorker.getSnowFlakeIdString()) .setId(IdWorker.getSnowFlakeIdString())
.userId("") .setUserId("")
.accessStartTime(new Date()) .setAccessStartTime(new Date())
.accessEndTime(new Date()) .setAccessEndTime(new Date())
.accessDuration(0L) .setAccessDuration(0L)
.action("删除") .setAction("删除")
.requestUrl("") .setRequestUrl("")
.requestIp("") .setRequestIp("")
.reqArgs("") .setReqArgs("")
.remoteAddr("") .setRemoteAddr("")
.accessSuccess(true) .setAccessSuccess(true)
.operationMsg("从系统中物理删除了文件" + file.getName()) .setOperationMsg("从系统中物理删除了文件" + file.getName())
.createTime(new Date()) .setCreateTime(new Date())
.operationModule(UserOperationModuleEnum.TMP.key) .setOperationModule(UserOperationModuleEnum.TMP.key)
.dataId("") .setDataId("")
.parentId("") .setParentId("")
.response("") .setResponse("");
.build();
userAccessLogMapper.insert(userAccessLog); userAccessLogMapper.insert(userAccessLog);
} }
} }