ludc
2024-08-16 56de7a42d2567ce72885be8ebb1d1250d68ddd1b
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
package com.vci.web.properties;
 
import com.alibaba.fastjson.JSON;
import com.vci.pagemodel.MenuVO;
import org.apache.commons.io.FileUtils;
import org.springframework.util.ResourceUtils;
 
import java.io.*;
 
/**
 * 读取json配置文件,菜单等
 * @author ludc
 * @date 2024/8/16 10:09
 */
public class JsonConfigReader {
 
    /**
     * 菜单json配置文件,如有其他需要读取的,可以仿照当前逻辑编写
     */
    private static MenuVO menuVO;
 
    static{
        try {
            File file = ResourceUtils.getFile("classpath:menuConfig.json");
            String json = FileUtils.readFileToString(file, "UTF-8");
            menuVO = JSON.parseObject(json, MenuVO.class);
        }catch (IOException e) {
            e.printStackTrace();
        }
    }
 
    public static MenuVO getMenuVO() {
        return menuVO;
    }
 
}