解决合并冲突

This commit is contained in:
s2042968 2025-04-21 10:27:43 +08:00
commit 344666b50b
21 changed files with 84 additions and 84 deletions

View File

@ -26,8 +26,7 @@ public class AopUtil {
} else if (value instanceof ServletResponse) {
log.info("参数中有response");
map.put(name, "response");
} else if (value instanceof MultipartFile) {
MultipartFile file = (MultipartFile) value;
} else if (value instanceof MultipartFile file) {
Map<String, Object> pars = new HashMap<>();
pars.put("fileName", file.getOriginalFilename());
pars.put("fileSize", file.getSize());

View File

@ -70,74 +70,77 @@ public class ElePropertyConfig {
@Value("${prj.folder.max.length}")
private Integer prjFolderMaxLength;
@Value("${prjRootPath}")
private String prjRootPath;
public String getEleTmpPath() {
if (EleCommonUtil.isWinOs()) {
return winPrefix + eleTmpPath;
return winPrefix + prjRootPath + eleTmpPath;
}
return eleTmpPath;
return prjRootPath + eleTmpPath;
}
public String getSysPrjPath() {
if (EleCommonUtil.isWinOs()) {
return winPrefix + sysPrjPath;
return winPrefix + prjRootPath + sysPrjPath;
}
return sysPrjPath;
return prjRootPath + sysPrjPath;
}
public String getSysUploadPath() {
if (EleCommonUtil.isWinOs()) {
return winPrefix + sysUploadPath;
return winPrefix + prjRootPath + sysUploadPath;
}
return sysUploadPath;
return prjRootPath + sysUploadPath;
}
public String getSysDownloadPath() {
if (EleCommonUtil.isWinOs()) {
return winPrefix + sysDownloadPath;
return winPrefix + prjRootPath + sysDownloadPath;
}
return sysDownloadPath;
return prjRootPath + sysDownloadPath;
}
public String getUserPrjPath() {
if (EleCommonUtil.isWinOs()) {
return winPrefix + userPrjPath;
return winPrefix + prjRootPath + userPrjPath;
}
return userPrjPath;
return prjRootPath + userPrjPath;
}
public String getUserUploadPath() {
if (EleCommonUtil.isWinOs()) {
return winPrefix + userUploadPath;
return winPrefix + prjRootPath + userUploadPath;
}
return userUploadPath;
return prjRootPath + userUploadPath;
}
public String getUserDownloadPath() {
if (EleCommonUtil.isWinOs()) {
return winPrefix + userDownloadPath;
return winPrefix + prjRootPath + userDownloadPath;
}
return userDownloadPath;
return prjRootPath + userDownloadPath;
}
public String getRepoPrjPath() {
if (EleCommonUtil.isWinOs()) {
return winPrefix + repoPrjPath;
return winPrefix + prjRootPath + repoPrjPath;
}
return repoPrjPath;
return prjRootPath + repoPrjPath;
}
public String getRepoUploadPath() {
if (EleCommonUtil.isWinOs()) {
return winPrefix + repoUploadPath;
return winPrefix + prjRootPath + repoUploadPath;
}
return repoUploadPath;
return prjRootPath + repoUploadPath;
}
public String getRepoDownloadPath() {
if (EleCommonUtil.isWinOs()) {
return winPrefix + repoDownloadPath;
return winPrefix + prjRootPath + repoDownloadPath;
}
return repoDownloadPath;
return prjRootPath + repoDownloadPath;
}
public String getUploadDataDir(int dataOwnCode) {

View File

@ -166,7 +166,6 @@ public class LoginInterceptor implements HandlerInterceptor {
.setReqArgs(reqArgs)
.setRemoteAddr(getRealIp(request))
.setAccessSuccess(true)
.setCreateTime(new Date())
.setOperationModule(userOperation.modelName().key)
.setOperationMsg(res.getErrorMessage())
.setDataId("")
@ -193,7 +192,6 @@ public class LoginInterceptor implements HandlerInterceptor {
.setReqArgs(reqArgs)
.setRemoteAddr(getRealIp(request))
.setAccessSuccess(true)
.setCreateTime(new Date())
.setOperationModule(userOperation.modelName().key)
.setOperationMsg(accessSuccessInfo.getSuccessMsg())
.setDataId(accessSuccessInfo.getDataId())

View File

@ -11,6 +11,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("/data/ed/backup/")
public class FileBackupLogController {
@ -27,7 +29,7 @@ public class FileBackupLogController {
@GetMapping(value = "restore")
@UserOperation(value = "系统恢复", modelName = UserOperationModuleEnum.BACKUP_FILE)
public ElectromagneticResult<?> restore() {
fileBackLogService.restore();
return ElectromagneticResultUtil.success(true);
List<String> restorePaths = fileBackLogService.restore();
return ElectromagneticResultUtil.success(restorePaths);
}
}

View File

@ -2,17 +2,13 @@ package com.electromagnetic.industry.software.manage.pojo.models;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.electromagnetic.industry.software.common.enums.EffectFlagEnum;
import com.electromagnetic.industry.software.common.util.EleCommonUtil;
import com.electromagnetic.industry.software.common.util.IdWorker;
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import lombok.experimental.FieldNameConstants;
import java.util.Date;
@EqualsAndHashCode(callSuper = true)
@TableName("ed_file_info")
@Accessors(chain = true)
@ -125,17 +121,10 @@ public class EdFileInfo extends BaseModel {
private Boolean permanentDeleted;
public void newInit() {
String userId = UserThreadLocal.getUserId();
String newFileDbId = IdWorker.getSnowFlakeIdString();
String fileTime = EleCommonUtil.getNowTimeStr();
Date now = new Date();
this.setUpdatedBy(userId);
this.setId(newFileDbId);
this.setUpdatedTime(now);
this.setCreatedTime(now);
this.setFileTime(fileTime);
this.setCreatedBy(userId);
this.setFileId(newFileDbId);
this.setEffectFlag(EffectFlagEnum.EFFECT.code);
}
}

View File

@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("file_tag_relations")
public class FileTagRelation extends BaseModel {

View File

@ -1,13 +1,17 @@
package com.electromagnetic.industry.software.manage.pojo.models;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.electromagnetic.industry.software.common.enums.EffectFlagEnum;
import com.electromagnetic.industry.software.common.util.IdWorker;
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("ed_role") // 指定表名
public class Role extends BaseModel {

View File

@ -7,9 +7,11 @@ import com.electromagnetic.industry.software.common.enums.EffectFlagEnum;
import com.electromagnetic.industry.software.common.util.IdWorker;
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("ed_role_permission")
public class RolePermission extends BaseModel {

View File

@ -51,9 +51,6 @@ public class UserAccessLog extends BaseModel {
// 异常信息 供开发者异常查看
private String exceptionDetail;
// 创建时间对应操作时间
private Date createTime;
// 操作对象
private String operationModule;

View File

@ -2,9 +2,11 @@ package com.electromagnetic.industry.software.manage.service;
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
import java.util.List;
public interface FileBackLogService {
ElectromagneticResult<?> query(Integer pageNumber, Integer pageSize);
void restore();
List<String> restore();
}

View File

@ -191,8 +191,8 @@ public class ChatService {
UserLoginInfo userLoginInfo = new UserLoginInfo();
userLoginInfo.setUserId(queryDTO.getUserId());
UserThreadLocal.set(userLoginInfo);
UserThreadLocal.remove();
aiQuestionRecordMapper.insert(record);
UserThreadLocal.remove();
return ChatClient.builder(model)
.defaultSystem("必须用中文回答")
.defaultAdvisors(messageChatMemoryAdvisor, questionAnswerAdvisor)

View File

@ -7,7 +7,6 @@ import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.lang.tree.TreeNodeConfig;
import cn.hutool.core.lang.tree.TreeUtil;
import cn.hutool.core.text.StrFormatter;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.json.JSONUtil;
@ -201,7 +200,7 @@ public class CommonService {
EdFileInfo fileInfo = map.get(id);
String tmp;
if (fileInfo.getDataType().equals(EleDataTypeEnum.FILE.code)) {
tmp = fileInfo.getFileName() + "." + fileInfo.getFileType() + "." + fileInfo.getFileCode();
tmp = fileInfo.getFileName() + "." + fileInfo.getFileType();
} else {
tmp = fileInfo.getFileName() + File.separator;
}
@ -237,7 +236,7 @@ public class CommonService {
case USER_FILE, USER_PRJ -> queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.USER_PRJ.code);
case SYS_FILE, SYS_PRJ -> queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.SYS_PRJ.code);
case REPO_PRJ, REPO_FILE -> queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.REPO_PRJ.code);
default -> ElectromagneticResultUtil.fail("-1", "参数错误");
default -> throw new BizException("参数错误");
}
return edFileInfoMapper.selectList(queryWrapper);
}
@ -463,8 +462,6 @@ public class CommonService {
// 如果文件夹下存在文件包括文件夹和已经逻辑删除的文件则不允许删除后面管理员选择会有物理删除文件夹和文件的功能此时MySQL和文件系统则会进行物理删除该文件
EdFileInfo srcFileInfo = edFileInfoMapper.selectById(id);
Assert.isTrue(srcFileInfo.getDataType().equals(EleDataTypeEnum.FOLDER.code), "禁止删除目录");
String srcFilePath = getFileSysPath(srcFileInfo.getId());
String uuid = IdUtil.fastSimpleUUID();
try {
// 这里要分两种情况1是删除层级目录2是删除用户创建的文件夹
String parentId = srcFileInfo.getParentId();
@ -535,11 +532,8 @@ public class CommonService {
}
public Set<String> selectPrjLeafs(int dataOwnCode, List<String> accessibleIds) {
Set<String> res = new HashSet<>();
List<String> prjInfo = List.of();
List<String> prjInfo;
DataOwnEnum obj = DataOwnEnum.getEnumByCode(dataOwnCode);
switch (Objects.requireNonNull(obj)) {
case USER_FILE, USER_PRJ ->
@ -548,7 +542,7 @@ public class CommonService {
prjInfo = querySysPrjTree(PrjQuerySource.SYS_DB.value, accessibleIds, new FileProjectVO()).getOrDefault(PrjQuerySource.SYS_DB.value, new ArrayList<>());
case REPO_PRJ, REPO_FILE ->
prjInfo = queryRepoPrjTree(PrjQuerySource.REPO_DB.value, accessibleIds, new FileProjectVO()).getOrDefault(PrjQuerySource.REPO_DB.value, new ArrayList<>());
default -> ElectromagneticResultUtil.fail("-1", "参数错误");
default -> throw new BizException("参数错误");
}
for (String info : prjInfo) {
@ -619,7 +613,7 @@ public class CommonService {
case USER_FILE, USER_PRJ -> queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.USER_PRJ.code);
case SYS_FILE, SYS_PRJ -> queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.SYS_PRJ.code);
case REPO_PRJ, REPO_FILE -> queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.REPO_PRJ.code);
default -> ElectromagneticResultUtil.fail("-1", "参数错误");
default -> throw new BizException("参数错误");
}
long dirCount = edFileInfoMapper.selectCount(queryWrapper);
@ -681,7 +675,7 @@ public class CommonService {
throw new BizException(info);
}
UserThreadLocal.setSuccessInfo(Optional.ofNullable(finalEdFileInfo).map(EdFileInfo::getParentId).orElse(""),
Optional.ofNullable(finalEdFileInfo).map(EdFileInfo::getFileId).orElse(""),
Optional.ofNullable(finalEdFileInfo).map(EdFileInfo::getId).orElse(""),
"文件 {} 为上传到 {} 成功,同名同后缀的处理方式为 {},存入的文件名为 {}",
fileName,
destPath,

View File

@ -873,6 +873,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
maps.putAll(edFileInfos);
}
Set<EdFileInfo> resFiles = new HashSet<>(maps.values());
String prjId = resFiles.stream().findFirst().get().getFilePath().split(MYSQL_FILE_PATH_SPLIT)[0];
List<EdFileInfo> prjFolders = this.baseMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class)
.likeRight(EdFileInfo::getFilePath, prjId + MYSQL_FILE_PATH_SPLIT)
@ -886,12 +887,22 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
resFiles.clear();
resFiles.addAll(tmps.values());
resFiles.add(prjFileInfo);
List<EdFileInfo> files = resFiles.stream().filter(e -> e.getDataType().equals(EleDataTypeEnum.FILE.code)).toList();
for (EdFileInfo edFileInfo : files) {
String filePath = commonService.getFileSysPath(edFileInfo.getId()); // file
String destPath = userDownloadDataDir + File.separator + EXPORT_PRJ_NAME + "_" + nowTimeStr + File.separator + EXPORT_PRJ_NAME + File.separator + edFileInfo.getId();
fileSystemService.copyFile(filePath, destPath);
}
// 去除用户创建的空文件夹
List<EdFileInfo> userFolders = resFiles.stream().filter(e ->
e.getDataType().equals(EleDataTypeEnum.FOLDER.code) && DataOwnEnum.isFileCode(e.getDataOwn())
).toList();
List<String> userFolderIds = userFolders.stream().map(EdFileInfo::getId).collect(Collectors.toList());
List<String> fileParentIds = files.stream().map(EdFileInfo::getParentId).toList();
userFolderIds.removeAll(fileParentIds);
resFiles = resFiles.stream().filter(e -> !userFolderIds.contains(e.getId())).collect(Collectors.toSet());
String json = JSONUtil.toJsonStr(resFiles);
String mysqlFilePath = userDownloadDataDir + File.separator + EXPORT_PRJ_NAME + "_" + nowTimeStr + File.separator + PRJ_INFO + ".json";
fileSystemService.writeStringToFile(mysqlFilePath, json);

View File

@ -69,7 +69,7 @@ public class FileBackLogServiceImpl extends ServiceImpl<FileBackupLogMapper, Fil
fileBackLogVO.setBackStartTime(DateUtil.date(fileBackupLog.getStartTime()));
fileBackLogVO.setBackEndTime(DateUtil.date(fileBackupLog.getEndTime()));
fileBackLogVO.setDataOwn(map.get(fileBackupLog.getFileId()).getDataOwn());
fileBackLogVO.setDataOwner(DataOwnEnum.getTypeByCode(map.get(fileBackupLog.getFileId()).getDataOwn()));
fileBackLogVO.setDataOwner(DataOwnEnum.getEnumByCode(map.get(fileBackupLog.getFileId()).getDataOwn()).type);
fileBackLogVO.setFilePath(paths.get(map.get(fileBackupLog.getFileId()).getFilePath()));
list.add(fileBackLogVO);
}
@ -79,18 +79,19 @@ public class FileBackLogServiceImpl extends ServiceImpl<FileBackupLogMapper, Fil
}
@Override
public void restore() {
public List<String> restore() {
List<EdFileInfo> edFileInfos = edFileInfoMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class)
.select(EdFileInfo.class, file -> !StrUtil.equals(file.getColumn(), "file_content"))
.eq(EdFileInfo::getPermanentDeleted, false)
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FILE.code));
List<String> restoreFilePaths = new ArrayList<>();
for (EdFileInfo edFileInfo : edFileInfos) {
String destPath = "";
String destPath;
if (DataOwnEnum.isUserCode(edFileInfo.getDataOwn())) {
destPath = commonService.getPrjRootPath1(edFileInfo.getDataOwn()) + File.separator + edFileInfo.getCreatedBy() + File.separator + commonService.getDbPath(edFileInfo.getFilePath());
destPath = commonService.getPrjRootPath1(edFileInfo.getDataOwn()) + File.separator + edFileInfo.getCreatedBy() + File.separator + edFileInfo.getId();
} else {
destPath = commonService.getPrjRootPath1(edFileInfo.getDataOwn()) + File.separator + commonService.getDbPath(edFileInfo.getFilePath());
destPath = commonService.getPrjRootPath1(edFileInfo.getDataOwn()) + File.separator + edFileInfo.getId();
}
destPath = destPath.replace("//", "/");
log.info("back up file path is {}", destPath);
@ -98,9 +99,11 @@ public class FileBackLogServiceImpl extends ServiceImpl<FileBackupLogMapper, Fil
byte[] bytes = backupHandler.downloadFile(edFileInfo.getId());
FileUtil.writeBytes(bytes, destPath);
String dbPath = commonService.getDbPath(edFileInfo.getFilePath());
restoreFilePaths.add(dbPath);
UserThreadLocal.setSuccessInfo(edFileInfo.getParentId(), edFileInfo.getId(), "{} 恢复成功,路径为 {}", edFileInfo.getFileName() + "." + edFileInfo.getFileType(), dbPath);
}
}
UserThreadLocal.setSuccessInfo("", "", "数据库恢复成功");
return restoreFilePaths;
}
}

View File

@ -118,7 +118,7 @@ public class FileRecycleServiceImpl implements FileRecycleService {
Map<String, String> filesPath = commonService.getFilesPath(filePaths);
Map<String, String> userIdNameMap = getUserIdNameMap(records.stream().map(FileRecycleQueryVO::getUpdatedBy).toList());
records.forEach(e -> {
e.setDataOwner(DataOwnEnum.getTypeByCode(e.getDataOwn()));
e.setDataOwner(DataOwnEnum.getEnumByCode(e.getDataOwn()).type);
e.setFilePrjPath(filesPath.get(e.getFilePath()));
e.setFileSizeShow(EleCommonUtil.convertFileSize(e.getFileSize()));
e.setUserName(userIdNameMap.get(e.getUpdatedBy()));

View File

@ -43,7 +43,7 @@ public class UserAccessLogServiceImpl extends ServiceImpl<UserAccessLogMapper, U
@Override
public ElectromagneticResult<?> info(AccessLogQueryDTO pars, boolean adminQuery) {
LambdaQueryWrapper<UserAccessLog> queryWrapper = Wrappers.lambdaQuery(UserAccessLog.class).orderByDesc(UserAccessLog::getCreateTime);
LambdaQueryWrapper<UserAccessLog> queryWrapper = Wrappers.lambdaQuery(UserAccessLog.class).orderByDesc(UserAccessLog::getCreatedTime);
if (!adminQuery) {
queryWrapper.eq(UserAccessLog::getDataId, pars.getDataId());
} else {

View File

@ -157,8 +157,7 @@ public class BackupTask {
.setReqArgs("")
.setRemoteAddr("")
.setAccessSuccess(true)
.setOperationMsg("从系统中物理删除了文件" + file.getName())
.setCreateTime(new Date())
.setOperationMsg("从系统中物理删除了文件--->" + file.getAbsolutePath())
.setOperationModule(UserOperationModuleEnum.TMP.key)
.setDataId("")
.setParentId("")

View File

@ -17,11 +17,13 @@ public enum DataOwnEnum {
REPO_FILE(3, "库数据文件(文件夹)", "库数据");
private static final Map<Integer, Integer> FILE_PRJ_MAP = new HashMap<>();
private static final Map<Integer, DataOwnEnum> CODE_ENUM = new HashMap<>();
static {
FILE_PRJ_MAP.put(DataOwnEnum.SYS_FILE.code, DataOwnEnum.SYS_PRJ.code);
FILE_PRJ_MAP.put(DataOwnEnum.USER_FILE.code, DataOwnEnum.USER_PRJ.code);
FILE_PRJ_MAP.put(DataOwnEnum.REPO_FILE.code, DataOwnEnum.REPO_PRJ.code);
addEnum();
}
public final int code;
@ -52,21 +54,14 @@ public enum DataOwnEnum {
return code == REPO_FILE.code || code == REPO_PRJ.code;
}
public static String getTypeByCode(int code) {
for (DataOwnEnum e : DataOwnEnum.values()) {
if (e.code == code) {
return e.type;
}
}
return "";
public static DataOwnEnum getEnumByCode(int code) {
return CODE_ENUM.getOrDefault(code, null);
}
public static DataOwnEnum getEnumByCode(int code) {
for (DataOwnEnum e : DataOwnEnum.values()) {
if (e.code == code) {
return e;
private static void addEnum() {
for (DataOwnEnum value : DataOwnEnum.values()) {
CODE_ENUM.put(value.code, value);
}
}
return null;
}
}