chenjiahe
5 天以前 826b66207dafbce24f441cb83fed1b241a6fba27
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
package com.hx.auto.common;
 
import java.util.ArrayList;
import java.util.List;
 
/**实体类对应生成mapper.xml的数据*/
public class ReadEntityData {
    //实体类的主键id名称
    private String entityIdName;
    //表的主键id名称
    private String tableIdName;
    //主键类型
    private String keyType;
    //表的名称
    private String tableName;
    //实体类和表的所有字段名称(除了主键)
    private List<FieldAttribute> fields = new ArrayList<FieldAttribute>();
    //特殊字段,主键id,如:#{id}
    private String entityIdData;
    //特殊字段,mybatis的排序
    private String orderBy = "${orderBy}";
    //特殊字段,mybatis的实体类匹配表字段
    private String createData = "#{createData.obj}";
    //特殊字段,mybatis的传的值
    private String valueData = "#{value}";
    
    /********************************************************************/
    /** 存储实体类的表字段
     * @param entityName 实体类字段名称
     * @param tableName1 表名称
     * @param dataType 类型
     */
    public void fielData(String entityName,String tableName1,String dataType,Integer isBlob,String mybatisName) {
        fields.add(new FieldAttribute(entityName,tableName1, dataType,isBlob,mybatisName));
    }
    
    /******************************************************************/
    public String getEntityIdName() {
        return entityIdName;
    }
    public void setEntityIdName(String entityIdName) {
        this.entityIdName = entityIdName;
    }
    public String getTableIdName() {
        return tableIdName;
    }
    public void setTableIdName(String tableIdName) {
        this.tableIdName = tableIdName;
    }
    public String getTableName() {
        return tableName;
    }
    public void setTableName(String tableName) {
        this.tableName = tableName;
    }
    public List<FieldAttribute> getFields() {
        return fields;
    }
    public void setFields(List<FieldAttribute> fields) {
        this.fields = fields;
    }
    public String getOrderBy() {
        return orderBy;
    }
    public void setOrderBy(String orderBy) {
        this.orderBy = orderBy;
    }
    public String getKeyType() {
        return keyType;
    }
    public void setKeyType(String keyType) {
        this.keyType = keyType;
    }
 
    public String getCreateData() {
        return createData;
    }
    public void setCreateData(String createData) {
        this.createData = createData;
    }
    public String getValueData() {
        return valueData;
    }
 
    public void setValueData(String valueData) {
        this.valueData = valueData;
    }
 
    public String getEntityIdData() {
        return entityIdData;
    }
 
    public void setEntityIdData(String entityIdData) {
        this.entityIdData = entityIdData;
    }
 
    /*****************************************************************/
    public static class FieldAttribute {
        //实体类字段名称
        private String entityName;
        //表字段名称
        private String tableName;
        //数据库类型
        private String dataType;
        //是否大数据
        private Integer isBlob = 0;
        //特殊字段,如在mybati中 #{id}的表示
        private String mybatisName;
        
        /**********************************/
        public FieldAttribute(String entityName,String tableName,String dataType,Integer isBlob
                ,String mybatisName) {
            this.entityName = entityName;
            this.tableName = tableName;
            this.dataType = dataType;
            this.isBlob = isBlob;
            this.mybatisName = mybatisName;
        }
        
        /*********************************/
        public String getDataType() {
            return dataType;
        }
        public void setDataType(String dataType) {
            this.dataType = dataType;
        }
        public String getEntityName() {
            return entityName;
        }
        public void setEntityName(String entityName) {
            this.entityName = entityName;
        }
        public String getTableName() {
            return tableName;
        }
        public void setTableName(String tableName) {
            this.tableName = tableName;
        }
        public Integer getIsBlob() {
            return isBlob;
        }
        public void setIsBlob(Integer isBlob) {
            this.isBlob = isBlob;
        }
 
        public String getMybatisName() {
            return mybatisName;
        }
        public void setMybatisName(String mybatisName) {
            this.mybatisName = mybatisName;
        }
    }
}