优化代码。
This commit is contained in:
parent
a6cb01bfdb
commit
34c51c775e
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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)) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue