刘光辉
14 小时以前 34981c30a78e8bbd7791131059a9210f9928b62c
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package jnpf.base.model.language;
 
import jnpf.model.ExcelColumnAttr;
import lombok.Getter;
import org.apache.poi.ss.usermodel.IndexedColors;
 
import java.util.*;
 
/**
 * 多语言导入模型
 *
 * @author JNPF开发平台组
 * @version v5.0.0
 * @copyright 引迈信息技术有限公司
 * @date 2024/6/25 15:31:23
 */
public class BaseLangColumn {
 
    /**
     * -- GETTER --
     *  表格名称
     *
     * @return
     */
    @Getter
    String excelName = "翻译管理";
 
    private static final Map<String, String> KEY_MAP = new HashMap<>();
 
    static {
        KEY_MAP.put("enCode", "翻译标记");
        KEY_MAP.put("type", "翻译分类");
    }
 
    public BaseLangColumn(Map<String, String> keyMap) {
        KEY_MAP.putAll(keyMap);
    }
 
    /**
     * 根据类型获取excel表头字段
     *
 
     * @return
     */
    public Map<String, String> getColumnByType() {
        return KEY_MAP;
    }
 
    /**
     * 获取字段列表
     *
     * @param isError
     * @return
     */
    public List<ExcelColumnAttr> getFieldsModel(boolean isError) {
        List<ExcelColumnAttr> models = new ArrayList<>();
        //异常原因
        if (isError) {
            ExcelColumnAttr attr = ExcelColumnAttr.builder().key("errorsInfo").name("异常原因").build();
            models.add(attr);
        }
        List<String> requireFields = Collections.singletonList("enCode");
        for (Map.Entry<String, String> entry : KEY_MAP.entrySet()) {
            String key = entry.getKey();
            ExcelColumnAttr attr = ExcelColumnAttr.builder().key(key).name(KEY_MAP.get(key)).build();
            if (requireFields.contains(key)) {
                attr.setRequire(true);
                attr.setFontColor(IndexedColors.RED.getIndex());
            }
            models.add(attr);
        }
        return models;
    }
 
    /**
     * 获取默认值
     */
    public List<Map<String, Object>> getDefaultList() {
        List<Map<String, Object>> list = new ArrayList<>();
        Map<String, Object> map = new HashMap<>();
 
        list.add(map);
        return list;
    }
}