懒羊羊
2024-01-31 e57a8990ae56f657a59c435a0613c5f7a8728003
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
package com.jcdm.generator.domain;
 
import javax.validation.constraints.NotBlank;
import com.jcdm.common.core.domain.BaseEntity;
import com.jcdm.common.utils.StringUtils;
 
/**
 * 代码生成业务字段表 gen_table_column
 * 
 * @author jc
 */
public class GenTableColumn extends BaseEntity
{
    private static final long serialVersionUID = 1L;
 
    /** 编号 */
    private Long columnId;
 
    /** 归属表编号 */
    private Long tableId;
 
    /** 列名称 */
    private String columnName;
 
    /** 列描述 */
    private String columnComment;
 
    /** 列类型 */
    private String columnType;
 
    /** JAVA类型 */
    private String javaType;
 
    /** JAVA字段名 */
    @NotBlank(message = "Java属性不能为空")
    private String javaField;
 
    /** 是否主键(1是) */
    private String isPk;
 
    /** 是否自增(1是) */
    private String isIncrement;
 
    /** 是否必填(1是) */
    private String isRequired;
 
    /** 是否为插入字段(1是) */
    private String isInsert;
 
    /** 是否编辑字段(1是) */
    private String isEdit;
 
    /** 是否列表字段(1是) */
    private String isList;
 
    /** 是否查询字段(1是) */
    private String isQuery;
 
    /** 查询方式(EQ等于、NE不等于、GT大于、LT小于、LIKE模糊、BETWEEN范围) */
    private String queryType;
 
    /** 显示类型(input文本框、textarea文本域、select下拉框、checkbox复选框、radio单选框、datetime日期控件、image图片上传控件、upload文件上传控件、editor富文本控件) */
    private String htmlType;
 
    /** 字典类型 */
    private String dictType;
 
    /** 排序 */
    private Integer sort;
 
    public void setColumnId(Long columnId)
    {
        this.columnId = columnId;
    }
 
    public Long getColumnId()
    {
        return columnId;
    }
 
    public void setTableId(Long tableId)
    {
        this.tableId = tableId;
    }
 
    public Long getTableId()
    {
        return tableId;
    }
 
    public void setColumnName(String columnName)
    {
        this.columnName = columnName;
    }
 
    public String getColumnName()
    {
        return columnName;
    }
 
    public void setColumnComment(String columnComment)
    {
        this.columnComment = columnComment;
    }
 
    public String getColumnComment()
    {
        return columnComment;
    }
 
    public void setColumnType(String columnType)
    {
        this.columnType = columnType;
    }
 
    public String getColumnType()
    {
        return columnType;
    }
 
    public void setJavaType(String javaType)
    {
        this.javaType = javaType;
    }
 
    public String getJavaType()
    {
        return javaType;
    }
 
    public void setJavaField(String javaField)
    {
        this.javaField = javaField;
    }
 
    public String getJavaField()
    {
        return javaField;
    }
 
    public String getCapJavaField()
    {
        return StringUtils.capitalize(javaField);
    }
 
    public void setIsPk(String isPk)
    {
        this.isPk = isPk;
    }
 
    public String getIsPk()
    {
        return isPk;
    }
 
    public boolean isPk()
    {
        return isPk(this.isPk);
    }
 
    public boolean isPk(String isPk)
    {
        return isPk != null && StringUtils.equals("1", isPk);
    }
 
    public String getIsIncrement()
    {
        return isIncrement;
    }
 
    public void setIsIncrement(String isIncrement)
    {
        this.isIncrement = isIncrement;
    }
 
    public boolean isIncrement()
    {
        return isIncrement(this.isIncrement);
    }
 
    public boolean isIncrement(String isIncrement)
    {
        return isIncrement != null && StringUtils.equals("1", isIncrement);
    }
 
    public void setIsRequired(String isRequired)
    {
        this.isRequired = isRequired;
    }
 
    public String getIsRequired()
    {
        return isRequired;
    }
 
    public boolean isRequired()
    {
        return isRequired(this.isRequired);
    }
 
    public boolean isRequired(String isRequired)
    {
        return isRequired != null && StringUtils.equals("1", isRequired);
    }
 
    public void setIsInsert(String isInsert)
    {
        this.isInsert = isInsert;
    }
 
    public String getIsInsert()
    {
        return isInsert;
    }
 
    public boolean isInsert()
    {
        return isInsert(this.isInsert);
    }
 
    public boolean isInsert(String isInsert)
    {
        return isInsert != null && StringUtils.equals("1", isInsert);
    }
 
    public void setIsEdit(String isEdit)
    {
        this.isEdit = isEdit;
    }
 
    public String getIsEdit()
    {
        return isEdit;
    }
 
    public boolean isEdit()
    {
        return isInsert(this.isEdit);
    }
 
    public boolean isEdit(String isEdit)
    {
        return isEdit != null && StringUtils.equals("1", isEdit);
    }
 
    public void setIsList(String isList)
    {
        this.isList = isList;
    }
 
    public String getIsList()
    {
        return isList;
    }
 
    public boolean isList()
    {
        return isList(this.isList);
    }
 
    public boolean isList(String isList)
    {
        return isList != null && StringUtils.equals("1", isList);
    }
 
    public void setIsQuery(String isQuery)
    {
        this.isQuery = isQuery;
    }
 
    public String getIsQuery()
    {
        return isQuery;
    }
 
    public boolean isQuery()
    {
        return isQuery(this.isQuery);
    }
 
    public boolean isQuery(String isQuery)
    {
        return isQuery != null && StringUtils.equals("1", isQuery);
    }
 
    public void setQueryType(String queryType)
    {
        this.queryType = queryType;
    }
 
    public String getQueryType()
    {
        return queryType;
    }
 
    public String getHtmlType()
    {
        return htmlType;
    }
 
    public void setHtmlType(String htmlType)
    {
        this.htmlType = htmlType;
    }
 
    public void setDictType(String dictType)
    {
        this.dictType = dictType;
    }
 
    public String getDictType()
    {
        return dictType;
    }
 
    public void setSort(Integer sort)
    {
        this.sort = sort;
    }
 
    public Integer getSort()
    {
        return sort;
    }
 
    public boolean isSuperColumn()
    {
        return isSuperColumn(this.javaField);
    }
 
    public static boolean isSuperColumn(String javaField)
    {
        return StringUtils.equalsAnyIgnoreCase(javaField,
                // BaseEntity
                "createBy", "createTime", "updateBy", "updateTime", "remark",
                // TreeEntity
                "parentName", "parentId", "orderNum", "ancestors");
    }
 
    public boolean isUsableColumn()
    {
        return isUsableColumn(javaField);
    }
 
    public static boolean isUsableColumn(String javaField)
    {
        // isSuperColumn()中的名单用于避免生成多余Domain属性,若某些属性在生成页面时需要用到不能忽略,则放在此处白名单
        return StringUtils.equalsAnyIgnoreCase(javaField, "parentId", "orderNum", "remark");
    }
 
    public String readConverterExp()
    {
        String remarks = StringUtils.substringBetween(this.columnComment, "(", ")");
        StringBuffer sb = new StringBuffer();
        if (StringUtils.isNotEmpty(remarks))
        {
            for (String value : remarks.split(" "))
            {
                if (StringUtils.isNotEmpty(value))
                {
                    Object startStr = value.subSequence(0, 1);
                    String endStr = value.substring(1);
                    sb.append("").append(startStr).append("=").append(endStr).append(",");
                }
            }
            return sb.deleteCharAt(sb.length() - 1).toString();
        }
        else
        {
            return this.columnComment;
        }
    }
}