提交 | 用户 | 时间
|
722af2
|
1 |
package com.dl.generator.domain; |
X |
2 |
|
|
3 |
import com.baomidou.mybatisplus.annotation.FieldStrategy; |
|
4 |
import com.baomidou.mybatisplus.annotation.TableField; |
|
5 |
import com.baomidou.mybatisplus.annotation.TableId; |
|
6 |
import com.baomidou.mybatisplus.annotation.TableName; |
|
7 |
import com.dl.common.core.domain.BaseEntity; |
|
8 |
import com.dl.common.utils.StringUtils; |
|
9 |
import lombok.Data; |
|
10 |
import lombok.EqualsAndHashCode; |
|
11 |
import org.apache.ibatis.type.JdbcType; |
|
12 |
|
|
13 |
import javax.validation.constraints.NotBlank; |
|
14 |
|
|
15 |
/** |
|
16 |
* 代码生成业务字段表 gen_table_column |
|
17 |
* |
|
18 |
* @author Lion Li |
|
19 |
*/ |
|
20 |
|
|
21 |
@Data |
|
22 |
@EqualsAndHashCode(callSuper = true) |
|
23 |
@TableName("gen_table_column") |
|
24 |
public class GenTableColumn extends BaseEntity { |
|
25 |
|
|
26 |
/** |
|
27 |
* 编号 |
|
28 |
*/ |
|
29 |
@TableId(value = "column_id") |
|
30 |
private Long columnId; |
|
31 |
|
|
32 |
/** |
|
33 |
* 归属表编号 |
|
34 |
*/ |
|
35 |
private Long tableId; |
|
36 |
|
|
37 |
/** |
|
38 |
* 列名称 |
|
39 |
*/ |
|
40 |
private String columnName; |
|
41 |
|
|
42 |
/** |
|
43 |
* 列描述 |
|
44 |
*/ |
|
45 |
@TableField(updateStrategy = FieldStrategy.IGNORED, jdbcType = JdbcType.VARCHAR) |
|
46 |
private String columnComment; |
|
47 |
|
|
48 |
/** |
|
49 |
* 列类型 |
|
50 |
*/ |
|
51 |
private String columnType; |
|
52 |
|
|
53 |
/** |
|
54 |
* JAVA类型 |
|
55 |
*/ |
|
56 |
private String javaType; |
|
57 |
|
|
58 |
/** |
|
59 |
* JAVA字段名 |
|
60 |
*/ |
|
61 |
@NotBlank(message = "Java属性不能为空") |
|
62 |
private String javaField; |
|
63 |
|
|
64 |
/** |
|
65 |
* 是否主键(1是) |
|
66 |
*/ |
|
67 |
@TableField(updateStrategy = FieldStrategy.IGNORED, jdbcType = JdbcType.VARCHAR) |
|
68 |
private String isPk; |
|
69 |
|
|
70 |
/** |
|
71 |
* 是否自增(1是) |
|
72 |
*/ |
|
73 |
@TableField(updateStrategy = FieldStrategy.IGNORED, jdbcType = JdbcType.VARCHAR) |
|
74 |
private String isIncrement; |
|
75 |
|
|
76 |
/** |
|
77 |
* 是否必填(1是) |
|
78 |
*/ |
|
79 |
@TableField(updateStrategy = FieldStrategy.IGNORED, jdbcType = JdbcType.VARCHAR) |
|
80 |
private String isRequired; |
|
81 |
|
|
82 |
/** |
|
83 |
* 是否为插入字段(1是) |
|
84 |
*/ |
|
85 |
@TableField(updateStrategy = FieldStrategy.IGNORED, jdbcType = JdbcType.VARCHAR) |
|
86 |
private String isInsert; |
|
87 |
|
|
88 |
/** |
|
89 |
* 是否编辑字段(1是) |
|
90 |
*/ |
|
91 |
@TableField(updateStrategy = FieldStrategy.IGNORED, jdbcType = JdbcType.VARCHAR) |
|
92 |
private String isEdit; |
|
93 |
|
|
94 |
/** |
|
95 |
* 是否列表字段(1是) |
|
96 |
*/ |
|
97 |
@TableField(updateStrategy = FieldStrategy.IGNORED, jdbcType = JdbcType.VARCHAR) |
|
98 |
private String isList; |
|
99 |
|
|
100 |
/** |
|
101 |
* 是否查询字段(1是) |
|
102 |
*/ |
|
103 |
@TableField(updateStrategy = FieldStrategy.IGNORED, jdbcType = JdbcType.VARCHAR) |
|
104 |
private String isQuery; |
|
105 |
|
|
106 |
/** |
|
107 |
* 查询方式(EQ等于、NE不等于、GT大于、LT小于、LIKE模糊、BETWEEN范围) |
|
108 |
*/ |
|
109 |
private String queryType; |
|
110 |
|
|
111 |
/** |
|
112 |
* 显示类型(input文本框、textarea文本域、select下拉框、checkbox复选框、radio单选框、datetime日期控件、image图片上传控件、upload文件上传控件、editor富文本控件) |
|
113 |
*/ |
|
114 |
private String htmlType; |
|
115 |
|
|
116 |
/** |
|
117 |
* 字典类型 |
|
118 |
*/ |
|
119 |
private String dictType; |
|
120 |
|
|
121 |
/** |
|
122 |
* 排序 |
|
123 |
*/ |
|
124 |
private Integer sort; |
|
125 |
|
|
126 |
public String getCapJavaField() { |
|
127 |
return StringUtils.capitalize(javaField); |
|
128 |
} |
|
129 |
|
|
130 |
public boolean isPk() { |
|
131 |
return isPk(this.isPk); |
|
132 |
} |
|
133 |
|
|
134 |
public boolean isPk(String isPk) { |
|
135 |
return isPk != null && StringUtils.equals("1", isPk); |
|
136 |
} |
|
137 |
|
|
138 |
public boolean isIncrement() { |
|
139 |
return isIncrement(this.isIncrement); |
|
140 |
} |
|
141 |
|
|
142 |
public boolean isIncrement(String isIncrement) { |
|
143 |
return isIncrement != null && StringUtils.equals("1", isIncrement); |
|
144 |
} |
|
145 |
|
|
146 |
public boolean isRequired() { |
|
147 |
return isRequired(this.isRequired); |
|
148 |
} |
|
149 |
|
|
150 |
public boolean isRequired(String isRequired) { |
|
151 |
return isRequired != null && StringUtils.equals("1", isRequired); |
|
152 |
} |
|
153 |
|
|
154 |
public boolean isInsert() { |
|
155 |
return isInsert(this.isInsert); |
|
156 |
} |
|
157 |
|
|
158 |
public boolean isInsert(String isInsert) { |
|
159 |
return isInsert != null && StringUtils.equals("1", isInsert); |
|
160 |
} |
|
161 |
|
|
162 |
public boolean isEdit() { |
|
163 |
return isInsert(this.isEdit); |
|
164 |
} |
|
165 |
|
|
166 |
public boolean isEdit(String isEdit) { |
|
167 |
return isEdit != null && StringUtils.equals("1", isEdit); |
|
168 |
} |
|
169 |
|
|
170 |
public boolean isList() { |
|
171 |
return isList(this.isList); |
|
172 |
} |
|
173 |
|
|
174 |
public boolean isList(String isList) { |
|
175 |
return isList != null && StringUtils.equals("1", isList); |
|
176 |
} |
|
177 |
|
|
178 |
public boolean isQuery() { |
|
179 |
return isQuery(this.isQuery); |
|
180 |
} |
|
181 |
|
|
182 |
public boolean isQuery(String isQuery) { |
|
183 |
return isQuery != null && StringUtils.equals("1", isQuery); |
|
184 |
} |
|
185 |
|
|
186 |
public boolean isSuperColumn() { |
|
187 |
return isSuperColumn(this.javaField); |
|
188 |
} |
|
189 |
|
|
190 |
public static boolean isSuperColumn(String javaField) { |
|
191 |
return StringUtils.equalsAnyIgnoreCase(javaField, |
|
192 |
// BaseEntity |
|
193 |
"createBy", "createTime", "updateBy", "updateTime", |
|
194 |
// TreeEntity |
|
195 |
"parentName", "parentId"); |
|
196 |
} |
|
197 |
|
|
198 |
public boolean isUsableColumn() { |
|
199 |
return isUsableColumn(javaField); |
|
200 |
} |
|
201 |
|
|
202 |
public static boolean isUsableColumn(String javaField) { |
|
203 |
// isSuperColumn()中的名单用于避免生成多余Domain属性,若某些属性在生成页面时需要用到不能忽略,则放在此处白名单 |
|
204 |
return StringUtils.equalsAnyIgnoreCase(javaField, "parentId", "orderNum", "remark"); |
|
205 |
} |
|
206 |
|
|
207 |
public String readConverterExp() { |
|
208 |
String remarks = StringUtils.substringBetween(this.columnComment, "(", ")"); |
|
209 |
StringBuffer sb = new StringBuffer(); |
|
210 |
if (StringUtils.isNotEmpty(remarks)) { |
|
211 |
for (String value : remarks.split(" ")) { |
|
212 |
if (StringUtils.isNotEmpty(value)) { |
|
213 |
Object startStr = value.subSequence(0, 1); |
|
214 |
String endStr = value.substring(1); |
|
215 |
sb.append(StringUtils.EMPTY).append(startStr).append("=").append(endStr).append(StringUtils.SEPARATOR); |
|
216 |
} |
|
217 |
} |
|
218 |
return sb.deleteCharAt(sb.length() - 1).toString(); |
|
219 |
} else { |
|
220 |
return this.columnComment; |
|
221 |
} |
|
222 |
} |
|
223 |
} |