优化代码
This commit is contained in:
parent
284dea6a98
commit
2d43880a51
|
|
@ -690,8 +690,7 @@ public class CommonService {
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
||||
|
|
@ -12,22 +16,19 @@ public enum FileRepeatEnum {
|
|||
public int code;
|
||||
public String desc;
|
||||
|
||||
public static String getDesc(int code) {
|
||||
private static final Map<Integer, FileRepeatEnum> MAP = new HashMap<>();
|
||||
static {
|
||||
for (FileRepeatEnum e : FileRepeatEnum.values()) {
|
||||
if (e.code == code) {
|
||||
return e.desc;
|
||||
}
|
||||
MAP.put(e.code, e);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String getDesc(int code) {
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue