严智鑫
2025-11-13 945bc394f40d8af1072a53da9a94f24207124e6d
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
package com.northglass.util;
 
import java.io.File;
 
import javax.servlet.http.HttpServletRequest;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
@Component
public class FolderUtil {
 
    public static String WEB_ROOT_PATH;
    public static String TEMP_PATH;
    public static String PATH;
    
    public FolderUtil(HttpServletRequest request) {
        if (WEB_ROOT_PATH == null || WEB_ROOT_PATH.equals("")) {
            WEB_ROOT_PATH = request.getSession().getServletContext().getRealPath("/");
            System.out.println("WEB_ROOT_PATH: " + WEB_ROOT_PATH);
            
            TEMP_PATH = WEB_ROOT_PATH + File.separator + "static" + File.separator + "temp";
            System.out.println("TEMP_PATH: " + TEMP_PATH);
            
            File tempDir = new File(TEMP_PATH);
            if (!tempDir.exists()) {
                tempDir.mkdirs();
            }
        }
        
    }
    public FolderUtil() {
        // TODO Auto-generated constructor stub
    }
//    public void downOpt(HttpServletRequest request,Long loadmachineid){
//        if (WEB_ROOT_PATH == null || WEB_ROOT_PATH.equals("")) {
//            LoadMachine loadmachine = new CutManageService().getLoadmachine(loadmachineid);
//            PATH = loadmachine.getPath();
//            File tempDir = new File(PATH);
//            
//            
//            if (!tempDir.exists()) {
//                tempDir.mkdirs();
//            }
//        }
//    }
    
}