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