zhuguifei
2025-04-28 442928123f63ee497d766f9a7a14f0a6ee067e25
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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;
    }
 
}