package org.jeecg.modules.doc.component;
|
|
import cn.hutool.core.util.IdUtil;
|
import org.jeecg.common.util.DateUtils;
|
import org.jeecg.modules.doc.constant.Constant;
|
import org.jeecg.modules.doc.entity.DocFilePath;
|
import org.jeecg.modules.doc.vo.QiwenFile;
|
|
public class PathFileUtil {
|
|
public static DocFilePath getDir(String filePath, String fileName, DocFilePath parent) {
|
DocFilePath docFilePath = new DocFilePath();
|
docFilePath.setPathId(IdUtil.getSnowflakeNextIdStr());
|
docFilePath.setFileId(null);
|
docFilePath.setFileName(fileName);
|
docFilePath.setFilePath(QiwenFile.formatPath(filePath));
|
docFilePath.setExtendName(null);
|
docFilePath.setIsDir(Constant.IS_DIR);
|
docFilePath.setUpdateTime(DateUtils.getDate());
|
docFilePath.setDeleteFlag(Constant.DEL_FALSE);
|
docFilePath.setDeleteBatchNum(null);
|
docFilePath.setPathStatus(1);
|
if (parent != null) {
|
docFilePath.setParentId(parent.getPathId());
|
}
|
|
return docFilePath;
|
}
|
|
public static DocFilePath getFile(long userId, String fileId, String filePath, String fileName, String extendName) {
|
DocFilePath docFilePath = new DocFilePath();
|
docFilePath.setPathId(IdUtil.getSnowflakeNextIdStr());
|
docFilePath.setFileId(fileId);
|
docFilePath.setFileName(fileName);
|
docFilePath.setFilePath(QiwenFile.formatPath(filePath));
|
docFilePath.setExtendName(extendName);
|
docFilePath.setIsDir(Constant.IS_NOT_DIR);
|
docFilePath.setUpdateTime(DateUtils.getDate());
|
docFilePath.setDeleteFlag(Constant.DEL_FALSE);
|
docFilePath.setDeleteBatchNum(null);
|
docFilePath.setPathStatus(1);
|
return docFilePath;
|
}
|
|
public static DocFilePath searchParam(DocFilePath docFilePath) {
|
DocFilePath param = new DocFilePath();
|
param.setFilePath(QiwenFile.formatPath(docFilePath.getFilePath()));
|
param.setFileName(docFilePath.getFileName());
|
param.setExtendName(docFilePath.getExtendName());
|
param.setDeleteFlag(Constant.DEL_FALSE);
|
param.setIsDir(Constant.IS_NOT_DIR);
|
return param;
|
}
|
|
public static String formatLikePath(String filePath) {
|
String newFilePath = filePath.replace("'", "\\'");
|
newFilePath = newFilePath.replace("%", "\\%");
|
newFilePath = newFilePath.replace("_", "\\_");
|
return newFilePath;
|
}
|
|
}
|