This commit is contained in:
s2042968 2025-04-22 16:35:59 +08:00
commit 997bef0b3b
18 changed files with 97 additions and 104 deletions

View File

@ -6,6 +6,8 @@ import lombok.Getter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
public class ElePropertyConfig {
@ -73,6 +75,13 @@ public class ElePropertyConfig {
@Value("${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() {
if (EleCommonUtil.isWinOs()) {
return winPrefix + prjRootPath + eleTmpPath;

View File

@ -27,7 +27,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import java.util.Date;
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
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {

View File

@ -2,9 +2,7 @@ package com.electromagnetic.industry.software.manage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
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.UserDeleteKeyWords;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;

View File

@ -13,13 +13,13 @@ import java.util.Date;
@TableName("ed_users")
@Data
public class User extends BaseModel{
public class User extends BaseModel {
/**
* 主键ID
*/
private String id;
/**
* 用户姓名
*/
@ -89,7 +89,7 @@ public class User extends BaseModel{
*
*/
private String salt;
public void newInit() {
String id = IdWorker.getSnowFlakeIdString();
String userId = UserThreadLocal.getUserId();

View File

@ -11,7 +11,7 @@ import java.util.Date;
@Data
@TableName("ed_user_role")
public class UserRole extends BaseModel{
public class UserRole extends BaseModel {
/**
* 主键ID

View File

@ -1,7 +1,5 @@
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.JsonProperty;
import lombok.Data;

View File

@ -3,7 +3,6 @@ package com.electromagnetic.industry.software.manage.service.serviceimpl;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.text.StrFormatter;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.digest.DigestUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@ -50,7 +49,6 @@ import java.util.*;
@Service
public class ChatService {
private static final List<String> ALLOWS_FILE_TYPES = List.of("doc", "docx", "txt", "csv", "xls", "xlsx", "pdf", "ppt", "pptx");
@Resource
private VectorStore vectorStore;
@Resource
@ -73,7 +71,7 @@ public class ChatService {
.map(AiFileUploadRecord::getVectorId)
.toList();
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)
.in(AiFileUploadRecord::getId, ids)
.set(AiFileUploadRecord::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code));
@ -91,7 +89,7 @@ public class ChatService {
}
String fileType = FileUtil.extName(file.getOriginalFilename());
if (!ALLOWS_FILE_TYPES.contains(fileType)) {
if (!elePropertyConfig.getAiAllowUploadFileTypes().contains(fileType)) {
return ElectromagneticResultUtil.fail("-1", StrFormatter.format("当前格式 {} 不支持", fileType));
}

View File

@ -198,12 +198,9 @@ public class CommonService {
StringBuilder path = new StringBuilder();
for (String id : ids) {
EdFileInfo fileInfo = map.get(id);
String tmp;
if (fileInfo.getDataType().equals(EleDataTypeEnum.FILE.code)) {
tmp = fileInfo.getFileName() + "." + fileInfo.getFileType();
} else {
tmp = fileInfo.getFileName() + File.separator;
}
String tmp = EleCommonUtil.simpleTrueFalse(Objects.equals(fileInfo.getDataType(), EleDataTypeEnum.FILE.code),
fileInfo.getFileName() + "." + fileInfo.getFileType(),
fileInfo.getFileName() + File.separator);
path.append(tmp);
}
return path.toString();
@ -254,9 +251,8 @@ public class CommonService {
.eq(EdFileInfo::getId, parentId);
EdFileInfo edFileInfo = edFileInfoMapper.selectOne(queryWrapper);
String currentPath = edFileInfo.getFilePath();
List<String> paths = CollUtil.newArrayList(edFileInfo.getFilePath().split(MYSQL_FILE_PATH_SPLIT));
if (maxLengthCheck) {
if (paths.size() >= elePropertyConfig.getPrjFolderMaxLength()) {
if (StrUtil.count(currentPath, MYSQL_FILE_PATH_SPLIT) >= elePropertyConfig.getPrjFolderMaxLength() - 1) {
String info = StrFormatter.format("当前子集已达到最大层级,禁止创建子集,{} 创建失败。", folderName);
log.error(info);
return ElectromagneticResultUtil.fail("-1", info);
@ -300,19 +296,12 @@ public class CommonService {
}
/**
* 1.询管理员从层级定义处查2.用户从数据库管理界面查询
*
* @param querySource 0询管理员从层级定义处查 2.用户从数据库管理界面查询
* @param querySource 管理员从层级定义处查询用户从数据库管理界面查询
* @param accessibleIds
* @param returnType
* @return
*/
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<>();
try {
// 首先查出所有的工程id
@ -594,13 +583,13 @@ public class CommonService {
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 mainName = FileUtil.mainName(fileName);
String suffix = FileUtil.getSuffix(fileName);
Assert.isTrue(StrUtil.isNotEmpty(suffix), "文件类型不能为空");
String destPath = getDbPathById(parentId);
String strategyStr = FileRepeatEnum.getDesc(strategy);
String strategyStr = getDesc(strategy);
Assert.isTrue(!file.isEmpty(), StrFormatter.format("文件 {} 为空,文件上传到 {} 失败,同名同后缀的处理方式为 {}", fileName, 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);
EdFileInfo newEdFileInfo = new EdFileInfo();
newEdFileInfo.newInit();
EdFileInfo finalEdFileInfo;
EdFileInfo finalEdFileInfo = null;
// 首先检查是否是同名文件
try {
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());
newEdFileInfo.setParentId(parentId)
.setFileCode(fileCode)
.setSaveStatus(EleDataSaveStatusEnum.SUCCESS.code)
.setSaveStatus(EleDataSaveStatusEnum.UPLOADING.code)
.setDataOwn(dataOwnCode)
.setFileName(mainName)
.setFileContent(EleCommonUtil.parse(file.getInputStream(), suffix))
@ -656,10 +645,16 @@ public class CommonService {
FileUtil.writeFromStream(file.getInputStream(), fileDestPath);
EleCommonUtil.encryptFile(fileDestPath, SecureUtil.aes(FILE_SEC_PASSWD.getBytes()));
finalEdFileInfo = newEdFileInfo;
newEdFileInfo.setSaveStatus(EleDataSaveStatusEnum.SUCCESS.code);
edFileInfoMapper.insertOrUpdate(newEdFileInfo);
}
} catch (Exception e) {
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)
.setSaveStatus(EleDataSaveStatusEnum.FAIL.code)
.setFileType(suffix)
@ -670,22 +665,21 @@ public class CommonService {
.setDataType(EleDataTypeEnum.FILE.code)
.setDataStatus(PublishEnum.PUBLISHED.getCode())
.setEffectFlag(EffectFlagEnum.NOT_EFFECTIVE.code);
edFileInfoMapper.insertOrUpdate(newEdFileInfo);
edFileInfoMapper.insertOrUpdate(finalEdFileInfo);
log.error(info, e);
throw new BizException(info);
}
UserThreadLocal.setSuccessInfo(Optional.ofNullable(finalEdFileInfo).map(EdFileInfo::getParentId).orElse(""),
UserThreadLocal.setSuccessInfo(parentId,
Optional.ofNullable(finalEdFileInfo).map(EdFileInfo::getId).orElse(""),
"文件 {} 为上传到 {} 成功,同名同后缀的处理方式为 {},存入的文件名为 {}",
fileName,
destPath,
strategyStr,
Optional.ofNullable(finalEdFileInfo).map(EdFileInfo::getFileName).orElse(fileName) + "." + Optional.ofNullable(finalEdFileInfo).map(EdFileInfo::getFileType).orElse(suffix));
return ElectromagneticResultUtil.success(newEdFileInfo.getId());
fileName + "." + suffix);
return ElectromagneticResultUtil.success(Optional.ofNullable(finalEdFileInfo).map(EdFileInfo::getId).orElse(""));
}
@Transactional(rollbackFor = Exception.class)
public EdFileInfo handUploadRepeatFile(String parentId, MultipartFile file, Integer strategy, int dataOwnCode) throws IOException {
private EdFileInfo handUploadRepeatFile(String parentId, MultipartFile file, Integer strategy, int dataOwnCode) throws IOException {
String fileName = file.getOriginalFilename();
String mainName = FileUtil.mainName(fileName);
String suffix = FileUtil.getSuffix(fileName);
@ -699,7 +693,7 @@ public class CommonService {
.setFileSize(file.getSize())
.setDataType(EleDataTypeEnum.FILE.code)
.setDataStatus(PublishEnum.PUBLISHED.getCode())
.setSaveStatus(EleDataSaveStatusEnum.SUCCESS.code)
.setSaveStatus(EleDataSaveStatusEnum.UPLOADING.code)
.setDataOwn(dataOwnCode)
.setEffectFlag(EffectFlagEnum.EFFECT.code);
if (strategy == REVERSION.code) {
@ -752,6 +746,8 @@ public class CommonService {
String fileDestPath = getFileSysPath(newEdFileInfo.getId());
fileSystemService.save(file.getInputStream(), fileDestPath);
EleCommonUtil.encryptFile(fileDestPath, SecureUtil.aes(FILE_SEC_PASSWD.getBytes()));
newEdFileInfo.setSaveStatus(EleDataSaveStatusEnum.SUCCESS.code);
edFileInfoMapper.insertOrUpdate(newEdFileInfo);
return newEdFileInfo;
}

View File

@ -340,14 +340,11 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
throw new BizException("文件名已经存在");
}
String srcFilePath = commonService.getFileSysPath(fileInfo.getId());
String dbPath = commonService.getDbPath(fileInfo.getFilePath());
this.baseMapper.update(new EdFileInfo(), Wrappers.lambdaUpdate(EdFileInfo.class)
.eq(EdFileInfo::getId, updateFileInfoDTO.getId())
.set(EdFileInfo::getFileName, updateFileInfoDTO.getFileName())
.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);
return ElectromagneticResultUtil.success(true);
} catch (Exception e) {

View File

@ -157,17 +157,6 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
this.baseMapper.update(new EdFileInfo(), Wrappers.lambdaUpdate(EdFileInfo.class)
.eq(EdFileInfo::getId, prjId)
.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);
} catch (Exception e) {
String info = StrFormatter.format("修改工程名异常--->{}{}", newPrjName, e.getMessage());

View File

@ -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.pojo.RespPageVO;
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.UserThreadLocal;
import com.electromagnetic.industry.software.manage.mapper.EdFileInfoMapper;
@ -87,12 +88,9 @@ public class FileBackLogServiceImpl extends ServiceImpl<FileBackupLogMapper, Fil
List<String> restoreFilePaths = new ArrayList<>();
for (EdFileInfo edFileInfo : edFileInfos) {
String destPath;
if (DataOwnEnum.isUserCode(edFileInfo.getDataOwn())) {
destPath = commonService.getPrjRootPath1(edFileInfo.getDataOwn()) + File.separator + edFileInfo.getCreatedBy() + File.separator + edFileInfo.getId();
} else {
destPath = commonService.getPrjRootPath1(edFileInfo.getDataOwn()) + File.separator + edFileInfo.getId();
}
String destPath = EleCommonUtil.simpleTrueFalse(DataOwnEnum.isUserCode(edFileInfo.getDataOwn()),
commonService.getPrjRootPath1(edFileInfo.getDataOwn()) + File.separator + edFileInfo.getCreatedBy() + File.separator + edFileInfo.getId(),
commonService.getPrjRootPath1(edFileInfo.getDataOwn()) + File.separator + edFileInfo.getId());
destPath = destPath.replace("//", "/");
log.info("back up file path is {}", destPath);
if (!FileUtil.exist(destPath)) {

View File

@ -4,9 +4,7 @@ import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.SystemClock;
import cn.hutool.core.lang.Assert;
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.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
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.pojo.UserLoginInfo;
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
import com.electromagnetic.industry.software.common.util.*;
import com.electromagnetic.industry.software.manage.mapper.*;
import com.electromagnetic.industry.software.manage.pojo.models.*;
import com.electromagnetic.industry.software.common.util.AESUtils;
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
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.SearchKeyWords;
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.resp.UserLoginResponse;
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);
String decodePwd = AESUtils.decrypt(info.getUserPwd(), UserConstants.SECRET_KEY);
User user = userMapper.selectUserByWorkNumber(info.getWorkNumber());
if (Objects.isNull(user)) {
return ElectromagneticResultUtil.fail("500", "用户不存在/密码错误");
}
info.setUserId(user.getId());
info.setUsername(user.getUserName());
info.setAdminType(user.getAdminType());

View File

@ -7,7 +7,7 @@ spring.mvc.async.request-timeout=3600000
#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.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.type=com.alibaba.druid.pool.DruidDataSource
# es
@ -24,6 +24,7 @@ spring.ai.vectorstore.elasticsearch.initialize-schema=true
spring.ai.vectorstore.elasticsearch.index-name=rag
spring.ai.vectorstore.elasticsearch.dimensions=768
spring.ai.vectorstore.elasticsearch.similarity=cosine
allow.upload.file.types=doc, docx, txt, csv, xls, xlsx, pdf, ppt, pptx
# mybatis
mybatis-plus.mapper-locations=classpath:sqlmapper/*.xml
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
@ -32,20 +33,21 @@ pagehelper.reasonable=false
# app
server.port=12396
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
# sys path
data.sys.prj.path=/szsd/data/ele/prj/dev/sys_project/
data.sys.upload.path=/szsd/data/ele/prj/dev/sys_upload/
data.sys.download.path=/szsd/data/ele/prj/dev/sys_download/
data.sys.prj.path=sys_project/
data.sys.upload.path=sys_upload/
data.sys.download.path=sys_download/
# user path
data.user.prj.path=/szsd/data/ele/prj/dev/user_project/
data.user.upload.path=/szsd/data/ele/prj/dev/user_upload/
data.user.download.path=/szsd/data/ele/prj/dev/user_download/
data.user.prj.path=user_project/
data.user.upload.path=user_upload/
data.user.download.path=user_download/
# repo path
data.repo.prj.path=/szsd/data/ele/prj/dev/repo_project/
data.repo.upload.path=/szsd/data/ele/prj/dev/repo_upload/
data.repo.download.path=/szsd/data/ele/prj/dev/repo_download/
data.repo.prj.path=repo_project/
data.repo.upload.path=repo_upload/
data.repo.download.path=repo_download/
prj.folder.max.length=6
# backupFiles
tmp.file.store.hour=48

View File

@ -4,9 +4,6 @@ import lombok.AllArgsConstructor;
/**
* 是否删除枚举
*
* @author zhangxiong.pt
* @version $Id: EffectFlagEnum.java, v 0.1 2024-08-01 18:18
*/
@AllArgsConstructor
public enum EffectFlagEnum {

View File

@ -9,7 +9,7 @@ public enum FileBackupSource {
REMOVE(1, "删除文件"),
SQL(2, "sql文件");
public int code;
public String desc;
public final int code;
public final String desc;
}

View File

@ -2,6 +2,10 @@ package com.electromagnetic.industry.software.common.enums;
import lombok.AllArgsConstructor;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
@AllArgsConstructor
public enum FileRepeatEnum {
@ -9,25 +13,22 @@ public enum FileRepeatEnum {
REVERSION(2, "所有冲突文件版本更新"),
NEW(3, "重命名所有冲突文件, 文件后加“_1”");
public int code;
public String desc;
public final int code;
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) {
for (FileRepeatEnum e : FileRepeatEnum.values()) {
if (e.code == code) {
return e.desc;
}
}
return "";
return Optional.ofNullable(MAP.get(code)).map(e -> e.desc).orElse("");
}
public static boolean contains(int code) {
for (FileRepeatEnum e : FileRepeatEnum.values()) {
if (e.code == code) {
return true;
}
}
return false;
return MAP.containsKey(code);
}
}
}

View File

@ -133,4 +133,8 @@ public final class EleCommonUtil {
}
}
public static <T> T simpleTrueFalse(Boolean match, T t1, T t2) {
return match ? t1 : t2;
}
}

View File

@ -1,7 +1,10 @@
package com.electromagnetic.industry.software.common.util;
import lombok.extern.slf4j.Slf4j;
import java.security.MessageDigest;
@Slf4j
public class SignUtils {
/**
@ -26,7 +29,7 @@ public class SignUtils {
}
return md5StrBuff.toString();
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage(), e);
return null;
}
}