懒羊羊
2023-08-30 1ac2bc1590406d9babec036e154d8d08f34a6aa1
提交 | 用户 | 时间
1ac2bc 1 package cn.stylefeng.guns.gen.core.util;
2
3 import com.baomidou.mybatisplus.generator.config.po.TableField;
4
5 import java.util.ArrayList;
6 import java.util.HashMap;
7 import java.util.List;
8 import java.util.Map;
9
10 /**
11  * 字段转化工具类
12  *
13  * @author fengshuonan
14  * @Date 2019/5/7 22:12
15  */
16 public class FieldUtil {
17
18     /**
19      * 将下划线字段数组,转化成驼峰式的字段数组
20      *
21      * @param underlineFields 下划线的字段数组
22      * @param tableFields     带有驼峰式的字段数组
23      * @author fengshuonan
24      * @Date 2019/5/7 22:14
25      */
26     public static List<Map<String, Object>> getCamelFieldsUnderLine(String[] underlineFields, List<TableField> tableFields) {
27
28         ArrayList<Map<String, Object>> newFields = new ArrayList<>();
29
30         if (underlineFields.length <= 0 || tableFields == null) {
31             return newFields;
32         } else {
33             for (String underlineField : underlineFields) {
34                 for (TableField tableField : tableFields) {
35                     if (underlineField.equals(tableField.getName())) {
36
37                         HashMap<String, Object> field = new HashMap<>();
38                         field.put("fieldUnderline", underlineField);
39                         field.put("fieldCamel", tableField.getPropertyName());
40                         newFields.add(field);
41
42                     }
43                 }
44             }
45             return newFields;
46         }
47     }
48
49 }