Merge branch 'dev-jdk17' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into dev-jdk17
This commit is contained in:
commit
997bef0b3b
|
|
@ -6,6 +6,8 @@ import lombok.Getter;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class ElePropertyConfig {
|
public class ElePropertyConfig {
|
||||||
|
|
||||||
|
|
@ -73,6 +75,13 @@ public class ElePropertyConfig {
|
||||||
@Value("${prjRootPath}")
|
@Value("${prjRootPath}")
|
||||||
private String prjRootPath;
|
private String prjRootPath;
|
||||||
|
|
||||||
|
@Value("${allow.upload.file.types}")
|
||||||
|
private String allowUploadFileTypes;
|
||||||
|
|
||||||
|
public List<String> getAiAllowUploadFileTypes() {
|
||||||
|
return List.of(allowUploadFileTypes.replace(" ", "").split(","));
|
||||||
|
}
|
||||||
|
|
||||||
public String getEleTmpPath() {
|
public String getEleTmpPath() {
|
||||||
if (EleCommonUtil.isWinOs()) {
|
if (EleCommonUtil.isWinOs()) {
|
||||||
return winPrefix + prjRootPath + eleTmpPath;
|
return winPrefix + prjRootPath + eleTmpPath;
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.method.HandlerMethod;
|
import org.springframework.web.method.HandlerMethod;
|
||||||
import org.springframework.web.servlet.HandlerInterceptor;
|
import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -130,11 +129,6 @@ public class LoginInterceptor implements HandlerInterceptor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
|
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,7 @@ package com.electromagnetic.industry.software.manage.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.electromagnetic.industry.software.manage.pojo.models.User;
|
import com.electromagnetic.industry.software.manage.pojo.models.User;
|
||||||
import com.electromagnetic.industry.software.manage.pojo.other.PublishParam;
|
|
||||||
import com.electromagnetic.industry.software.manage.pojo.other.SearchKeyWords;
|
import com.electromagnetic.industry.software.manage.pojo.other.SearchKeyWords;
|
||||||
import com.electromagnetic.industry.software.manage.pojo.other.UserDeleteKeyWords;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
|
||||||
|
|
@ -13,13 +13,13 @@ import java.util.Date;
|
||||||
|
|
||||||
@TableName("ed_users")
|
@TableName("ed_users")
|
||||||
@Data
|
@Data
|
||||||
public class User extends BaseModel{
|
public class User extends BaseModel {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 主键ID
|
* 主键ID
|
||||||
*/
|
*/
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户姓名
|
* 用户姓名
|
||||||
*/
|
*/
|
||||||
|
|
@ -89,7 +89,7 @@ public class User extends BaseModel{
|
||||||
* 盐
|
* 盐
|
||||||
*/
|
*/
|
||||||
private String salt;
|
private String salt;
|
||||||
|
|
||||||
public void newInit() {
|
public void newInit() {
|
||||||
String id = IdWorker.getSnowFlakeIdString();
|
String id = IdWorker.getSnowFlakeIdString();
|
||||||
String userId = UserThreadLocal.getUserId();
|
String userId = UserThreadLocal.getUserId();
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import java.util.Date;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@TableName("ed_user_role")
|
@TableName("ed_user_role")
|
||||||
public class UserRole extends BaseModel{
|
public class UserRole extends BaseModel {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 主键ID
|
* 主键ID
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
package com.electromagnetic.industry.software.manage.pojo.other;
|
package com.electromagnetic.industry.software.manage.pojo.other;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ package com.electromagnetic.industry.software.manage.service.serviceimpl;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import cn.hutool.core.text.StrFormatter;
|
import cn.hutool.core.text.StrFormatter;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.crypto.digest.DigestUtil;
|
import cn.hutool.crypto.digest.DigestUtil;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
|
@ -50,7 +49,6 @@ import java.util.*;
|
||||||
@Service
|
@Service
|
||||||
public class ChatService {
|
public class ChatService {
|
||||||
|
|
||||||
private static final List<String> ALLOWS_FILE_TYPES = List.of("doc", "docx", "txt", "csv", "xls", "xlsx", "pdf", "ppt", "pptx");
|
|
||||||
@Resource
|
@Resource
|
||||||
private VectorStore vectorStore;
|
private VectorStore vectorStore;
|
||||||
@Resource
|
@Resource
|
||||||
|
|
@ -73,7 +71,7 @@ public class ChatService {
|
||||||
.map(AiFileUploadRecord::getVectorId)
|
.map(AiFileUploadRecord::getVectorId)
|
||||||
.toList();
|
.toList();
|
||||||
Optional<Boolean> delete = vectorStore.delete(vectorIds);
|
Optional<Boolean> delete = vectorStore.delete(vectorIds);
|
||||||
if (delete.isPresent() && ObjectUtil.equals(delete.get(), true)) {
|
if (null != delete && delete.isPresent() && delete.get()) {
|
||||||
aiFileUploadRecordMapper.update(Wrappers.lambdaUpdate(AiFileUploadRecord.class)
|
aiFileUploadRecordMapper.update(Wrappers.lambdaUpdate(AiFileUploadRecord.class)
|
||||||
.in(AiFileUploadRecord::getId, ids)
|
.in(AiFileUploadRecord::getId, ids)
|
||||||
.set(AiFileUploadRecord::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code));
|
.set(AiFileUploadRecord::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code));
|
||||||
|
|
@ -91,7 +89,7 @@ public class ChatService {
|
||||||
}
|
}
|
||||||
|
|
||||||
String fileType = FileUtil.extName(file.getOriginalFilename());
|
String fileType = FileUtil.extName(file.getOriginalFilename());
|
||||||
if (!ALLOWS_FILE_TYPES.contains(fileType)) {
|
if (!elePropertyConfig.getAiAllowUploadFileTypes().contains(fileType)) {
|
||||||
return ElectromagneticResultUtil.fail("-1", StrFormatter.format("当前格式 {} 不支持", fileType));
|
return ElectromagneticResultUtil.fail("-1", StrFormatter.format("当前格式 {} 不支持", fileType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -198,12 +198,9 @@ public class CommonService {
|
||||||
StringBuilder path = new StringBuilder();
|
StringBuilder path = new StringBuilder();
|
||||||
for (String id : ids) {
|
for (String id : ids) {
|
||||||
EdFileInfo fileInfo = map.get(id);
|
EdFileInfo fileInfo = map.get(id);
|
||||||
String tmp;
|
String tmp = EleCommonUtil.simpleTrueFalse(Objects.equals(fileInfo.getDataType(), EleDataTypeEnum.FILE.code),
|
||||||
if (fileInfo.getDataType().equals(EleDataTypeEnum.FILE.code)) {
|
fileInfo.getFileName() + "." + fileInfo.getFileType(),
|
||||||
tmp = fileInfo.getFileName() + "." + fileInfo.getFileType();
|
fileInfo.getFileName() + File.separator);
|
||||||
} else {
|
|
||||||
tmp = fileInfo.getFileName() + File.separator;
|
|
||||||
}
|
|
||||||
path.append(tmp);
|
path.append(tmp);
|
||||||
}
|
}
|
||||||
return path.toString();
|
return path.toString();
|
||||||
|
|
@ -254,9 +251,8 @@ public class CommonService {
|
||||||
.eq(EdFileInfo::getId, parentId);
|
.eq(EdFileInfo::getId, parentId);
|
||||||
EdFileInfo edFileInfo = edFileInfoMapper.selectOne(queryWrapper);
|
EdFileInfo edFileInfo = edFileInfoMapper.selectOne(queryWrapper);
|
||||||
String currentPath = edFileInfo.getFilePath();
|
String currentPath = edFileInfo.getFilePath();
|
||||||
List<String> paths = CollUtil.newArrayList(edFileInfo.getFilePath().split(MYSQL_FILE_PATH_SPLIT));
|
|
||||||
if (maxLengthCheck) {
|
if (maxLengthCheck) {
|
||||||
if (paths.size() >= elePropertyConfig.getPrjFolderMaxLength()) {
|
if (StrUtil.count(currentPath, MYSQL_FILE_PATH_SPLIT) >= elePropertyConfig.getPrjFolderMaxLength() - 1) {
|
||||||
String info = StrFormatter.format("当前子集已达到最大层级,禁止创建子集,{} 创建失败。", folderName);
|
String info = StrFormatter.format("当前子集已达到最大层级,禁止创建子集,{} 创建失败。", folderName);
|
||||||
log.error(info);
|
log.error(info);
|
||||||
return ElectromagneticResultUtil.fail("-1", info);
|
return ElectromagneticResultUtil.fail("-1", info);
|
||||||
|
|
@ -300,19 +296,12 @@ public class CommonService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1.询管理员从层级定义处查。2.用户从数据库管理界面查询。
|
* @param querySource 管理员从层级定义处查询,用户从数据库管理界面查询。
|
||||||
*
|
|
||||||
* @param querySource 0:询管理员从层级定义处查。 2.用户从数据库管理界面查询。
|
|
||||||
* @param accessibleIds
|
* @param accessibleIds
|
||||||
* @param returnType
|
* @param returnType
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Map<Integer, List<String>> querySysPrjTree(int querySource, List<String> accessibleIds, Object returnType) {
|
public Map<Integer, List<String>> querySysPrjTree(int querySource, List<String> accessibleIds, Object returnType) {
|
||||||
|
|
||||||
/**
|
|
||||||
* querySource=SYS_PRJ(从层级定义处查询) querySource=SYS_DB(从数据库界面处查询)
|
|
||||||
*/
|
|
||||||
|
|
||||||
Map<Integer, List<String>> map = new HashMap<>();
|
Map<Integer, List<String>> map = new HashMap<>();
|
||||||
try {
|
try {
|
||||||
// 首先查出所有的工程id
|
// 首先查出所有的工程id
|
||||||
|
|
@ -594,13 +583,13 @@ public class CommonService {
|
||||||
|
|
||||||
|
|
||||||
public ElectromagneticResult<?> upload(String parentId, MultipartFile file, Integer strategy, int dataOwnCode) {
|
public ElectromagneticResult<?> upload(String parentId, MultipartFile file, Integer strategy, int dataOwnCode) {
|
||||||
Assert.isTrue(FileRepeatEnum.contains(strategy), "解决重名文件参数错误");
|
Assert.isTrue(contains(strategy), "解决重名文件参数错误");
|
||||||
String fileName = file.getOriginalFilename();
|
String fileName = file.getOriginalFilename();
|
||||||
String mainName = FileUtil.mainName(fileName);
|
String mainName = FileUtil.mainName(fileName);
|
||||||
String suffix = FileUtil.getSuffix(fileName);
|
String suffix = FileUtil.getSuffix(fileName);
|
||||||
Assert.isTrue(StrUtil.isNotEmpty(suffix), "文件类型不能为空");
|
Assert.isTrue(StrUtil.isNotEmpty(suffix), "文件类型不能为空");
|
||||||
String destPath = getDbPathById(parentId);
|
String destPath = getDbPathById(parentId);
|
||||||
String strategyStr = FileRepeatEnum.getDesc(strategy);
|
String strategyStr = getDesc(strategy);
|
||||||
Assert.isTrue(!file.isEmpty(), StrFormatter.format("文件 {} 为空,文件上传到 {} 失败,同名同后缀的处理方式为 {}", fileName, destPath, strategyStr));
|
Assert.isTrue(!file.isEmpty(), StrFormatter.format("文件 {} 为空,文件上传到 {} 失败,同名同后缀的处理方式为 {}", fileName, destPath, strategyStr));
|
||||||
Assert.isTrue(EleCommonUtil.isFileNameValid(file.getOriginalFilename()), StrFormatter.format("文件 {} {},上传到 {} 失败,同名同后缀的处理方式为 {}", fileName, NAME_VALID_MSG, destPath, strategyStr));
|
Assert.isTrue(EleCommonUtil.isFileNameValid(file.getOriginalFilename()), StrFormatter.format("文件 {} {},上传到 {} 失败,同名同后缀的处理方式为 {}", fileName, NAME_VALID_MSG, destPath, strategyStr));
|
||||||
// 查找下一层,看是否存在顶级定义相关文件,如果存在,则该层属于管理员层级定义的,不允许上传文件
|
// 查找下一层,看是否存在顶级定义相关文件,如果存在,则该层属于管理员层级定义的,不允许上传文件
|
||||||
|
|
@ -620,7 +609,7 @@ public class CommonService {
|
||||||
Assert.isTrue(dirCount == 0, "文件 {} 上传到 {} 失败,层级结构不允许上传文件,同名同后缀的处理方式为 {}", fileName, destPath, strategyStr);
|
Assert.isTrue(dirCount == 0, "文件 {} 上传到 {} 失败,层级结构不允许上传文件,同名同后缀的处理方式为 {}", fileName, destPath, strategyStr);
|
||||||
EdFileInfo newEdFileInfo = new EdFileInfo();
|
EdFileInfo newEdFileInfo = new EdFileInfo();
|
||||||
newEdFileInfo.newInit();
|
newEdFileInfo.newInit();
|
||||||
EdFileInfo finalEdFileInfo;
|
EdFileInfo finalEdFileInfo = null;
|
||||||
// 首先检查是否是同名文件
|
// 首先检查是否是同名文件
|
||||||
try {
|
try {
|
||||||
Assert.isTrue(EleCommonUtil.isFileNameValid(fileName), NAME_VALID_MSG);
|
Assert.isTrue(EleCommonUtil.isFileNameValid(fileName), NAME_VALID_MSG);
|
||||||
|
|
@ -640,7 +629,7 @@ public class CommonService {
|
||||||
String fileCode = createFileCode(codePathByDbPath, suffix, FILE_START_VERSION, newEdFileInfo.getFileTime());
|
String fileCode = createFileCode(codePathByDbPath, suffix, FILE_START_VERSION, newEdFileInfo.getFileTime());
|
||||||
newEdFileInfo.setParentId(parentId)
|
newEdFileInfo.setParentId(parentId)
|
||||||
.setFileCode(fileCode)
|
.setFileCode(fileCode)
|
||||||
.setSaveStatus(EleDataSaveStatusEnum.SUCCESS.code)
|
.setSaveStatus(EleDataSaveStatusEnum.UPLOADING.code)
|
||||||
.setDataOwn(dataOwnCode)
|
.setDataOwn(dataOwnCode)
|
||||||
.setFileName(mainName)
|
.setFileName(mainName)
|
||||||
.setFileContent(EleCommonUtil.parse(file.getInputStream(), suffix))
|
.setFileContent(EleCommonUtil.parse(file.getInputStream(), suffix))
|
||||||
|
|
@ -656,10 +645,16 @@ public class CommonService {
|
||||||
FileUtil.writeFromStream(file.getInputStream(), fileDestPath);
|
FileUtil.writeFromStream(file.getInputStream(), fileDestPath);
|
||||||
EleCommonUtil.encryptFile(fileDestPath, SecureUtil.aes(FILE_SEC_PASSWD.getBytes()));
|
EleCommonUtil.encryptFile(fileDestPath, SecureUtil.aes(FILE_SEC_PASSWD.getBytes()));
|
||||||
finalEdFileInfo = newEdFileInfo;
|
finalEdFileInfo = newEdFileInfo;
|
||||||
|
newEdFileInfo.setSaveStatus(EleDataSaveStatusEnum.SUCCESS.code);
|
||||||
|
edFileInfoMapper.insertOrUpdate(newEdFileInfo);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String info = StrFormatter.format("文件 {} 为上传到 {} 失败,原因 {},同名同后缀的处理方式为 {}", fileName, destPath, e.getMessage(), strategyStr);
|
String info = StrFormatter.format("文件 {} 为上传到 {} 失败,原因 {},同名同后缀的处理方式为 {}", fileName, destPath, e.getMessage(), strategyStr);
|
||||||
newEdFileInfo.setParentId(parentId)
|
if (Objects.isNull(finalEdFileInfo)) {
|
||||||
|
log.error(info, e);
|
||||||
|
throw new BizException(info);
|
||||||
|
}
|
||||||
|
finalEdFileInfo.setParentId(parentId)
|
||||||
.setFileName(mainName)
|
.setFileName(mainName)
|
||||||
.setSaveStatus(EleDataSaveStatusEnum.FAIL.code)
|
.setSaveStatus(EleDataSaveStatusEnum.FAIL.code)
|
||||||
.setFileType(suffix)
|
.setFileType(suffix)
|
||||||
|
|
@ -670,22 +665,21 @@ public class CommonService {
|
||||||
.setDataType(EleDataTypeEnum.FILE.code)
|
.setDataType(EleDataTypeEnum.FILE.code)
|
||||||
.setDataStatus(PublishEnum.PUBLISHED.getCode())
|
.setDataStatus(PublishEnum.PUBLISHED.getCode())
|
||||||
.setEffectFlag(EffectFlagEnum.NOT_EFFECTIVE.code);
|
.setEffectFlag(EffectFlagEnum.NOT_EFFECTIVE.code);
|
||||||
edFileInfoMapper.insertOrUpdate(newEdFileInfo);
|
edFileInfoMapper.insertOrUpdate(finalEdFileInfo);
|
||||||
log.error(info, e);
|
log.error(info, e);
|
||||||
throw new BizException(info);
|
throw new BizException(info);
|
||||||
}
|
}
|
||||||
UserThreadLocal.setSuccessInfo(Optional.ofNullable(finalEdFileInfo).map(EdFileInfo::getParentId).orElse(""),
|
UserThreadLocal.setSuccessInfo(parentId,
|
||||||
Optional.ofNullable(finalEdFileInfo).map(EdFileInfo::getId).orElse(""),
|
Optional.ofNullable(finalEdFileInfo).map(EdFileInfo::getId).orElse(""),
|
||||||
"文件 {} 为上传到 {} 成功,同名同后缀的处理方式为 {},存入的文件名为 {}",
|
"文件 {} 为上传到 {} 成功,同名同后缀的处理方式为 {},存入的文件名为 {}",
|
||||||
fileName,
|
fileName,
|
||||||
destPath,
|
destPath,
|
||||||
strategyStr,
|
strategyStr,
|
||||||
Optional.ofNullable(finalEdFileInfo).map(EdFileInfo::getFileName).orElse(fileName) + "." + Optional.ofNullable(finalEdFileInfo).map(EdFileInfo::getFileType).orElse(suffix));
|
fileName + "." + suffix);
|
||||||
return ElectromagneticResultUtil.success(newEdFileInfo.getId());
|
return ElectromagneticResultUtil.success(Optional.ofNullable(finalEdFileInfo).map(EdFileInfo::getId).orElse(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
private EdFileInfo handUploadRepeatFile(String parentId, MultipartFile file, Integer strategy, int dataOwnCode) throws IOException {
|
||||||
public EdFileInfo handUploadRepeatFile(String parentId, MultipartFile file, Integer strategy, int dataOwnCode) throws IOException {
|
|
||||||
String fileName = file.getOriginalFilename();
|
String fileName = file.getOriginalFilename();
|
||||||
String mainName = FileUtil.mainName(fileName);
|
String mainName = FileUtil.mainName(fileName);
|
||||||
String suffix = FileUtil.getSuffix(fileName);
|
String suffix = FileUtil.getSuffix(fileName);
|
||||||
|
|
@ -699,7 +693,7 @@ public class CommonService {
|
||||||
.setFileSize(file.getSize())
|
.setFileSize(file.getSize())
|
||||||
.setDataType(EleDataTypeEnum.FILE.code)
|
.setDataType(EleDataTypeEnum.FILE.code)
|
||||||
.setDataStatus(PublishEnum.PUBLISHED.getCode())
|
.setDataStatus(PublishEnum.PUBLISHED.getCode())
|
||||||
.setSaveStatus(EleDataSaveStatusEnum.SUCCESS.code)
|
.setSaveStatus(EleDataSaveStatusEnum.UPLOADING.code)
|
||||||
.setDataOwn(dataOwnCode)
|
.setDataOwn(dataOwnCode)
|
||||||
.setEffectFlag(EffectFlagEnum.EFFECT.code);
|
.setEffectFlag(EffectFlagEnum.EFFECT.code);
|
||||||
if (strategy == REVERSION.code) {
|
if (strategy == REVERSION.code) {
|
||||||
|
|
@ -752,6 +746,8 @@ public class CommonService {
|
||||||
String fileDestPath = getFileSysPath(newEdFileInfo.getId());
|
String fileDestPath = getFileSysPath(newEdFileInfo.getId());
|
||||||
fileSystemService.save(file.getInputStream(), fileDestPath);
|
fileSystemService.save(file.getInputStream(), fileDestPath);
|
||||||
EleCommonUtil.encryptFile(fileDestPath, SecureUtil.aes(FILE_SEC_PASSWD.getBytes()));
|
EleCommonUtil.encryptFile(fileDestPath, SecureUtil.aes(FILE_SEC_PASSWD.getBytes()));
|
||||||
|
newEdFileInfo.setSaveStatus(EleDataSaveStatusEnum.SUCCESS.code);
|
||||||
|
edFileInfoMapper.insertOrUpdate(newEdFileInfo);
|
||||||
return newEdFileInfo;
|
return newEdFileInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -340,14 +340,11 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
throw new BizException("文件名已经存在");
|
throw new BizException("文件名已经存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
String srcFilePath = commonService.getFileSysPath(fileInfo.getId());
|
|
||||||
String dbPath = commonService.getDbPath(fileInfo.getFilePath());
|
String dbPath = commonService.getDbPath(fileInfo.getFilePath());
|
||||||
this.baseMapper.update(new EdFileInfo(), 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()));
|
||||||
String newName = updateFileInfoDTO.getFileName() + "." + fileInfo.getFileType() + "." + fileInfo.getFileCode();
|
|
||||||
fileSystemService.renameFile(srcFilePath, newName);
|
|
||||||
UserThreadLocal.setSuccessInfo(commonService.getLastPrjLeafId(fileInfo.getFilePath()), updateFileInfoDTO.getId(), "更新文件信息成功,新文件名为 {}.{},新备注为 {},路径为 {}", newFileName, fileInfo.getFileType(), updateFileInfoDTO.getFileNote(), dbPath);
|
UserThreadLocal.setSuccessInfo(commonService.getLastPrjLeafId(fileInfo.getFilePath()), updateFileInfoDTO.getId(), "更新文件信息成功,新文件名为 {}.{},新备注为 {},路径为 {}", newFileName, fileInfo.getFileType(), updateFileInfoDTO.getFileNote(), dbPath);
|
||||||
return ElectromagneticResultUtil.success(true);
|
return ElectromagneticResultUtil.success(true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
||||||
|
|
@ -157,17 +157,6 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
||||||
this.baseMapper.update(new EdFileInfo(), 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));
|
||||||
|
|
||||||
String prjPath;
|
|
||||||
DataOwnEnum enumByCode = DataOwnEnum.getEnumByCode(dataOwnCode);
|
|
||||||
switch (Objects.requireNonNull(enumByCode)) {
|
|
||||||
case USER_PRJ, USER_FILE ->
|
|
||||||
prjPath = commonService.getPrjRootPath1(dataOwnCode) + File.separator + UserThreadLocal.getUserId() + File.separator;
|
|
||||||
case REPO_PRJ, REPO_FILE, SYS_PRJ, SYS_FILE ->
|
|
||||||
prjPath = commonService.getPrjRootPath1(dataOwnCode) + File.separator;
|
|
||||||
default -> throw new BizException("参数错误");
|
|
||||||
}
|
|
||||||
fileSystemService.renameFile(prjPath, oldPrjName, newPrjName);
|
|
||||||
UserThreadLocal.setSuccessInfo("", prjId, "修改工层名 {} 为 {} 成功。", oldPrjName, newPrjName);
|
UserThreadLocal.setSuccessInfo("", prjId, "修改工层名 {} 为 {} 成功。", oldPrjName, newPrjName);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String info = StrFormatter.format("修改工程名异常--->{},{}", newPrjName, e.getMessage());
|
String info = StrFormatter.format("修改工程名异常--->{},{}", newPrjName, e.getMessage());
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import com.electromagnetic.industry.software.common.enums.EleDataTypeEnum;
|
||||||
import com.electromagnetic.industry.software.common.enums.FileBackupSource;
|
import com.electromagnetic.industry.software.common.enums.FileBackupSource;
|
||||||
import com.electromagnetic.industry.software.common.pojo.RespPageVO;
|
import com.electromagnetic.industry.software.common.pojo.RespPageVO;
|
||||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||||
|
import com.electromagnetic.industry.software.common.util.EleCommonUtil;
|
||||||
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
|
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
|
||||||
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
|
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
|
||||||
import com.electromagnetic.industry.software.manage.mapper.EdFileInfoMapper;
|
import com.electromagnetic.industry.software.manage.mapper.EdFileInfoMapper;
|
||||||
|
|
@ -87,12 +88,9 @@ public class FileBackLogServiceImpl extends ServiceImpl<FileBackupLogMapper, Fil
|
||||||
List<String> restoreFilePaths = new ArrayList<>();
|
List<String> restoreFilePaths = new ArrayList<>();
|
||||||
for (EdFileInfo edFileInfo : edFileInfos) {
|
for (EdFileInfo edFileInfo : edFileInfos) {
|
||||||
|
|
||||||
String destPath;
|
String destPath = EleCommonUtil.simpleTrueFalse(DataOwnEnum.isUserCode(edFileInfo.getDataOwn()),
|
||||||
if (DataOwnEnum.isUserCode(edFileInfo.getDataOwn())) {
|
commonService.getPrjRootPath1(edFileInfo.getDataOwn()) + File.separator + edFileInfo.getCreatedBy() + File.separator + edFileInfo.getId(),
|
||||||
destPath = commonService.getPrjRootPath1(edFileInfo.getDataOwn()) + File.separator + edFileInfo.getCreatedBy() + File.separator + edFileInfo.getId();
|
commonService.getPrjRootPath1(edFileInfo.getDataOwn()) + File.separator + edFileInfo.getId());
|
||||||
} else {
|
|
||||||
destPath = commonService.getPrjRootPath1(edFileInfo.getDataOwn()) + File.separator + edFileInfo.getId();
|
|
||||||
}
|
|
||||||
destPath = destPath.replace("//", "/");
|
destPath = destPath.replace("//", "/");
|
||||||
log.info("back up file path is {}", destPath);
|
log.info("back up file path is {}", destPath);
|
||||||
if (!FileUtil.exist(destPath)) {
|
if (!FileUtil.exist(destPath)) {
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,7 @@ import cn.hutool.core.date.DateTime;
|
||||||
import cn.hutool.core.date.SystemClock;
|
import cn.hutool.core.date.SystemClock;
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.hutool.core.text.StrFormatter;
|
import cn.hutool.core.text.StrFormatter;
|
||||||
import cn.hutool.core.util.RandomUtil;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
|
@ -17,13 +15,21 @@ import com.electromagnetic.industry.software.common.enums.PublishEnum;
|
||||||
import com.electromagnetic.industry.software.common.exception.BizException;
|
import com.electromagnetic.industry.software.common.exception.BizException;
|
||||||
import com.electromagnetic.industry.software.common.pojo.UserLoginInfo;
|
import com.electromagnetic.industry.software.common.pojo.UserLoginInfo;
|
||||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||||
import com.electromagnetic.industry.software.common.util.*;
|
import com.electromagnetic.industry.software.common.util.AESUtils;
|
||||||
import com.electromagnetic.industry.software.manage.mapper.*;
|
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
|
||||||
import com.electromagnetic.industry.software.manage.pojo.models.*;
|
import com.electromagnetic.industry.software.common.util.SignUtils;
|
||||||
|
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
|
||||||
|
import com.electromagnetic.industry.software.manage.mapper.RoleMapper;
|
||||||
|
import com.electromagnetic.industry.software.manage.mapper.TokenMapper;
|
||||||
|
import com.electromagnetic.industry.software.manage.mapper.UserMapper;
|
||||||
|
import com.electromagnetic.industry.software.manage.mapper.UserMappers;
|
||||||
|
import com.electromagnetic.industry.software.manage.pojo.models.Role;
|
||||||
|
import com.electromagnetic.industry.software.manage.pojo.models.Token;
|
||||||
|
import com.electromagnetic.industry.software.manage.pojo.models.User;
|
||||||
|
import com.electromagnetic.industry.software.manage.pojo.models.UserRole;
|
||||||
import com.electromagnetic.industry.software.manage.pojo.other.PublishParam;
|
import com.electromagnetic.industry.software.manage.pojo.other.PublishParam;
|
||||||
import com.electromagnetic.industry.software.manage.pojo.other.SearchKeyWords;
|
import com.electromagnetic.industry.software.manage.pojo.other.SearchKeyWords;
|
||||||
import com.electromagnetic.industry.software.manage.pojo.other.SingleUserResponse;
|
import com.electromagnetic.industry.software.manage.pojo.other.SingleUserResponse;
|
||||||
import com.electromagnetic.industry.software.manage.pojo.other.UserDeleteKeyWords;
|
|
||||||
import com.electromagnetic.industry.software.manage.pojo.req.*;
|
import com.electromagnetic.industry.software.manage.pojo.req.*;
|
||||||
import com.electromagnetic.industry.software.manage.pojo.resp.UserLoginResponse;
|
import com.electromagnetic.industry.software.manage.pojo.resp.UserLoginResponse;
|
||||||
import com.electromagnetic.industry.software.manage.pojo.resp.UserSearchResponse;
|
import com.electromagnetic.industry.software.manage.pojo.resp.UserSearchResponse;
|
||||||
|
|
@ -64,6 +70,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||||
UserLoginInfo info = UserMappers.INSTANCE.getUserLoginRequestToModel(loginRequest);
|
UserLoginInfo info = UserMappers.INSTANCE.getUserLoginRequestToModel(loginRequest);
|
||||||
String decodePwd = AESUtils.decrypt(info.getUserPwd(), UserConstants.SECRET_KEY);
|
String decodePwd = AESUtils.decrypt(info.getUserPwd(), UserConstants.SECRET_KEY);
|
||||||
User user = userMapper.selectUserByWorkNumber(info.getWorkNumber());
|
User user = userMapper.selectUserByWorkNumber(info.getWorkNumber());
|
||||||
|
if (Objects.isNull(user)) {
|
||||||
|
return ElectromagneticResultUtil.fail("500", "用户不存在/密码错误");
|
||||||
|
}
|
||||||
info.setUserId(user.getId());
|
info.setUserId(user.getId());
|
||||||
info.setUsername(user.getUserName());
|
info.setUsername(user.getUserName());
|
||||||
info.setAdminType(user.getAdminType());
|
info.setAdminType(user.getAdminType());
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ spring.mvc.async.request-timeout=3600000
|
||||||
#mysql
|
#mysql
|
||||||
spring.datasource.url=jdbc:mysql://139.196.179.195:3306/em_data_dev?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true&rewriteBatchedStatements=true
|
spring.datasource.url=jdbc:mysql://139.196.179.195:3306/em_data_dev?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true&rewriteBatchedStatements=true
|
||||||
spring.datasource.username=em_user_dev
|
spring.datasource.username=em_user_dev
|
||||||
spring.datasource.password=Szsd#2O25$dev
|
spring.datasource.password=123456
|
||||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||||
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
|
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
|
||||||
# es
|
# es
|
||||||
|
|
@ -24,6 +24,7 @@ spring.ai.vectorstore.elasticsearch.initialize-schema=true
|
||||||
spring.ai.vectorstore.elasticsearch.index-name=rag
|
spring.ai.vectorstore.elasticsearch.index-name=rag
|
||||||
spring.ai.vectorstore.elasticsearch.dimensions=768
|
spring.ai.vectorstore.elasticsearch.dimensions=768
|
||||||
spring.ai.vectorstore.elasticsearch.similarity=cosine
|
spring.ai.vectorstore.elasticsearch.similarity=cosine
|
||||||
|
allow.upload.file.types=doc, docx, txt, csv, xls, xlsx, pdf, ppt, pptx
|
||||||
# mybatis
|
# mybatis
|
||||||
mybatis-plus.mapper-locations=classpath:sqlmapper/*.xml
|
mybatis-plus.mapper-locations=classpath:sqlmapper/*.xml
|
||||||
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
|
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
|
||||||
|
|
@ -32,20 +33,21 @@ pagehelper.reasonable=false
|
||||||
# app
|
# app
|
||||||
server.port=12396
|
server.port=12396
|
||||||
winPrefix:D:/tmp
|
winPrefix:D:/tmp
|
||||||
data.ele.tmp.path=/szsd/data/ele/prj/dev/tmp
|
prjRootPath=/szsd/data/ele/prj/dev/
|
||||||
|
data.ele.tmp.path=tmp/
|
||||||
ai.store.max.docs=200
|
ai.store.max.docs=200
|
||||||
# sys path
|
# sys path
|
||||||
data.sys.prj.path=/szsd/data/ele/prj/dev/sys_project/
|
data.sys.prj.path=sys_project/
|
||||||
data.sys.upload.path=/szsd/data/ele/prj/dev/sys_upload/
|
data.sys.upload.path=sys_upload/
|
||||||
data.sys.download.path=/szsd/data/ele/prj/dev/sys_download/
|
data.sys.download.path=sys_download/
|
||||||
# user path
|
# user path
|
||||||
data.user.prj.path=/szsd/data/ele/prj/dev/user_project/
|
data.user.prj.path=user_project/
|
||||||
data.user.upload.path=/szsd/data/ele/prj/dev/user_upload/
|
data.user.upload.path=user_upload/
|
||||||
data.user.download.path=/szsd/data/ele/prj/dev/user_download/
|
data.user.download.path=user_download/
|
||||||
# repo path
|
# repo path
|
||||||
data.repo.prj.path=/szsd/data/ele/prj/dev/repo_project/
|
data.repo.prj.path=repo_project/
|
||||||
data.repo.upload.path=/szsd/data/ele/prj/dev/repo_upload/
|
data.repo.upload.path=repo_upload/
|
||||||
data.repo.download.path=/szsd/data/ele/prj/dev/repo_download/
|
data.repo.download.path=repo_download/
|
||||||
prj.folder.max.length=6
|
prj.folder.max.length=6
|
||||||
# backupFiles
|
# backupFiles
|
||||||
tmp.file.store.hour=48
|
tmp.file.store.hour=48
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,6 @@ import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否删除枚举
|
* 是否删除枚举
|
||||||
*
|
|
||||||
* @author zhangxiong.pt
|
|
||||||
* @version $Id: EffectFlagEnum.java, v 0.1 2024-08-01 18:18
|
|
||||||
*/
|
*/
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum EffectFlagEnum {
|
public enum EffectFlagEnum {
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ public enum FileBackupSource {
|
||||||
REMOVE(1, "删除文件"),
|
REMOVE(1, "删除文件"),
|
||||||
SQL(2, "sql文件");
|
SQL(2, "sql文件");
|
||||||
|
|
||||||
public int code;
|
public final int code;
|
||||||
public String desc;
|
public final String desc;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,10 @@ package com.electromagnetic.industry.software.common.enums;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum FileRepeatEnum {
|
public enum FileRepeatEnum {
|
||||||
|
|
||||||
|
|
@ -9,25 +13,22 @@ public enum FileRepeatEnum {
|
||||||
REVERSION(2, "所有冲突文件版本更新"),
|
REVERSION(2, "所有冲突文件版本更新"),
|
||||||
NEW(3, "重命名所有冲突文件, 文件后加“_1”");
|
NEW(3, "重命名所有冲突文件, 文件后加“_1”");
|
||||||
|
|
||||||
public int code;
|
public final int code;
|
||||||
public String desc;
|
public final String desc;
|
||||||
|
|
||||||
|
private static final Map<Integer, FileRepeatEnum> MAP = new HashMap<>();
|
||||||
|
static {
|
||||||
|
for (FileRepeatEnum e : FileRepeatEnum.values()) {
|
||||||
|
MAP.put(e.code, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static String getDesc(int code) {
|
public static String getDesc(int code) {
|
||||||
for (FileRepeatEnum e : FileRepeatEnum.values()) {
|
return Optional.ofNullable(MAP.get(code)).map(e -> e.desc).orElse("");
|
||||||
if (e.code == code) {
|
|
||||||
return e.desc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean contains(int code) {
|
public static boolean contains(int code) {
|
||||||
for (FileRepeatEnum e : FileRepeatEnum.values()) {
|
return MAP.containsKey(code);
|
||||||
if (e.code == code) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -133,4 +133,8 @@ public final class EleCommonUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T> T simpleTrueFalse(Boolean match, T t1, T t2) {
|
||||||
|
return match ? t1 : t2;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
package com.electromagnetic.industry.software.common.util;
|
package com.electromagnetic.industry.software.common.util;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
public class SignUtils {
|
public class SignUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -26,7 +29,7 @@ public class SignUtils {
|
||||||
}
|
}
|
||||||
return md5StrBuff.toString();
|
return md5StrBuff.toString();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
log.error(e.getMessage(), e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue