Commit 633a5a70bb9ae8d9b9c927bee2c1433d9d62fe30

Authored by huhai
2 parents 1a687197 3a0d3b0c

Merge branch 'develop' of http://www.huahengrobot.com:90/wms/wms2 into develop

Showing 78 changed files with 24624 additions and 1152 deletions

Too many changes to show.

To preserve performance only 36 of 78 files are displayed.

src/main/java/com/huaheng/common/constant/GenConstants.java 0 → 100644
  1 +package com.huaheng.common.constant;
  2 +
  3 +import java.time.LocalTime;
  4 +
  5 +/**
  6 + * 代码生成通用常量
  7 + */
  8 +public class GenConstants {
  9 + /**
  10 + * 单表(增删改查)
  11 + */
  12 + public static final String TPL_CRUD = "crud";
  13 +
  14 + /**
  15 + * 树表(增删改查)
  16 + */
  17 + public static final String TPL_TREE = "tree";
  18 +
  19 + /**
  20 + * 主子表(增删改查)
  21 + */
  22 + public static final String TPL_SUB = "sub";
  23 +
  24 + /**
  25 + * 树编码字段
  26 + */
  27 + public static final String TREE_CODE = "treeCode";
  28 +
  29 + /**
  30 + * 树父编码字段
  31 + */
  32 + public static final String TREE_PARENT_CODE = "treeParentCode";
  33 +
  34 + /**
  35 + * 树名称字段
  36 + */
  37 + public static final String TREE_NAME = "treeName";
  38 +
  39 + /**
  40 + * 数据库字符串类型
  41 + */
  42 + public static final String[] COLUMNTYPE_STR = {"char", "varchar", "narchar", "varchar2", "tinytext", "text",
  43 + "mediumtext", "longtext"};
  44 +
  45 + /**
  46 + * 数据库时间类型
  47 + */
  48 + public static final String[] COLUMNTYPE_DATETIME = {"datetime", "timestamp"};
  49 +
  50 + /**
  51 + * 数据库时间类型
  52 + */
  53 + public static final String[] COLUMNTYPE_DATE = {"date"};
  54 +
  55 + /**
  56 + * 数据库时间类型
  57 + */
  58 + public static final String[] COLUMNTYPE_TIME = {"time"};
  59 +
  60 + /**
  61 + * 数据库位类型
  62 + */
  63 + public static final String[] COLUMNTYPE_BIT = {"bit"};
  64 +
  65 + /**
  66 + * 数据库数字类型
  67 + */
  68 + public static final String[] COLUMNTYPE_NUMBER = {"tinyint", "smallint", "mediumint", "int", "number", "integer",
  69 + "bigint", "float", "float", "double", "decimal"};
  70 +
  71 + /**
  72 + * 页面不需要编辑字段
  73 + */
  74 + public static final String[] COLUMNNAME_NOT_EDIT = {"id", "create_by", "create_time", "del_flag"};
  75 +
  76 + /**
  77 + * 页面不需要显示的列表字段
  78 + */
  79 + public static final String[] COLUMNNAME_NOT_LIST = {"id", "create_by", "create_time", "del_flag", "update_by",
  80 + "update_time"};
  81 +
  82 + /**
  83 + * 页面不需要查询字段
  84 + */
  85 + public static final String[] COLUMNNAME_NOT_QUERY = {"id", "create_by", "create_time", "del_flag", "update_by",
  86 + "update_time", "remark"};
  87 +
  88 + /**
  89 + * Entity基类字段
  90 + */
  91 + public static final String[] BASE_ENTITY = {"createBy", "createTime", "updateBy", "updateTime", "remark"};
  92 +
  93 + /**
  94 + * Tree基类字段
  95 + */
  96 + public static final String[] TREE_ENTITY = {"parentName", "parentId", "orderNum", "ancestors"};
  97 +
  98 + /**
  99 + * 文本框
  100 + */
  101 + public static final String HTML_INPUT = "input";
  102 +
  103 + /**
  104 + * 文本域
  105 + */
  106 + public static final String HTML_TEXTAREA = "textarea";
  107 +
  108 + /**
  109 + * 下拉框
  110 + */
  111 + public static final String HTML_SELECT = "select";
  112 +
  113 + /**
  114 + * 单选框
  115 + */
  116 + public static final String HTML_RADIO = "radio";
  117 +
  118 + /**
  119 + * 复选框
  120 + */
  121 + public static final String HTML_CHECKBOX = "checkbox";
  122 +
  123 + /**
  124 + * 日期控件
  125 + */
  126 + public static final String HTML_DATETIME = "datetime";
  127 +
  128 + /**
  129 + * 字符串类型
  130 + */
  131 + public static final String TYPE_STRING = "String";
  132 +
  133 + /**
  134 + * 整型
  135 + */
  136 + public static final String TYPE_INTEGER = "Integer";
  137 +
  138 + /**
  139 + * 长整型
  140 + */
  141 + public static final String TYPE_LONG = "Long";
  142 +
  143 + /**
  144 + * 浮点型
  145 + */
  146 + public static final String TYPE_DOUBLE = "Double";
  147 +
  148 + /**
  149 + * 高精度计算类型
  150 + */
  151 + public static final String TYPE_BIGDECIMAL = "BigDecimal";
  152 +
  153 + /**
  154 + * 时间类型
  155 + */
  156 + public static final String TYPE_DATE = "LocalDate";
  157 +
  158 + /**
  159 + * 时间类型
  160 + */
  161 + public static final String TYPE_DATETIME = "LocalDateTime";
  162 +
  163 + /**
  164 + * 时间类型
  165 + */
  166 + public static final String TYPE_TIME = "LocalTime";
  167 +
  168 + /**
  169 + * 模糊查询
  170 + */
  171 + public static final String QUERY_LIKE = "LIKE";
  172 +
  173 + /**
  174 + * 需要
  175 + */
  176 + public static final String REQUIRE = "1";
  177 +}
... ...
src/main/java/com/huaheng/common/constant/UserConstants.java
... ... @@ -8,8 +8,8 @@ package com.huaheng.common.constant;
8 8 public class UserConstants
9 9 {
10 10  
11   -// /** 正常状态 */
12   -// public static final String NORMAL = "0";
  11 + /** 正常状态 */
  12 + public static final String NORMAL = "0";
13 13 //
14 14 // /** 异常状态 */
15 15 // public static final String EXCEPTION = "1";
... ... @@ -89,4 +89,6 @@ public class UserConstants
89 89 */
90 90 public static final String EMAIL_PATTERN = "^((([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+(\\.([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+)*)|((\\x22)((((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]|\\x21|[\\x23-\\x5b]|[\\x5d-\\x7e]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(\\\\([\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]))))*(((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(\\x22)))@((([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.)+(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.?";
91 91  
  92 + /** 字典正常状态 */
  93 + public static final String DICT_NORMAL = "0";
92 94 }
... ...
src/main/java/com/huaheng/common/utils/StringUtils.java
... ... @@ -3,129 +3,123 @@ package com.huaheng.common.utils;
3 3 import java.lang.reflect.Field;
4 4 import java.util.Collection;
5 5 import java.util.Map;
  6 +
6 7 import org.apache.commons.lang.text.StrBuilder;
7 8 import com.huaheng.common.support.StrFormatter;
8 9  
9 10 /**
10 11 * 字符串工具类
11   - *
  12 + *
12 13 * @author huaheng
13 14 */
14   -public class StringUtils extends org.apache.commons.lang3.StringUtils
15   -{
16   - /** 空字符串 */
  15 +public class StringUtils extends org.apache.commons.lang3.StringUtils {
  16 + /**
  17 + * 空字符串
  18 + */
17 19 private static final String NULLSTR = "";
18 20  
19   - /** 下划线 */
  21 + /**
  22 + * 下划线
  23 + */
20 24 private static final char SEPARATOR = '_';
21 25  
22 26 /**
23 27 * 获取参数不为空值
24   - *
  28 + *
25 29 * @param value defaultValue 要判断的value
26 30 * @return value 返回值
27 31 */
28   - public static <T> T nvl(T value, T defaultValue)
29   - {
  32 + public static <T> T nvl(T value, T defaultValue) {
30 33 return value != null ? value : defaultValue;
31 34 }
32 35  
33 36 /**
34 37 * * 判断一个Collection是否为空, 包含List,Set,Queue
35   - *
  38 + *
36 39 * @param coll 要判断的Collection
37 40 * @return true:为空 false:非空
38 41 */
39   - public static boolean isEmpty(Collection<?> coll)
40   - {
  42 + public static boolean isEmpty(Collection<?> coll) {
41 43 return isNull(coll) || coll.isEmpty();
42 44 }
43 45  
44 46 /**
45 47 * * 判断一个Collection是否非空,包含List,Set,Queue
46   - *
  48 + *
47 49 * @param coll 要判断的Collection
48 50 * @return true:非空 false:空
49 51 */
50   - public static boolean isNotEmpty(Collection<?> coll)
51   - {
  52 + public static boolean isNotEmpty(Collection<?> coll) {
52 53 return !isEmpty(coll);
53 54 }
54 55  
55 56 /**
56 57 * * 判断一个对象数组是否为空
57   - *
  58 + *
58 59 * @param objects 要判断的对象数组
59   - ** @return true:为空 false:非空
  60 + * * @return true:为空 false:非空
60 61 */
61   - public static boolean isEmpty(Object[] objects)
62   - {
  62 + public static boolean isEmpty(Object[] objects) {
63 63 return isNull(objects) || (objects.length == 0);
64 64 }
65 65  
66 66 /**
67 67 * * 判断一个对象数组是否非空
68   - *
  68 + *
69 69 * @param objects 要判断的对象数组
70 70 * @return true:非空 false:空
71 71 */
72   - public static boolean isNotEmpty(Object[] objects)
73   - {
  72 + public static boolean isNotEmpty(Object[] objects) {
74 73 return !isEmpty(objects);
75 74 }
76 75  
77 76 /**
78 77 * * 判断一个Map是否为空
79   - *
  78 + *
80 79 * @param map 要判断的Map
81 80 * @return true:为空 false:非空
82 81 */
83   - public static boolean isEmpty(Map<?, ?> map)
84   - {
  82 + public static boolean isEmpty(Map<?, ?> map) {
85 83 return isNull(map) || map.isEmpty();
86 84 }
87 85  
88 86 /**
89 87 * * 判断一个Map是否为空
90   - *
  88 + *
91 89 * @param map 要判断的Map
92 90 * @return true:非空 false:空
93 91 */
94   - public static boolean isNotEmpty(Map<?, ?> map)
95   - {
  92 + public static boolean isNotEmpty(Map<?, ?> map) {
96 93 return !isEmpty(map);
97 94 }
98 95  
99 96 /**
100 97 * * 判断一个字符串是否为空串
101   - *
  98 + *
102 99 * @param str String
103 100 * @return true:为空 false:非空
104 101 */
105   - public static boolean isEmpty(String str)
106   - {
  102 + public static boolean isEmpty(String str) {
107 103 return isNull(str) || NULLSTR.equals(str.trim());
108 104 }
109 105  
110 106 /**
111 107 * * 判断一个字符串是否为非空串
112   - *
  108 + *
113 109 * @param str String
114 110 * @return true:非空串 false:空串
115 111 */
116   - public static boolean isNotEmpty(String str)
117   - {
  112 + public static boolean isNotEmpty(String str) {
118 113 return !isEmpty(str);
119 114 }
120 115  
121 116 /**
122 117 * * 判断一个对象是否为空
123   - *
  118 + *
124 119 * @param object Object
125 120 * @return true:为空 false:非空
126 121 */
127   - public static boolean isNull(Object object)
128   - {
  122 + public static boolean isNull(Object object) {
129 123  
130 124 if (object == null) {
131 125 return true;
... ... @@ -161,59 +155,51 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
161 155  
162 156 /**
163 157 * * 判断一个对象是否非空
164   - *
  158 + *
165 159 * @param object Object
166 160 * @return true:非空 false:空
167 161 */
168   - public static boolean isNotNull(Object object)
169   - {
  162 + public static boolean isNotNull(Object object) {
170 163 return !isNull(object);
171 164 }
172 165  
173 166 /**
174 167 * * 判断一个对象是否是数组类型(Java基本型别的数组)
175   - *
  168 + *
176 169 * @param object 对象
177 170 * @return true:是数组 false:不是数组
178 171 */
179   - public static boolean isArray(Object object)
180   - {
  172 + public static boolean isArray(Object object) {
181 173 return isNotNull(object) && object.getClass().isArray();
182 174 }
183 175  
184 176 /**
185 177 * 去空格
186 178 */
187   - public static String trim(String str)
188   - {
  179 + public static String trim(String str) {
189 180 return (str == null ? "" : str.trim());
190 181 }
191 182  
192 183 /**
193 184 * 截取字符串
194   - *
195   - * @param str 字符串
  185 + *
  186 + * @param str 字符串
196 187 * @param start 开始
197 188 * @return 结果
198 189 */
199   - public static String substring(final String str, int start)
200   - {
201   - if (str == null)
202   - {
  190 + public static String substring(final String str, int start) {
  191 + if (str == null) {
203 192 return NULLSTR;
204 193 }
205 194  
206   - if (start < 0)
207   - {
  195 + if (start < 0) {
208 196 start = str.length() + start;
209 197 }
210 198  
211   - if (start < 0)
212   - {
  199 + if (start < 0) {
213 200 start = 0;
214 201 }
215   - if (start > str.length())
216   - {
  202 + if (start > str.length()) {
217 203 return NULLSTR;
218 204 }
219 205  
... ... @@ -222,44 +208,36 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
222 208  
223 209 /**
224 210 * 截取字符串
225   - *
226   - * @param str 字符串
  211 + *
  212 + * @param str 字符串
227 213 * @param start 开始
228   - * @param end 结束
  214 + * @param end 结束
229 215 * @return 结果
230 216 */
231   - public static String substring(final String str, int start, int end)
232   - {
233   - if (str == null)
234   - {
  217 + public static String substring(final String str, int start, int end) {
  218 + if (str == null) {
235 219 return NULLSTR;
236 220 }
237 221  
238   - if (end < 0)
239   - {
  222 + if (end < 0) {
240 223 end = str.length() + end;
241 224 }
242   - if (start < 0)
243   - {
  225 + if (start < 0) {
244 226 start = str.length() + start;
245 227 }
246 228  
247   - if (end > str.length())
248   - {
  229 + if (end > str.length()) {
249 230 end = str.length();
250 231 }
251 232  
252   - if (start > end)
253   - {
  233 + if (start > end) {
254 234 return NULLSTR;
255 235 }
256 236  
257   - if (start < 0)
258   - {
  237 + if (start < 0) {
259 238 start = 0;
260 239 }
261   - if (end < 0)
262   - {
  240 + if (end < 0) {
263 241 end = 0;
264 242 }
265 243  
... ... @@ -274,15 +252,13 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
274 252 * 通常使用:format("this is {} for {}", "a", "b") -> this is a for b<br>
275 253 * 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a<br>
276 254 * 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b<br>
277   - *
  255 + *
278 256 * @param template 文本模板,被替换的部分用 {} 表示
279   - * @param params 参数值
  257 + * @param params 参数值
280 258 * @return 格式化后的文本
281 259 */
282   - public static String format(String template, Object... params)
283   - {
284   - if (isEmpty(params) || isEmpty(template))
285   - {
  260 + public static String format(String template, Object... params) {
  261 + if (isEmpty(params) || isEmpty(template)) {
286 262 return template;
287 263 }
288 264 return StrFormatter.format(template, params);
... ... @@ -291,11 +267,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
291 267 /**
292 268 * 驼峰首字符小写
293 269 */
294   - public static String uncapitalize(String str)
295   - {
  270 + public static String uncapitalize(String str) {
296 271 int strLen;
297   - if (str == null || (strLen = str.length()) == 0)
298   - {
  272 + if (str == null || (strLen = str.length()) == 0) {
299 273 return str;
300 274 }
301 275 return new StrBuilder(strLen).append(Character.toLowerCase(str.charAt(0))).append(str.substring(1)).toString();
... ... @@ -304,35 +278,27 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
304 278 /**
305 279 * 下划线转驼峰命名
306 280 */
307   - public static String toUnderScoreCase(String s)
308   - {
309   - if (s == null)
310   - {
  281 + public static String toUnderScoreCase(String s) {
  282 + if (s == null) {
311 283 return null;
312 284 }
313 285 StringBuilder sb = new StringBuilder();
314 286 boolean upperCase = false;
315   - for (int i = 0; i < s.length(); i++)
316   - {
  287 + for (int i = 0; i < s.length(); i++) {
317 288 char c = s.charAt(i);
318 289  
319 290 boolean nextUpperCase = true;
320 291  
321   - if (i < (s.length() - 1))
322   - {
  292 + if (i < (s.length() - 1)) {
323 293 nextUpperCase = Character.isUpperCase(s.charAt(i + 1));
324 294 }
325 295  
326   - if ((i > 0) && Character.isUpperCase(c))
327   - {
328   - if (!upperCase || !nextUpperCase)
329   - {
  296 + if ((i > 0) && Character.isUpperCase(c)) {
  297 + if (!upperCase || !nextUpperCase) {
330 298 sb.append(SEPARATOR);
331 299 }
332 300 upperCase = true;
333   - }
334   - else
335   - {
  301 + } else {
336 302 upperCase = false;
337 303 }
338 304  
... ... @@ -344,19 +310,15 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
344 310  
345 311 /**
346 312 * 是否包含字符串
347   - *
348   - * @param str 验证字符串
  313 + *
  314 + * @param str 验证字符串
349 315 * @param strs 字符串组
350 316 * @return 包含返回true
351 317 */
352   - public static boolean inStringIgnoreCase(String str, String... strs)
353   - {
354   - if (str != null && strs != null)
355   - {
356   - for (String s : strs)
357   - {
358   - if (str.equalsIgnoreCase(trim(s)))
359   - {
  318 + public static boolean inStringIgnoreCase(String str, String... strs) {
  319 + if (str != null && strs != null) {
  320 + for (String s : strs) {
  321 + if (str.equalsIgnoreCase(trim(s))) {
360 322 return true;
361 323 }
362 324 }
... ... @@ -366,31 +328,25 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
366 328  
367 329 /**
368 330 * 将下划线大写方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。 例如:HELLO_WORLD->HelloWorld
369   - *
  331 + *
370 332 * @param name 转换前的下划线大写方式命名的字符串
371 333 * @return 转换后的驼峰式命名的字符串
372 334 */
373   - public static String convertToCamelCase(String name)
374   - {
  335 + public static String convertToCamelCase(String name) {
375 336 StringBuilder result = new StringBuilder();
376 337 // 快速检查
377   - if (name == null || name.isEmpty())
378   - {
  338 + if (name == null || name.isEmpty()) {
379 339 // 没必要转换
380 340 return "";
381   - }
382   - else if (!name.contains("_"))
383   - {
  341 + } else if (!name.contains("_")) {
384 342 // 不含下划线,仅将首字母大写
385 343 return name.substring(0, 1).toUpperCase() + name.substring(1);
386 344 }
387 345 // 用下划线将原始字符串分割
388 346 String[] camels = name.split("_");
389   - for (String camel : camels)
390   - {
  347 + for (String camel : camels) {
391 348 // 跳过原始字符串中开头、结尾的下换线或双重下划线
392   - if (camel.isEmpty())
393   - {
  349 + if (camel.isEmpty()) {
394 350 continue;
395 351 }
396 352 // 首字母大写
... ... @@ -399,4 +355,29 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
399 355 }
400 356 return result.toString();
401 357 }
  358 +
  359 + /**
  360 + * 驼峰式命名法 例如:user_name->userName
  361 + */
  362 + public static String toCamelCase(String s) {
  363 + if (s == null) {
  364 + return null;
  365 + }
  366 + s = s.toLowerCase();
  367 + StringBuilder sb = new StringBuilder(s.length());
  368 + boolean upperCase = false;
  369 + for (int i = 0; i < s.length(); i++) {
  370 + char c = s.charAt(i);
  371 +
  372 + if (c == SEPARATOR) {
  373 + upperCase = true;
  374 + } else if (upperCase) {
  375 + sb.append(Character.toUpperCase(c));
  376 + upperCase = false;
  377 + } else {
  378 + sb.append(c);
  379 + }
  380 + }
  381 + return sb.toString();
  382 + }
402 383 }
403 384 \ No newline at end of file
... ...
src/main/java/com/huaheng/common/utils/VelocityInitializer.java 0 → 100644
  1 +package com.huaheng.common.utils;
  2 +
  3 +import java.util.Properties;
  4 +
  5 +import com.huaheng.common.constant.Constants;
  6 +import org.apache.velocity.app.Velocity;
  7 +
  8 +
  9 +/**
  10 + * VelocityEngine工厂
  11 + *
  12 + * @author RuoYi
  13 + */
  14 +public class VelocityInitializer {
  15 + /**
  16 + * 初始化vm方法
  17 + */
  18 + public static void initVelocity() {
  19 + Properties p = new Properties();
  20 + try {
  21 + // 加载classpath目录下的vm文件
  22 + p.setProperty("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
  23 + // 定义字符集
  24 + p.setProperty(Velocity.ENCODING_DEFAULT, Constants.UTF8);
  25 + p.setProperty(Velocity.OUTPUT_ENCODING, Constants.UTF8);
  26 + // 初始化Velocity引擎,指定配置Properties
  27 + Velocity.init(p);
  28 + } catch (Exception e) {
  29 + throw new RuntimeException(e);
  30 + }
  31 + }
  32 +}
... ...
src/main/java/com/huaheng/common/utils/VelocityUtils.java 0 → 100644
  1 +package com.huaheng.common.utils;
  2 +
  3 +import java.util.ArrayList;
  4 +import java.util.HashSet;
  5 +import java.util.List;
  6 +
  7 +import com.huaheng.common.constant.GenConstants;
  8 +import com.huaheng.common.utils.DateUtils;
  9 +import com.huaheng.common.utils.StringUtils;
  10 +import com.huaheng.framework.config.GenConfig;
  11 +import com.huaheng.pc.tool.gen.domain.GenTable;
  12 +import com.huaheng.pc.tool.gen.domain.GenTableColumn;
  13 +import org.apache.velocity.VelocityContext;
  14 +import com.alibaba.fastjson.JSONObject;
  15 +
  16 +public class VelocityUtils {
  17 + /**
  18 + * 项目空间路径
  19 + */
  20 + private static final String PROJECT_PATH = "main/java";
  21 +
  22 + /**
  23 + * mybatis空间路径
  24 + */
  25 + private static final String MYBATIS_PATH = "main/resources/mapper";
  26 +
  27 + /**
  28 + * html空间路径
  29 + */
  30 + private static final String TEMPLATES_PATH = "main/resources/templates";
  31 +
  32 + /**
  33 + * 设置模板变量信息
  34 + *
  35 + * @return 模板列表
  36 + */
  37 + public static VelocityContext prepareContext(GenTable genTable) {
  38 + String moduleName = genTable.getModuleName();
  39 + String businessName = genTable.getBusinessName();
  40 + String packageName = genTable.getPackageName();
  41 + String tplCategory = genTable.getTplCategory();
  42 + String functionName = genTable.getFunctionName();
  43 +
  44 + VelocityContext velocityContext = new VelocityContext();
  45 + velocityContext.put("tplCategory", genTable.getTplCategory());
  46 + velocityContext.put("tableName", genTable.getTableName());
  47 + velocityContext.put("functionName", StringUtils.isNotEmpty(functionName) ? functionName : "【请填写功能名称】");
  48 + velocityContext.put("ClassName", genTable.getClassName());
  49 + velocityContext.put("className", StringUtils.uncapitalize(genTable.getClassName()));
  50 + velocityContext.put("moduleName", genTable.getModuleName());
  51 + velocityContext.put("businessName", genTable.getBusinessName());
  52 + velocityContext.put("basePackage", getPackagePrefix(packageName));
  53 + velocityContext.put("packageName", packageName);
  54 + velocityContext.put("author", genTable.getFunctionAuthor());
  55 + velocityContext.put("datetime", DateUtils.getDate());
  56 + velocityContext.put("pkColumn", genTable.getPkColumn());
  57 + velocityContext.put("importList", getImportList(genTable));
  58 + velocityContext.put("permissionPrefix", getPermissionPrefix(moduleName, businessName));
  59 + velocityContext.put("columns", genTable.getColumns());
  60 + velocityContext.put("table", genTable);
  61 + if (GenConstants.TPL_TREE.equals(tplCategory)) {
  62 + setTreeVelocityContext(velocityContext, genTable);
  63 + }
  64 + if (GenConstants.TPL_SUB.equals(tplCategory)) {
  65 + setSubVelocityContext(velocityContext, genTable);
  66 + }
  67 + return velocityContext;
  68 + }
  69 +
  70 + public static void setTreeVelocityContext(VelocityContext context, GenTable genTable) {
  71 + String options = genTable.getOptions();
  72 + JSONObject paramsObj = JSONObject.parseObject(options);
  73 + String treeCode = getTreecode(paramsObj);
  74 + String treeParentCode = getTreeParentCode(paramsObj);
  75 + String treeName = getTreeName(paramsObj);
  76 +
  77 + context.put("treeCode", treeCode);
  78 + context.put("treeParentCode", treeParentCode);
  79 + context.put("treeName", treeName);
  80 + context.put("expandColumn", getExpandColumn(genTable));
  81 + if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE)) {
  82 + context.put("tree_parent_code", paramsObj.getString(GenConstants.TREE_PARENT_CODE));
  83 + }
  84 + if (paramsObj.containsKey(GenConstants.TREE_NAME)) {
  85 + context.put("tree_name", paramsObj.getString(GenConstants.TREE_NAME));
  86 + }
  87 + }
  88 +
  89 + public static void setSubVelocityContext(VelocityContext context, GenTable genTable) {
  90 + GenTable subTable = genTable.getSubTable();
  91 + String subTableName = genTable.getSubTableName();
  92 + String subTableFkName = genTable.getSubTableFkName();
  93 + String subClassName = genTable.getSubTable().getClassName();
  94 + String subTableFkClassName = StringUtils.convertToCamelCase(subTableFkName);
  95 +
  96 + context.put("subTable", subTable);
  97 + context.put("subTableName", subTableName);
  98 + context.put("subTableFkName", subTableFkName);
  99 + context.put("subTableFkClassName", subTableFkClassName);
  100 + context.put("subTableFkclassName", StringUtils.uncapitalize(subTableFkClassName));
  101 + context.put("subClassName", subClassName);
  102 + context.put("subclassName", StringUtils.uncapitalize(subClassName));
  103 + context.put("subImportList", getImportList(genTable.getSubTable()));
  104 + }
  105 +
  106 + /**
  107 + * 获取模板信息
  108 + *
  109 + * @return 模板列表
  110 + */
  111 + public static List<String> getTemplateList(String tplCategory) {
  112 + List<String> templates = new ArrayList<String>();
  113 + templates.add("templates/vm/java/domain.java.vm");
  114 + templates.add("templates/vm/java/mapper.java.vm");
  115 + templates.add("templates/vm/java/service.java.vm");
  116 + templates.add("templates/vm/java/serviceImpl.java.vm");
  117 + templates.add("templates/vm/java/controller.java.vm");
  118 + templates.add("templates/vm/xml/mapper.xml.vm");
  119 + if (GenConstants.TPL_CRUD.equals(tplCategory)) {
  120 + templates.add("templates/vm/html/list.html.vm");
  121 + } else if (GenConstants.TPL_TREE.equals(tplCategory)) {
  122 + templates.add("templates/vm/html/tree.html.vm");
  123 + templates.add("templates/vm/html/list-tree.html.vm");
  124 + } else if (GenConstants.TPL_SUB.equals(tplCategory)) {
  125 + templates.add("templates/vm/html/list.html.vm");
  126 + templates.add("templates/vm/java/sub-domain.java.vm");
  127 + }
  128 + templates.add("templates/vm/html/add.html.vm");
  129 + templates.add("templates/vm/html/edit.html.vm");
  130 + templates.add("templates/vm/sql/sql.vm");
  131 + return templates;
  132 + }
  133 +
  134 + /**
  135 + * 获取文件名
  136 + */
  137 + public static String getFileName(String template, GenTable genTable) {
  138 + // 文件名称
  139 + String fileName = "";
  140 + // 包路径
  141 + String packageName = genTable.getPackageName();
  142 + // 模块名
  143 + String moduleName = genTable.getModuleName();
  144 + // 大写类名
  145 + String className = genTable.getClassName();
  146 + // 业务名称
  147 + String businessName = genTable.getBusinessName();
  148 +
  149 + String javaPath = PROJECT_PATH + "/" + StringUtils.replace(packageName, ".", "/");
  150 + String mybatisPath = MYBATIS_PATH + "/" + moduleName;
  151 + String htmlPath = TEMPLATES_PATH + "/" + moduleName + "/" + businessName;
  152 +
  153 + if (template.contains("domain.java.vm")) {
  154 + fileName = StringUtils.format("{}/domain/{}.java", javaPath, className);
  155 + }
  156 + if (template.contains("sub-domain.java.vm") && StringUtils.equals(GenConstants.TPL_SUB, genTable.getTplCategory())) {
  157 + fileName = StringUtils.format("{}/domain/{}.java", javaPath, genTable.getSubTable().getClassName());
  158 + } else if (template.contains("mapper.java.vm")) {
  159 + fileName = StringUtils.format("{}/mapper/{}Mapper.java", javaPath, className);
  160 + } else if (template.contains("service.java.vm")) {
  161 + fileName = StringUtils.format("{}/service/I{}Service.java", javaPath, className);
  162 + } else if (template.contains("serviceImpl.java.vm")) {
  163 + fileName = StringUtils.format("{}/service/impl/{}ServiceImpl.java", javaPath, className);
  164 + } else if (template.contains("controller.java.vm")) {
  165 + fileName = StringUtils.format("{}/controller/{}Controller.java", javaPath, className);
  166 + } else if (template.contains("mapper.xml.vm")) {
  167 + fileName = StringUtils.format("{}/{}Mapper.xml", mybatisPath, className);
  168 + } else if (template.contains("list.html.vm")) {
  169 + fileName = StringUtils.format("{}/{}.html", htmlPath, businessName);
  170 + } else if (template.contains("list-tree.html.vm")) {
  171 + fileName = StringUtils.format("{}/{}.html", htmlPath, businessName);
  172 + } else if (template.contains("tree.html.vm")) {
  173 + fileName = StringUtils.format("{}/tree.html", htmlPath);
  174 + } else if (template.contains("add.html.vm")) {
  175 + fileName = StringUtils.format("{}/add.html", htmlPath);
  176 + } else if (template.contains("edit.html.vm")) {
  177 + fileName = StringUtils.format("{}/edit.html", htmlPath);
  178 + } else if (template.contains("sql.vm")) {
  179 + fileName = businessName + "Menu.sql";
  180 + }
  181 + return fileName;
  182 + }
  183 +
  184 + /**
  185 + * 获取项目文件路径
  186 + *
  187 + * @return 路径
  188 + */
  189 + public static String getProjectPath() {
  190 + String packageName = GenConfig.getPackageName();
  191 + StringBuffer projectPath = new StringBuffer();
  192 + projectPath.append("main/java/");
  193 + projectPath.append(packageName.replace(".", "/"));
  194 + projectPath.append("/");
  195 + return projectPath.toString();
  196 + }
  197 +
  198 + /**
  199 + * 获取包前缀
  200 + *
  201 + * @param packageName 包名称
  202 + * @return 包前缀名称
  203 + */
  204 + public static String getPackagePrefix(String packageName) {
  205 + int lastIndex = packageName.lastIndexOf(".");
  206 + String basePackage = StringUtils.substring(packageName, 0, lastIndex);
  207 + return basePackage;
  208 + }
  209 +
  210 + /**
  211 + * 根据列类型获取导入包
  212 + *
  213 + * @param genTable 业务表对象
  214 + * @return 返回需要导入的包列表
  215 + */
  216 + public static HashSet<String> getImportList(GenTable genTable) {
  217 + List<GenTableColumn> columns = genTable.getColumns();
  218 + GenTable subGenTable = genTable.getSubTable();
  219 + HashSet<String> importList = new HashSet<String>();
  220 + if (StringUtils.isNotNull(subGenTable)) {
  221 + importList.add("java.util.List");
  222 + }
  223 + for (GenTableColumn column : columns) {
  224 + if (!column.isSuperColumn() && GenConstants.TYPE_DATE.equals(column.getJavaType())) {
  225 + importList.add("java.util.Date");
  226 + } else if (!column.isSuperColumn() && GenConstants.TYPE_BIGDECIMAL.equals(column.getJavaType())) {
  227 + importList.add("java.math.BigDecimal");
  228 + }
  229 + }
  230 + return importList;
  231 + }
  232 +
  233 + /**
  234 + * 获取权限前缀
  235 + *
  236 + * @param moduleName 模块名称
  237 + * @param businessName 业务名称
  238 + * @return 返回权限前缀
  239 + */
  240 + public static String getPermissionPrefix(String moduleName, String businessName) {
  241 + return StringUtils.format("{}:{}", moduleName, businessName);
  242 +
  243 + }
  244 +
  245 + /**
  246 + * 获取树编码
  247 + *
  248 + * @param paramsObj 生成其他选项
  249 + * @return 树编码
  250 + */
  251 + public static String getTreecode(JSONObject paramsObj) {
  252 + if (paramsObj.containsKey(GenConstants.TREE_CODE)) {
  253 + return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_CODE));
  254 + }
  255 + return "";
  256 + }
  257 +
  258 + /**
  259 + * 获取树父编码
  260 + *
  261 + * @param paramsObj 生成其他选项
  262 + * @return 树父编码
  263 + */
  264 + public static String getTreeParentCode(JSONObject paramsObj) {
  265 + if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE)) {
  266 + return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_PARENT_CODE));
  267 + }
  268 + return "";
  269 + }
  270 +
  271 + /**
  272 + * 获取树名称
  273 + *
  274 + * @param paramsObj 生成其他选项
  275 + * @return 树名称
  276 + */
  277 + public static String getTreeName(JSONObject paramsObj) {
  278 + if (paramsObj.containsKey(GenConstants.TREE_NAME)) {
  279 + return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_NAME));
  280 + }
  281 + return "";
  282 + }
  283 +
  284 + /**
  285 + * 获取需要在哪一列上面显示展开按钮
  286 + *
  287 + * @param genTable 业务表对象
  288 + * @return 展开按钮列序号
  289 + */
  290 + public static int getExpandColumn(GenTable genTable) {
  291 + String options = genTable.getOptions();
  292 + JSONObject paramsObj = JSONObject.parseObject(options);
  293 + String treeName = paramsObj.getString(GenConstants.TREE_NAME);
  294 + int num = 0;
  295 + for (GenTableColumn column : genTable.getColumns()) {
  296 + if (column.isList()) {
  297 + num++;
  298 + String columnName = column.getColumnName();
  299 + if (columnName.equals(treeName)) {
  300 + break;
  301 + }
  302 + }
  303 + }
  304 + return num;
  305 + }
  306 +}
0 307 \ No newline at end of file
... ...
src/main/java/com/huaheng/framework/config/GenConfig.java
1 1 package com.huaheng.framework.config;
2 2  
  3 +import org.springframework.beans.factory.annotation.Value;
3 4 import org.springframework.boot.context.properties.ConfigurationProperties;
  5 +import org.springframework.context.annotation.PropertySource;
4 6 import org.springframework.stereotype.Component;
5 7  
6 8 /**
7 9 * 读取代码生成相关配置
8   - *
9   - * @author huaheng
  10 + *
  11 + * @author ruoyi
10 12 */
11 13 @Component
12 14 @ConfigurationProperties(prefix = "gen")
13   -public class GenConfig
14   -{
15   - /** 作者 */
  15 +@PropertySource(value = {"classpath:generator.yml"})
  16 +public class GenConfig {
  17 + /**
  18 + * 作者
  19 + */
16 20 public static String author;
17   - /** 生成包路径 */
  21 +
  22 + /**
  23 + * 生成包路径
  24 + */
18 25 public static String packageName;
19   - /** 自动去除表前缀,默认是true */
20   - public static String autoRemovePre;
21   - /** 表前缀(类名不会包含表前缀) */
  26 +
  27 + /**
  28 + * 自动去除表前缀,默认是false
  29 + */
  30 + public static boolean autoRemovePre;
  31 +
  32 + /**
  33 + * 表前缀(类名不会包含表前缀)
  34 + */
22 35 public static String tablePrefix;
23 36  
24   - public static String getAuthor()
25   - {
  37 + public static String getAuthor() {
26 38 return author;
27 39 }
28 40  
29   - public void setAuthor(String author)
30   - {
  41 + @Value("${author}")
  42 + public void setAuthor(String author) {
31 43 GenConfig.author = author;
32 44 }
33 45  
34   - public static String getPackageName()
35   - {
  46 + public static String getPackageName() {
36 47 return packageName;
37 48 }
38 49  
39   - public void setPackageName(String packageName)
40   - {
  50 + @Value("${packageName}")
  51 + public void setPackageName(String packageName) {
41 52 GenConfig.packageName = packageName;
42 53 }
43 54  
44   - public static String getAutoRemovePre()
45   - {
  55 + public static boolean getAutoRemovePre() {
46 56 return autoRemovePre;
47 57 }
48 58  
49   - public void setAutoRemovePre(String autoRemovePre)
50   - {
  59 + @Value("${autoRemovePre}")
  60 + public void setAutoRemovePre(boolean autoRemovePre) {
51 61 GenConfig.autoRemovePre = autoRemovePre;
52 62 }
53 63  
54   - public static String getTablePrefix()
55   - {
  64 + public static String getTablePrefix() {
56 65 return tablePrefix;
57 66 }
58 67  
59   - public void setTablePrefix(String tablePrefix)
60   - {
  68 + @Value("${tablePrefix}")
  69 + public void setTablePrefix(String tablePrefix) {
61 70 GenConfig.tablePrefix = tablePrefix;
62 71 }
63   -
64   - @Override
65   - public String toString()
66   - {
67   - return "GenConfig [getClass()=" + getClass() + ", hashCode()=" + hashCode() + ", toString()=" + super.toString() + "]";
68   - }
69   -
70 72 }
... ...
src/main/java/com/huaheng/framework/web/domain/AjaxResult.java
... ... @@ -85,6 +85,14 @@ public class AjaxResult&lt;T&gt; implements Serializable
85 85 /**
86 86 * 返回成功消息
87 87 */
  88 + public static AjaxResult success()
  89 + {
  90 + return new AjaxResult<>().setCode(RetCode.SUCCESS).setMsg("成功");
  91 + }
  92 +
  93 + /**
  94 + * 返回成功消息
  95 + */
88 96 public static <T> AjaxResult<T> success(T data)
89 97 {
90 98 return new AjaxResult<T>().setCode(RetCode.SUCCESS).setMsg("成功").setData(data);
... ... @@ -115,6 +123,14 @@ public class AjaxResult&lt;T&gt; implements Serializable
115 123 }
116 124  
117 125 /**
  126 + * 返回失败消息
  127 + */
  128 + public static <T> AjaxResult<T> error()
  129 + {
  130 + return new AjaxResult<T>().setCode(RetCode.FAIL).setMsg("失败");
  131 + }
  132 +
  133 + /**
118 134 * 返回消息
119 135 */
120 136 public static <T> AjaxResult<T> setResult(RetCode retCode, String message, T data)
... ...
src/main/java/com/huaheng/framework/web/domain/Ztree.java 0 → 100644
  1 +package com.huaheng.framework.web.domain;
  2 +
  3 +import java.io.Serializable;
  4 +
  5 +/**
  6 + * Ztree树结构实体类
  7 + * @author Enzo Cotter
  8 + * @date 2020/6/30
  9 + */
  10 +public class Ztree implements Serializable {
  11 +
  12 + private static final long serialVersionUID = 1L;
  13 +
  14 + /** 节点ID */
  15 + private Long id;
  16 +
  17 + /** 节点父ID */
  18 + private Long pId;
  19 +
  20 + /** 节点名称 */
  21 + private String name;
  22 +
  23 + /** 节点标题 */
  24 + private String title;
  25 +
  26 + /** 是否勾选 */
  27 + private boolean checked = false;
  28 +
  29 + /** 是否展开 */
  30 + private boolean open = false;
  31 +
  32 + /** 是否能勾选 */
  33 + private boolean nocheck = false;
  34 +
  35 + public Long getId()
  36 + {
  37 + return id;
  38 + }
  39 +
  40 + public void setId(Long id)
  41 + {
  42 + this.id = id;
  43 + }
  44 +
  45 + public Long getpId()
  46 + {
  47 + return pId;
  48 + }
  49 +
  50 + public void setpId(Long pId)
  51 + {
  52 + this.pId = pId;
  53 + }
  54 +
  55 + public String getName()
  56 + {
  57 + return name;
  58 + }
  59 +
  60 + public void setName(String name)
  61 + {
  62 + this.name = name;
  63 + }
  64 +
  65 + public String getTitle()
  66 + {
  67 + return title;
  68 + }
  69 +
  70 + public void setTitle(String title)
  71 + {
  72 + this.title = title;
  73 + }
  74 +
  75 + public boolean isChecked()
  76 + {
  77 + return checked;
  78 + }
  79 +
  80 + public void setChecked(boolean checked)
  81 + {
  82 + this.checked = checked;
  83 + }
  84 +
  85 + public boolean isOpen()
  86 + {
  87 + return open;
  88 + }
  89 +
  90 + public void setOpen(boolean open)
  91 + {
  92 + this.open = open;
  93 + }
  94 +
  95 + public boolean isNocheck()
  96 + {
  97 + return nocheck;
  98 + }
  99 +
  100 + public void setNocheck(boolean nocheck)
  101 + {
  102 + this.nocheck = nocheck;
  103 + }
  104 +}
... ...
src/main/java/com/huaheng/framework/web/page/TableDataInfo.java
... ... @@ -8,8 +8,7 @@ import java.util.List;
8 8 *
9 9 * @author huaheng
10 10 */
11   -public class TableDataInfo implements Serializable
12   -{
  11 +public class TableDataInfo implements Serializable {
13 12 private static final long serialVersionUID = 1L;
14 13 /** 总记录数 */
15 14 private long total;
... ...
src/main/java/com/huaheng/mobile/receipt/MobileBatchReceiptController.java
... ... @@ -507,7 +507,7 @@ public class MobileBatchReceiptController {
507 507 container.setWarehouseCode(ShiroUtils.getWarehouseCode());
508 508 LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(container);
509 509 container = containerService.getOne(lambdaQueryWrapper);
510   - if(container==null) {
  510 + if(container == null) {
511 511 return AjaxResult.error("容器不存在");
512 512 }
513 513 if (!StringUtils.isNotEmpty(container.getLocationCode())) {
... ... @@ -532,7 +532,7 @@ public class MobileBatchReceiptController {
532 532 }
533 533 //判断托盘是否已经存在任务
534 534 LambdaQueryWrapper<TaskHeader> headerQueryWrapper = Wrappers.lambdaQuery();
535   - headerQueryWrapper.ne(TaskHeader::getStatus, 100)
  535 + headerQueryWrapper.ne(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_COMPLETED.intValue())
536 536 .eq(TaskHeader::getContainerCode, containerCode);
537 537 Integer taskCount = taskHeaderService.count(headerQueryWrapper);
538 538 if (taskCount != null && taskCount.intValue() > 0) {
... ... @@ -543,7 +543,7 @@ public class MobileBatchReceiptController {
543 543 TaskHeader taskHeader = new TaskHeader();
544 544 taskHeader.setWarehouseCode(loc.getWarehouseCode());
545 545 taskHeader.setCompanyCode(companyCode);//货主
546   - if(type == 200) {
  546 + if(type == QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT.intValue()) {
547 547 taskHeader.setInternalTaskType(QuantityConstant.TASK_INTENERTYPE_SHELF);
548 548 taskHeader.setTaskType(QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT);
549 549 } else {
... ...
src/main/java/com/huaheng/pc/system/dict/controller/DictTypeController.java
... ... @@ -2,6 +2,7 @@ package com.huaheng.pc.system.dict.controller;
2 2  
3 3 import java.util.List;
4 4  
  5 +import com.huaheng.framework.web.domain.Ztree;
5 6 import com.huaheng.framework.web.service.DictService;
6 7 import org.apache.shiro.authz.annotation.RequiresPermissions;
7 8 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -142,4 +143,26 @@ public class DictTypeController extends BaseController {
142 143 }
143 144 return Integer.valueOf(uniqueFlag);
144 145 }
  146 +
  147 + /**
  148 + * 选择字典树
  149 + */
  150 + @GetMapping("/selectDictTree/{columnId}/{dictType}")
  151 + public String selectDeptTree(@PathVariable("columnId") Long columnId, @PathVariable("dictType") String dictType,
  152 + ModelMap mmap) {
  153 + mmap.put("columnId", columnId);
  154 + mmap.put("dict", dictTypeService.selectDictTypeByType(dictType));
  155 + return prefix + "/tree";
  156 + }
  157 +
  158 + /**
  159 + * 加载字典列表树
  160 + */
  161 + @GetMapping("/treeData")
  162 + @ResponseBody
  163 + public List<Ztree> treeData() {
  164 + List<Ztree> ztrees = dictTypeService.selectDictTree(new DictType());
  165 + return ztrees;
  166 + }
  167 +
145 168 }
... ...
src/main/java/com/huaheng/pc/system/dict/mapper/DictTypeMapper.java
... ... @@ -23,6 +23,14 @@ public interface DictTypeMapper
23 23 public List<DictType> selectDictTypeList(DictType dictType);
24 24  
25 25 /**
  26 + * 根据字典类型查询信息
  27 + *
  28 + * @param dictType 字典类型
  29 + * @return 字典类型
  30 + */
  31 + public DictType selectDictTypeByType(String dictType);
  32 +
  33 + /**
26 34 * 根据所有字典类型
27 35 *
28 36 * @return 字典类型集合信息
... ...
src/main/java/com/huaheng/pc/system/dict/service/DictTypeServiceImpl.java
1 1 package com.huaheng.pc.system.dict.service;
2 2  
3 3 import com.huaheng.common.exception.service.ServiceException;
  4 +import com.huaheng.framework.web.domain.Ztree;
4 5 import org.apache.ibatis.annotations.Param;
5 6 import org.springframework.beans.factory.annotation.Autowired;
6 7 import org.springframework.stereotype.Service;
... ... @@ -46,6 +47,17 @@ public class DictTypeServiceImpl implements IDictTypeService
46 47 }
47 48  
48 49 /**
  50 + * 根据字典类型查询信息
  51 + *
  52 + * @param dictType 字典类型
  53 + * @return 字典类型
  54 + */
  55 + @Override
  56 + public DictType selectDictTypeByType(String dictType) {
  57 + return dictTypeMapper.selectDictTypeByType(dictType);
  58 + }
  59 +
  60 + /**
49 61 * 根据所有字典类型
50 62 *
51 63 * @return 字典类型集合信息
... ... @@ -204,4 +216,33 @@ public class DictTypeServiceImpl implements IDictTypeService
204 216 }
205 217 return true;
206 218 }
  219 +
  220 + /**
  221 + * 查询字典类型树
  222 + *
  223 + * @param dictType 字典类型
  224 + * @return 所有字典类型
  225 + */
  226 + @Override
  227 + public List<Ztree> selectDictTree(DictType dictType) {
  228 + List<Ztree> ztrees = new ArrayList<Ztree>();
  229 + List<DictType> dictList = dictTypeMapper.selectDictTypeList(dictType);
  230 + for (DictType dict : dictList) {
  231 + if (dict.getEnable()) {
  232 + Ztree ztree = new Ztree();
  233 + ztree.setId(Long.valueOf(dict.getId()));
  234 + ztree.setName(transDictName(dict));
  235 + ztree.setTitle(dict.getDictType());
  236 + ztrees.add(ztree);
  237 + }
  238 + }
  239 + return ztrees;
  240 + }
  241 +
  242 + public String transDictName(DictType dictType) {
  243 + StringBuffer sb = new StringBuffer();
  244 + sb.append("(" + dictType.getDictName() + ")");
  245 + sb.append("&nbsp;&nbsp;&nbsp;" + dictType.getDictType());
  246 + return sb.toString();
  247 + }
207 248 }
... ...
src/main/java/com/huaheng/pc/system/dict/service/IDictTypeService.java
1 1 package com.huaheng.pc.system.dict.service;
2 2  
  3 +import com.huaheng.framework.web.domain.Ztree;
3 4 import com.huaheng.pc.system.dict.domain.DictType;
4 5 import org.apache.ibatis.annotations.Param;
5 6  
... ... @@ -22,6 +23,14 @@ public interface IDictTypeService
22 23 public List<DictType> selectDictTypeList(DictType dictType);
23 24  
24 25 /**
  26 + * 根据字典类型查询信息
  27 + *
  28 + * @param dictType 字典类型
  29 + * @return 字典类型
  30 + */
  31 + public DictType selectDictTypeByType(String dictType);
  32 +
  33 + /**
25 34 * 根据所有字典类型
26 35 *
27 36 * @return 字典类型集合信息
... ... @@ -99,4 +108,12 @@ public interface IDictTypeService
99 108  
100 109 //复制字典数据
101 110 Boolean dictTypeCopy(String code,String newCode);
  111 +
  112 + /**
  113 + * 查询字典类型树
  114 + *
  115 + * @param dictType 字典类型
  116 + * @return 所有字典类型
  117 + */
  118 + public List<Ztree> selectDictTree(DictType dictType);
102 119 }
... ...
src/main/java/com/huaheng/pc/task/taskHeader/service/TaskHeaderServiceImpl.java
... ... @@ -677,7 +677,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
677 677 if (task.getInternalTaskType().equals(QuantityConstant.TASK_INTENERTYPE_SHELF) ) {
678 678 //入库任务
679 679 this.completeReceiptTask(task);
680   -// combineInventory(task);
  680 + combineInventory(task);
681 681 }
682 682 if (task.getInternalTaskType().equals(QuantityConstant.TASK_INTENERTYPE_PICKING) &&
683 683 (task.getTaskType().equals(QuantityConstant.TASK_TYPE_WHOLESHIPMENT) || task.getTaskType().equals(QuantityConstant.TASK_TYPE_SORTINGSHIPMENT))) {
... ... @@ -719,7 +719,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
719 719 }
720 720 LambdaQueryWrapper<InventoryHeader> inventoryHeaderErapper = Wrappers.lambdaQuery();
721 721 inventoryHeaderErapper.eq(InventoryHeader::getWarehouseCode, ShiroUtils.getWarehouseCode())
722   - .eq(InventoryHeader::getLocationCode, task.getFromLocation())
  722 + .eq(InventoryHeader::getLocationCode, task.getToLocation())
723 723 .eq(InventoryHeader::getContainerCode, task.getContainerCode());
724 724 InventoryHeader header = inventoryHeaderService.getOne(inventoryHeaderErapper);
725 725  
... ... @@ -747,12 +747,12 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
747 747 //将未完成的任务数量更新到库存表
748 748 if (DataUtils.getInteger(map.get("status")) < QuantityConstant.TASK_STATUS_COMPLETED) {
749 749  
750   -
751 750 LambdaQueryWrapper<InventoryDetail> inventory = Wrappers.lambdaQuery();
752 751 inventory.eq(InventoryDetail::getWarehouseCode, ShiroUtils.getWarehouseCode())
753   - .eq(InventoryDetail::getLocationCode, task.getFromLocation())
  752 + .eq(InventoryDetail::getLocationCode, task.getToLocation())
754 753 .eq(InventoryDetail::getMaterialCode, DataUtils.getString(map.get("materialCode")))
755   - .eq(InventoryDetail::getContainerCode, DataUtils.getString(map.get("containerCode")));
  754 + .eq(InventoryDetail::getContainerCode, DataUtils.getString(map.get("containerCode")))
  755 + .eq(InventoryDetail::getContainerCode, DataUtils.getString(map.get("batch")));
756 756 InventoryDetail detail = inventoryDetailService.getOne(inventory);
757 757 if (detail == null) {
758 758 //库存明细添加
... ... @@ -892,21 +892,41 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
892 892 return AjaxResult.success("完成入库任务");
893 893 }
894 894  
895   -// private void combineInventory(TaskHeader task) {
896   -// LambdaQueryWrapper<InventoryHeader> inventoryHeaderErapper = Wrappers.lambdaQuery();
897   -// inventoryHeaderErapper.eq(InventoryHeader::getWarehouseCode, ShiroUtils.getWarehouseCode())
898   -// .eq(InventoryHeader::getLocationCode, task.getFromLocation())
899   -// .eq(InventoryHeader::getContainerCode, task.getContainerCode());
900   -// InventoryHeader header = inventoryHeaderService.getOne(inventoryHeaderErapper);
901   -// if(header != null) {
902   -// LambdaQueryWrapper<InventoryDetail> inventory = Wrappers.lambdaQuery();
903   -// inventory.eq(InventoryDetail::getWarehouseCode, ShiroUtils.getWarehouseCode())
904   -// .eq(InventoryDetail::getLocationCode, task.getFromLocation())
905   -// .eq(InventoryDetail::getMaterialCode, DataUtils.getString(map.get("materialCode")))
906   -// .eq(InventoryDetail::getContainerCode, DataUtils.getString(map.get("containerCode")));
907   -// List<InventoryDetail> detail = inventoryDetailService.list(inventory);
908   -// }
909   -// }
  895 + @Transactional(rollbackFor = Exception.class)
  896 + public void combineInventory(TaskHeader task) {
  897 + LambdaQueryWrapper<InventoryHeader> inventoryHeaderErapper = Wrappers.lambdaQuery();
  898 + inventoryHeaderErapper.eq(InventoryHeader::getWarehouseCode, ShiroUtils.getWarehouseCode())
  899 + .eq(InventoryHeader::getLocationCode, task.getToLocation())
  900 + .eq(InventoryHeader::getContainerCode, task.getContainerCode());
  901 + InventoryHeader header = inventoryHeaderService.getOne(inventoryHeaderErapper);
  902 + if(header != null) {
  903 + LambdaQueryWrapper<InventoryDetail> inventory = Wrappers.lambdaQuery();
  904 + inventory.eq(InventoryDetail::getWarehouseCode, ShiroUtils.getWarehouseCode())
  905 + .eq(InventoryDetail::getLocationCode, task.getFromLocation())
  906 + .eq(InventoryDetail::getContainerCode, task.getContainerCode());
  907 + List<InventoryDetail> inventoryDetailList = inventoryDetailService.list(inventory);
  908 + for(int i=0; i < inventoryDetailList.size() -1; i++) {
  909 + for(int j = inventoryDetailList.size() - 1; j > i; j--) {
  910 + if(inventoryDetailList.get(i).getMaterialCode().equals(inventoryDetailList.get(j).getMaterialCode())) {
  911 + BigDecimal totalQty = inventoryDetailList.get(i).getQty().add(inventoryDetailList.get(j).getQty());
  912 + inventoryDetailList.get(i).setQty(totalQty);
  913 + inventoryDetailList.remove(j);
  914 + LambdaQueryWrapper<InventoryDetail> wrapper = Wrappers.lambdaQuery();
  915 + wrapper.eq(InventoryDetail::getId, inventoryDetailList.get(i).getId());
  916 + inventoryDetailService.update(inventoryDetailList.get(i), wrapper);
  917 + }
  918 + }
  919 + }
  920 + BigDecimal totalQty = new BigDecimal(0);
  921 + for(InventoryDetail inventoryDetail : inventoryDetailList) {
  922 + totalQty = totalQty.add(inventoryDetail.getQty());
  923 + }
  924 + header.setTotalQty(totalQty);
  925 + LambdaQueryWrapper<InventoryHeader> wrapper = Wrappers.lambdaQuery();
  926 + wrapper.eq(InventoryHeader::getId, header.getId());
  927 + inventoryHeaderService.update(header, wrapper);
  928 + }
  929 + }
910 930  
911 931 /**
912 932 * 移动端创建入库任务
... ...
src/main/java/com/huaheng/pc/tool/gen/controller/GenController.java
1 1 package com.huaheng.pc.tool.gen.controller;
2 2  
3   -import java.io.IOException;
4   -import java.util.List;
5   -import javax.servlet.http.HttpServletResponse;
  3 +import com.alibaba.fastjson.JSON;
  4 +import com.huaheng.common.support.Convert;
  5 +import com.huaheng.common.utils.StringUtils;
  6 +import com.huaheng.common.utils.security.ShiroUtils;
  7 +import com.huaheng.framework.web.controller.BaseController;
  8 +import com.huaheng.framework.web.domain.AjaxResult;
  9 +import com.huaheng.framework.web.page.TableDataInfo;
  10 +import com.huaheng.pc.tool.gen.domain.CxSelect;
  11 +import com.huaheng.pc.tool.gen.domain.GenTable;
  12 +import com.huaheng.pc.tool.gen.domain.GenTableColumn;
  13 +import com.huaheng.pc.tool.gen.service.IGenTableColumnService;
  14 +import com.huaheng.pc.tool.gen.service.IGenTableService;
6 15 import org.apache.commons.io.IOUtils;
7 16 import org.apache.shiro.authz.annotation.RequiresPermissions;
8 17 import org.springframework.beans.factory.annotation.Autowired;
9 18 import org.springframework.stereotype.Controller;
10   -import org.springframework.web.bind.annotation.GetMapping;
11   -import org.springframework.web.bind.annotation.PathVariable;
12   -import org.springframework.web.bind.annotation.PostMapping;
13   -import org.springframework.web.bind.annotation.RequestMapping;
14   -import org.springframework.web.bind.annotation.ResponseBody;
15   -import com.huaheng.common.support.Convert;
16   -import com.huaheng.framework.aspectj.lang.annotation.Log;
17   -import com.huaheng.framework.aspectj.lang.constant.BusinessType;
18   -import com.huaheng.framework.web.controller.BaseController;
19   -import com.huaheng.framework.web.page.TableDataInfo;
20   -import com.huaheng.pc.tool.gen.domain.TableInfo;
21   -import com.huaheng.pc.tool.gen.service.IGenService;
  19 +import org.springframework.ui.ModelMap;
  20 +import org.springframework.validation.annotation.Validated;
  21 +import org.springframework.web.bind.annotation.*;
  22 +
  23 +import javax.servlet.http.HttpServletResponse;
  24 +import java.io.IOException;
  25 +import java.util.ArrayList;
  26 +import java.util.List;
  27 +import java.util.Map;
22 28  
23 29 /**
24 30 * 代码生成 操作处理
25   - *
26   - * @author huaheng
  31 + *
  32 + * @author ruoyi
27 33 */
28 34 @Controller
29 35 @RequestMapping("/tool/gen")
30   -public class GenController extends BaseController
31   -{
  36 +public class GenController extends BaseController {
32 37 private String prefix = "tool/gen";
33 38  
34 39 @Autowired
35   - private IGenService genService;
  40 + private IGenTableService genTableService;
  41 +
  42 + @Autowired
  43 + private IGenTableColumnService genTableColumnService;
36 44  
37 45 @RequiresPermissions("tool:gen:view")
38 46 @GetMapping()
39   - public String gen()
40   - {
  47 + public String gen() {
41 48 return prefix + "/gen";
42 49 }
43 50  
  51 + /**
  52 + * 查询代码生成列表
  53 + */
44 54 @RequiresPermissions("tool:gen:list")
45 55 @PostMapping("/list")
46 56 @ResponseBody
47   - public TableDataInfo list(TableInfo tableInfo)
48   - {
  57 + public TableDataInfo genList(GenTable genTable) {
  58 + startPage();
  59 + List<GenTable> list = genTableService.selectGenTableList(genTable);
  60 + return getDataTable(list);
  61 + }
  62 +
  63 + /**
  64 + * 查询数据库列表
  65 + */
  66 + @RequiresPermissions("tool:gen:list")
  67 + @PostMapping("/db/list")
  68 + @ResponseBody
  69 + public TableDataInfo dataList(GenTable genTable) {
49 70 startPage();
50   - List<TableInfo> list = genService.selectTableList(tableInfo);
  71 + List<GenTable> list = genTableService.selectDbTableList(genTable);
51 72 return getDataTable(list);
52 73 }
53 74  
54 75 /**
  76 + * 查询数据表字段列表
  77 + */
  78 + @RequiresPermissions("tool:gen:list")
  79 + @PostMapping("/column/list")
  80 + @ResponseBody
  81 + public TableDataInfo columnList(GenTableColumn genTableColumn) {
  82 + TableDataInfo dataInfo = new TableDataInfo();
  83 + List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(genTableColumn);
  84 + dataInfo.setData(list);
  85 + dataInfo.setTotal(list.size());
  86 + dataInfo.setCode(200);
  87 + return dataInfo;
  88 + }
  89 +
  90 + /**
  91 + * 导入表结构
  92 + */
  93 + @RequiresPermissions("tool:gen:list")
  94 + @GetMapping("/importTable")
  95 + public String importTable() {
  96 + return prefix + "/importTable";
  97 + }
  98 +
  99 + /**
  100 + * 导入表结构(保存)
  101 + */
  102 + @RequiresPermissions("tool:gen:list")
  103 + @PostMapping("/importTable")
  104 + @ResponseBody
  105 + public AjaxResult importTableSave(String tables) {
  106 + String[] tableNames = Convert.toStrArray(tables);
  107 + // 查询表信息
  108 + List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames);
  109 + String operName = ShiroUtils.getLoginName();
  110 + genTableService.importGenTable(tableList, operName);
  111 + return AjaxResult.success();
  112 + }
  113 +
  114 + /**
  115 + * 修改代码生成业务
  116 + */
  117 + @GetMapping("/edit/{tableId}")
  118 + public String edit(@PathVariable("tableId") Long tableId, ModelMap mmap) {
  119 + GenTable table = genTableService.selectGenTableById(tableId);
  120 + List<GenTable> genTables = genTableService.selectGenTableAll();
  121 + List<CxSelect> cxSelect = new ArrayList<CxSelect>();
  122 + for (GenTable genTable : genTables) {
  123 + if (!StringUtils.equals(table.getTableName(), genTable.getTableName())) {
  124 + CxSelect cxTable = new CxSelect(genTable.getTableName(), genTable.getTableName() + ':' + genTable.getTableComment());
  125 + List<CxSelect> cxColumns = new ArrayList<CxSelect>();
  126 + for (GenTableColumn tableColumn : genTable.getColumns()) {
  127 + cxColumns.add(new CxSelect(tableColumn.getColumnName(), tableColumn.getColumnName() + ':' + tableColumn.getColumnComment()));
  128 + }
  129 + cxTable.setS(cxColumns);
  130 + cxSelect.add(cxTable);
  131 + }
  132 + }
  133 + mmap.put("table", table);
  134 + mmap.put("data", JSON.toJSON(cxSelect));
  135 + return prefix + "/edit";
  136 + }
  137 +
  138 + /**
  139 + * 修改保存代码生成业务
  140 + */
  141 + @RequiresPermissions("tool:gen:edit")
  142 + @PostMapping("/edit")
  143 + @ResponseBody
  144 + public AjaxResult editSave(@Validated GenTable genTable) {
  145 + genTableService.validateEdit(genTable);
  146 + genTableService.updateGenTable(genTable);
  147 + return AjaxResult.success();
  148 + }
  149 +
  150 + @RequiresPermissions("tool:gen:remove")
  151 + @PostMapping("/remove")
  152 + @ResponseBody
  153 + public AjaxResult remove(String ids) {
  154 + genTableService.deleteGenTableByIds(ids);
  155 + return AjaxResult.success();
  156 + }
  157 +
  158 + /**
  159 + * 预览代码
  160 + */
  161 + @RequiresPermissions("tool:gen:preview")
  162 + @GetMapping("/preview/{tableId}")
  163 + @ResponseBody
  164 + public AjaxResult preview(@PathVariable("tableId") Long tableId) throws IOException {
  165 + Map<String, String> dataMap = genTableService.previewCode(tableId);
  166 + return AjaxResult.success(dataMap);
  167 + }
  168 +
  169 + /**
55 170 * 生成代码
56 171 */
57 172 @RequiresPermissions("tool:gen:code")
58   - @Log(title = "系统工具-代码生成", operating = "生成代码", action = BusinessType.GENCODE)
59 173 @GetMapping("/genCode/{tableName}")
60   - public void genCode(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException
61   - {
62   - byte[] data = genService.generatorCode(tableName);
63   - response.reset();
64   - response.setHeader("Content-Disposition", "attachment; filename=\"huaheng.zip\"");
65   - response.addHeader("Content-Length", "" + data.length);
66   - response.setContentType("application/octet-stream; charset=UTF-8");
67   -
68   - IOUtils.write(data, response.getOutputStream());
  174 + public void genCode(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException {
  175 + byte[] data = genTableService.generatorCode(tableName);
  176 + genCode(response, data);
69 177 }
70 178  
71 179 /**
72 180 * 批量生成代码
73 181 */
74 182 @RequiresPermissions("tool:gen:code")
75   - @Log(title = "系统工具-代码生成", operating = "批量代码生成", action = BusinessType.GENCODE)
76 183 @GetMapping("/batchGenCode")
77 184 @ResponseBody
78   - public void batchGenCode(HttpServletResponse response, String tables) throws IOException
79   - {
  185 + public void batchGenCode(HttpServletResponse response, String tables) throws IOException {
80 186 String[] tableNames = Convert.toStrArray(tables);
81   - byte[] data = genService.generatorCode(tableNames);
  187 + byte[] data = genTableService.generatorCode(tableNames);
  188 + genCode(response, data);
  189 + }
  190 +
  191 + /**
  192 + * 生成zip文件
  193 + */
  194 + private void genCode(HttpServletResponse response, byte[] data) throws IOException {
82 195 response.reset();
83 196 response.setHeader("Content-Disposition", "attachment; filename=\"huaheng.zip\"");
84 197 response.addHeader("Content-Length", "" + data.length);
85 198 response.setContentType("application/octet-stream; charset=UTF-8");
86   -
87 199 IOUtils.write(data, response.getOutputStream());
88 200 }
89 201 -}
  202 +}
90 203 \ No newline at end of file
... ...
src/main/java/com/huaheng/pc/tool/gen/domain/ColumnInfo.java deleted
1   -package com.huaheng.pc.tool.gen.domain;
2   -
3   -/**
4   - * ry数据库表列信息
5   - *
6   - * @author huaheng
7   - */
8   -public class ColumnInfo
9   -{
10   - /** 表名称 */
11   - private String tableName;
12   - /** 字段名称 */
13   - private String columnName;
14   - /** 字段类型 */
15   - private String dataType;
16   - /** 字段是否可为null */
17   - private String isNullable;
18   - /** 列默认值 */
19   - private String columnDefault;
20   - /** 列描述 */
21   - private String columnComment;
22   - /** Java属性类型 */
23   - private String attrType;
24   - /** Java属性名称(第一个字母大写),如:userName => UserName */
25   - private String attrName;
26   - /** Java属性名称(第一个字母小写),如:userName => userName */
27   - private String attrname;
28   -
29   - public String getTableName() {
30   - return tableName;
31   - }
32   -
33   - public void setTableName(String tableName) {
34   - this.tableName = tableName;
35   - }
36   -
37   - public String getIsNullable() {
38   - return isNullable;
39   - }
40   -
41   - public void setIsNullable(String isNullable) {
42   - this.isNullable = isNullable;
43   - }
44   -
45   - public String getColumnDefault() {
46   - return columnDefault;
47   - }
48   -
49   - public void setColumnDefault(String columnDefault) {
50   - this.columnDefault = columnDefault;
51   - }
52   -
53   - public String getColumnName()
54   - {
55   - return columnName;
56   - }
57   -
58   - public void setColumnName(String columnName)
59   - {
60   - this.columnName = columnName;
61   - }
62   -
63   - public String getDataType()
64   - {
65   - return dataType;
66   - }
67   -
68   - public void setDataType(String dataType)
69   - {
70   - this.dataType = dataType;
71   - }
72   -
73   - public String getColumnComment()
74   - {
75   - return columnComment;
76   - }
77   -
78   - public void setColumnComment(String columnComment)
79   - {
80   - this.columnComment = columnComment;
81   - }
82   -
83   - public String getAttrName()
84   - {
85   - return attrName;
86   - }
87   -
88   - public void setAttrName(String attrName)
89   - {
90   - this.attrName = attrName;
91   - }
92   -
93   - public String getAttrname()
94   - {
95   - return attrname;
96   - }
97   -
98   - public void setAttrname(String attrname)
99   - {
100   - this.attrname = attrname;
101   - }
102   -
103   - public String getAttrType()
104   - {
105   - return attrType;
106   - }
107   -
108   - public void setAttrType(String attrType)
109   - {
110   - this.attrType = attrType;
111   - }
112   -
113   -}
src/main/java/com/huaheng/pc/tool/gen/domain/CxSelect.java 0 → 100644
  1 +package com.huaheng.pc.tool.gen.domain;
  2 +
  3 +import java.io.Serializable;
  4 +import java.util.List;
  5 +
  6 +/**
  7 + * CxSelect树结构实体类
  8 + */
  9 +public class CxSelect implements Serializable {
  10 + private static final long serialVersionUID = 1L;
  11 +
  12 + /**
  13 + * 数据值字段名称
  14 + */
  15 + private String v;
  16 +
  17 + /**
  18 + * 数据标题字段名称
  19 + */
  20 + private String n;
  21 +
  22 + /**
  23 + * 子集数据字段名称
  24 + */
  25 + private List<CxSelect> s;
  26 +
  27 + public CxSelect() {
  28 + }
  29 +
  30 + public CxSelect(String v, String n) {
  31 + this.v = v;
  32 + this.n = n;
  33 + }
  34 +
  35 + public List<CxSelect> getS() {
  36 + return s;
  37 + }
  38 +
  39 + public void setN(String n) {
  40 + this.n = n;
  41 + }
  42 +
  43 + public String getN() {
  44 + return n;
  45 + }
  46 +
  47 + public void setS(List<CxSelect> s) {
  48 + this.s = s;
  49 + }
  50 +
  51 + public String getV() {
  52 + return v;
  53 + }
  54 +
  55 + public void setV(String v) {
  56 + this.v = v;
  57 + }
  58 +}
... ...
src/main/java/com/huaheng/pc/tool/gen/domain/GenTable.java 0 → 100644
  1 +package com.huaheng.pc.tool.gen.domain;
  2 +
  3 +import java.util.List;
  4 +import javax.validation.Valid;
  5 +import javax.validation.constraints.NotBlank;
  6 +
  7 +import com.huaheng.common.constant.GenConstants;
  8 +import com.huaheng.common.utils.StringUtils;
  9 +import com.huaheng.framework.web.domain.BaseEntity;
  10 +import com.huaheng.pc.tool.gen.domain.GenTableColumn;
  11 +import org.apache.commons.lang3.ArrayUtils;
  12 +
  13 +
  14 +/**
  15 + * 业务表 gen_table
  16 + */
  17 +public class GenTable extends BaseEntity {
  18 + private static final long serialVersionUID = 1L;
  19 +
  20 + /**
  21 + * 编号
  22 + */
  23 + private Long tableId;
  24 +
  25 + /**
  26 + * 表名称
  27 + */
  28 + @NotBlank(message = "表名称不能为空")
  29 + private String tableName;
  30 +
  31 + /**
  32 + * 表描述
  33 + */
  34 + @NotBlank(message = "表描述不能为空")
  35 + private String tableComment;
  36 +
  37 + /**
  38 + * 关联父表的表名
  39 + */
  40 + private String subTableName;
  41 +
  42 + /**
  43 + * 本表关联父表的外键名
  44 + */
  45 + private String subTableFkName;
  46 +
  47 + /**
  48 + * 实体类名称(首字母大写)
  49 + */
  50 + @NotBlank(message = "实体类名称不能为空")
  51 + private String className;
  52 +
  53 + /**
  54 + * 使用的模板(crud单表操作 tree树表操作 sub主子表操作)
  55 + */
  56 + private String tplCategory;
  57 +
  58 + /**
  59 + * 生成包路径
  60 + */
  61 + @NotBlank(message = "生成包路径不能为空")
  62 + private String packageName;
  63 +
  64 + /**
  65 + * 生成模块名
  66 + */
  67 + @NotBlank(message = "生成模块名不能为空")
  68 + private String moduleName;
  69 +
  70 + /**
  71 + * 生成业务名
  72 + */
  73 + @NotBlank(message = "生成业务名不能为空")
  74 + private String businessName;
  75 +
  76 + /**
  77 + * 生成功能名
  78 + */
  79 + @NotBlank(message = "生成功能名不能为空")
  80 + private String functionName;
  81 +
  82 + /**
  83 + * 生成作者
  84 + */
  85 + @NotBlank(message = "作者不能为空")
  86 + private String functionAuthor;
  87 +
  88 + /**
  89 + * 主键信息
  90 + */
  91 + private GenTableColumn pkColumn;
  92 +
  93 + /**
  94 + * 子表信息
  95 + */
  96 + private GenTable subTable;
  97 +
  98 + /**
  99 + * 表列信息
  100 + */
  101 + @Valid
  102 + private List<GenTableColumn> columns;
  103 +
  104 + /**
  105 + * 其它生成选项
  106 + */
  107 + private String options;
  108 +
  109 + /**
  110 + * 树编码字段
  111 + */
  112 + private String treeCode;
  113 +
  114 + /**
  115 + * 树父编码字段
  116 + */
  117 + private String treeParentCode;
  118 +
  119 + /**
  120 + * 树名称字段
  121 + */
  122 + private String treeName;
  123 +
  124 + public Long getTableId() {
  125 + return tableId;
  126 + }
  127 +
  128 + public void setTableId(Long tableId) {
  129 + this.tableId = tableId;
  130 + }
  131 +
  132 + public String getTableName() {
  133 + return tableName;
  134 + }
  135 +
  136 + public void setTableName(String tableName) {
  137 + this.tableName = tableName;
  138 + }
  139 +
  140 + public String getTableComment() {
  141 + return tableComment;
  142 + }
  143 +
  144 + public void setTableComment(String tableComment) {
  145 + this.tableComment = tableComment;
  146 + }
  147 +
  148 + public String getSubTableName() {
  149 + return subTableName;
  150 + }
  151 +
  152 + public void setSubTableName(String subTableName) {
  153 + this.subTableName = subTableName;
  154 + }
  155 +
  156 + public String getSubTableFkName() {
  157 + return subTableFkName;
  158 + }
  159 +
  160 + public void setSubTableFkName(String subTableFkName) {
  161 + this.subTableFkName = subTableFkName;
  162 + }
  163 +
  164 + public String getClassName() {
  165 + return className;
  166 + }
  167 +
  168 + public void setClassName(String className) {
  169 + this.className = className;
  170 + }
  171 +
  172 + public String getTplCategory() {
  173 + return tplCategory;
  174 + }
  175 +
  176 + public void setTplCategory(String tplCategory) {
  177 + this.tplCategory = tplCategory;
  178 + }
  179 +
  180 + public String getPackageName() {
  181 + return packageName;
  182 + }
  183 +
  184 + public void setPackageName(String packageName) {
  185 + this.packageName = packageName;
  186 + }
  187 +
  188 + public String getModuleName() {
  189 + return moduleName;
  190 + }
  191 +
  192 + public void setModuleName(String moduleName) {
  193 + this.moduleName = moduleName;
  194 + }
  195 +
  196 + public String getBusinessName() {
  197 + return businessName;
  198 + }
  199 +
  200 + public void setBusinessName(String businessName) {
  201 + this.businessName = businessName;
  202 + }
  203 +
  204 + public String getFunctionName() {
  205 + return functionName;
  206 + }
  207 +
  208 + public void setFunctionName(String functionName) {
  209 + this.functionName = functionName;
  210 + }
  211 +
  212 + public String getFunctionAuthor() {
  213 + return functionAuthor;
  214 + }
  215 +
  216 + public void setFunctionAuthor(String functionAuthor) {
  217 + this.functionAuthor = functionAuthor;
  218 + }
  219 +
  220 + public GenTableColumn getPkColumn() {
  221 + return pkColumn;
  222 + }
  223 +
  224 + public void setPkColumn(GenTableColumn pkColumn) {
  225 + this.pkColumn = pkColumn;
  226 + }
  227 +
  228 + public GenTable getSubTable() {
  229 + return subTable;
  230 + }
  231 +
  232 + public void setSubTable(GenTable subTable) {
  233 + this.subTable = subTable;
  234 + }
  235 +
  236 + public List<GenTableColumn> getColumns() {
  237 + return columns;
  238 + }
  239 +
  240 + public void setColumns(List<GenTableColumn> columns) {
  241 + this.columns = columns;
  242 + }
  243 +
  244 + public String getOptions() {
  245 + return options;
  246 + }
  247 +
  248 + public void setOptions(String options) {
  249 + this.options = options;
  250 + }
  251 +
  252 + public String getTreeCode() {
  253 + return treeCode;
  254 + }
  255 +
  256 + public void setTreeCode(String treeCode) {
  257 + this.treeCode = treeCode;
  258 + }
  259 +
  260 + public String getTreeParentCode() {
  261 + return treeParentCode;
  262 + }
  263 +
  264 + public void setTreeParentCode(String treeParentCode) {
  265 + this.treeParentCode = treeParentCode;
  266 + }
  267 +
  268 + public String getTreeName() {
  269 + return treeName;
  270 + }
  271 +
  272 + public void setTreeName(String treeName) {
  273 + this.treeName = treeName;
  274 + }
  275 +
  276 + public boolean isSub() {
  277 + return isSub(this.tplCategory);
  278 + }
  279 +
  280 + public static boolean isSub(String tplCategory) {
  281 + return tplCategory != null && StringUtils.equals(GenConstants.TPL_SUB, tplCategory);
  282 + }
  283 +
  284 + public boolean isTree() {
  285 + return isTree(this.tplCategory);
  286 + }
  287 +
  288 + public static boolean isTree(String tplCategory) {
  289 + return tplCategory != null && StringUtils.equals(GenConstants.TPL_TREE, tplCategory);
  290 + }
  291 +
  292 + public boolean isCrud() {
  293 + return isCrud(this.tplCategory);
  294 + }
  295 +
  296 + public static boolean isCrud(String tplCategory) {
  297 + return tplCategory != null && StringUtils.equals(GenConstants.TPL_CRUD, tplCategory);
  298 + }
  299 +
  300 + public boolean isSuperColumn(String javaField) {
  301 + return isSuperColumn(this.tplCategory, javaField);
  302 + }
  303 +
  304 + public static boolean isSuperColumn(String tplCategory, String javaField) {
  305 + if (isTree(tplCategory)) {
  306 + return StringUtils.equalsAnyIgnoreCase(javaField,
  307 + ArrayUtils.addAll(GenConstants.TREE_ENTITY, GenConstants.BASE_ENTITY));
  308 + }
  309 + return StringUtils.equalsAnyIgnoreCase(javaField, GenConstants.BASE_ENTITY);
  310 + }
  311 +}
0 312 \ No newline at end of file
... ...
src/main/java/com/huaheng/pc/tool/gen/domain/GenTableColumn.java 0 → 100644
  1 +package com.huaheng.pc.tool.gen.domain;
  2 +
  3 +import com.huaheng.common.utils.StringUtils;
  4 +import com.huaheng.framework.web.domain.BaseEntity;
  5 +
  6 +import javax.validation.constraints.NotBlank;
  7 +
  8 +/**
  9 + * 代码生成业务字段表 gen_table_column
  10 + */
  11 +public class GenTableColumn extends BaseEntity {
  12 + private static final long serialVersionUID = 1L;
  13 +
  14 + /**
  15 + * 编号
  16 + */
  17 + private Long columnId;
  18 +
  19 + /**
  20 + * 归属表编号
  21 + */
  22 + private Long tableId;
  23 +
  24 + /**
  25 + * 列名称
  26 + */
  27 + private String columnName;
  28 +
  29 + /**
  30 + * 列描述
  31 + */
  32 + private String columnComment;
  33 +
  34 + /**
  35 + * 列类型
  36 + */
  37 + private String columnType;
  38 +
  39 + /**
  40 + * JAVA类型
  41 + */
  42 + private String javaType;
  43 +
  44 + /**
  45 + * JAVA字段名
  46 + */
  47 + @NotBlank(message = "Java属性不能为空")
  48 + private String javaField;
  49 +
  50 + /**
  51 + * 是否主键(1是)
  52 + */
  53 + private String isPk;
  54 +
  55 + /**
  56 + * 是否自增(1是)
  57 + */
  58 + private String isIncrement;
  59 +
  60 + /**
  61 + * 是否必填(1是)
  62 + */
  63 + private String isRequired;
  64 +
  65 + /**
  66 + * 是否为插入字段(1是)
  67 + */
  68 + private String isInsert;
  69 +
  70 + /**
  71 + * 是否编辑字段(1是)
  72 + */
  73 + private String isEdit;
  74 +
  75 + /**
  76 + * 是否列表字段(1是)
  77 + */
  78 + private String isList;
  79 +
  80 + /**
  81 + * 是否查询字段(1是)
  82 + */
  83 + private String isQuery;
  84 +
  85 + /**
  86 + * 查询方式(EQ等于、NE不等于、GT大于、LT小于、LIKE模糊、BETWEEN范围)
  87 + */
  88 + private String queryType;
  89 +
  90 + /**
  91 + * 显示类型(input文本框、textarea文本域、select下拉框、checkbox复选框、radio单选框、datetime日期控件)
  92 + */
  93 + private String htmlType;
  94 +
  95 + /**
  96 + * 字典类型
  97 + */
  98 + private String dictType;
  99 +
  100 + /**
  101 + * 排序
  102 + */
  103 + private Integer sort;
  104 +
  105 + public void setColumnId(Long columnId) {
  106 + this.columnId = columnId;
  107 + }
  108 +
  109 + public Long getColumnId() {
  110 + return columnId;
  111 + }
  112 +
  113 + public void setTableId(Long tableId) {
  114 + this.tableId = tableId;
  115 + }
  116 +
  117 + public Long getTableId() {
  118 + return tableId;
  119 + }
  120 +
  121 + public void setColumnName(String columnName) {
  122 + this.columnName = columnName;
  123 + }
  124 +
  125 + public String getColumnName() {
  126 + return columnName;
  127 + }
  128 +
  129 + public void setColumnComment(String columnComment) {
  130 + this.columnComment = columnComment;
  131 + }
  132 +
  133 + public String getColumnComment() {
  134 + return columnComment;
  135 + }
  136 +
  137 + public void setColumnType(String columnType) {
  138 + this.columnType = columnType;
  139 + }
  140 +
  141 + public String getColumnType() {
  142 + return columnType;
  143 + }
  144 +
  145 + public void setJavaType(String javaType) {
  146 + this.javaType = javaType;
  147 + }
  148 +
  149 + public String getJavaType() {
  150 + return javaType;
  151 + }
  152 +
  153 + public void setJavaField(String javaField) {
  154 + this.javaField = javaField;
  155 + }
  156 +
  157 + public String getJavaField() {
  158 + return javaField;
  159 + }
  160 +
  161 + public String getCapJavaField() {
  162 + return StringUtils.capitalize(javaField);
  163 + }
  164 +
  165 + public void setIsPk(String isPk) {
  166 + this.isPk = isPk;
  167 + }
  168 +
  169 + public String getIsPk() {
  170 + return isPk;
  171 + }
  172 +
  173 + public boolean isPk() {
  174 + return isPk(this.isPk);
  175 + }
  176 +
  177 + public boolean isPk(String isPk) {
  178 + return isPk != null && StringUtils.equals("1", isPk);
  179 + }
  180 +
  181 + public String getIsIncrement() {
  182 + return isIncrement;
  183 + }
  184 +
  185 + public void setIsIncrement(String isIncrement) {
  186 + this.isIncrement = isIncrement;
  187 + }
  188 +
  189 + public boolean isIncrement() {
  190 + return isIncrement(this.isIncrement);
  191 + }
  192 +
  193 + public boolean isIncrement(String isIncrement) {
  194 + return isIncrement != null && StringUtils.equals("1", isIncrement);
  195 + }
  196 +
  197 + public void setIsRequired(String isRequired) {
  198 + this.isRequired = isRequired;
  199 + }
  200 +
  201 + public String getIsRequired() {
  202 + return isRequired;
  203 + }
  204 +
  205 + public boolean isRequired() {
  206 + return isRequired(this.isRequired);
  207 + }
  208 +
  209 + public boolean isRequired(String isRequired) {
  210 + return isRequired != null && StringUtils.equals("1", isRequired);
  211 + }
  212 +
  213 + public void setIsInsert(String isInsert) {
  214 + this.isInsert = isInsert;
  215 + }
  216 +
  217 + public String getIsInsert() {
  218 + return isInsert;
  219 + }
  220 +
  221 + public boolean isInsert() {
  222 + return isInsert(this.isInsert);
  223 + }
  224 +
  225 + public boolean isInsert(String isInsert) {
  226 + return isInsert != null && StringUtils.equals("1", isInsert);
  227 + }
  228 +
  229 + public void setIsEdit(String isEdit) {
  230 + this.isEdit = isEdit;
  231 + }
  232 +
  233 + public String getIsEdit() {
  234 + return isEdit;
  235 + }
  236 +
  237 + public boolean isEdit() {
  238 + return isInsert(this.isEdit);
  239 + }
  240 +
  241 + public boolean isEdit(String isEdit) {
  242 + return isEdit != null && StringUtils.equals("1", isEdit);
  243 + }
  244 +
  245 + public void setIsList(String isList) {
  246 + this.isList = isList;
  247 + }
  248 +
  249 + public String getIsList() {
  250 + return isList;
  251 + }
  252 +
  253 + public boolean isList() {
  254 + return isList(this.isList);
  255 + }
  256 +
  257 + public boolean isList(String isList) {
  258 + return isList != null && StringUtils.equals("1", isList);
  259 + }
  260 +
  261 + public void setIsQuery(String isQuery) {
  262 + this.isQuery = isQuery;
  263 + }
  264 +
  265 + public String getIsQuery() {
  266 + return isQuery;
  267 + }
  268 +
  269 + public boolean isQuery() {
  270 + return isQuery(this.isQuery);
  271 + }
  272 +
  273 + public boolean isQuery(String isQuery) {
  274 + return isQuery != null && StringUtils.equals("1", isQuery);
  275 + }
  276 +
  277 + public void setQueryType(String queryType) {
  278 + this.queryType = queryType;
  279 + }
  280 +
  281 + public String getQueryType() {
  282 + return queryType;
  283 + }
  284 +
  285 + public String getHtmlType() {
  286 + return htmlType;
  287 + }
  288 +
  289 + public void setHtmlType(String htmlType) {
  290 + this.htmlType = htmlType;
  291 + }
  292 +
  293 + public void setDictType(String dictType) {
  294 + this.dictType = dictType;
  295 + }
  296 +
  297 + public String getDictType() {
  298 + return dictType;
  299 + }
  300 +
  301 + public void setSort(Integer sort) {
  302 + this.sort = sort;
  303 + }
  304 +
  305 + public Integer getSort() {
  306 + return sort;
  307 + }
  308 +
  309 + public boolean isSuperColumn() {
  310 + return isSuperColumn(this.javaField);
  311 + }
  312 +
  313 + public static boolean isSuperColumn(String javaField) {
  314 + return StringUtils.equalsAnyIgnoreCase(javaField,
  315 + // BaseEntity
  316 + "createBy", "createTime", "updateBy", "updateTime", "remark",
  317 + // TreeEntity
  318 + "parentName", "parentId", "orderNum", "ancestors");
  319 + }
  320 +
  321 + public boolean isUsableColumn() {
  322 + return isUsableColumn(javaField);
  323 + }
  324 +
  325 + public static boolean isUsableColumn(String javaField) {
  326 + // isSuperColumn()中的名单用于避免生成多余Domain属性,若某些属性在生成页面时需要用到不能忽略,则放在此处白名单
  327 + return StringUtils.equalsAnyIgnoreCase(javaField, "parentId", "orderNum");
  328 + }
  329 +
  330 + public String readConverterExp() {
  331 + String remarks = StringUtils.substringBetween(this.columnComment, "(", ")");
  332 + StringBuffer sb = new StringBuffer();
  333 + if (StringUtils.isNotEmpty(remarks)) {
  334 + for (String value : remarks.split(" ")) {
  335 + if (StringUtils.isNotEmpty(value)) {
  336 + Object startStr = value.subSequence(0, 1);
  337 + String endStr = value.substring(1);
  338 + sb.append("").append(startStr).append("=").append(endStr).append(",");
  339 + }
  340 + }
  341 + return sb.deleteCharAt(sb.length() - 1).toString();
  342 + } else {
  343 + return this.columnComment;
  344 + }
  345 + }
  346 +}
0 347 \ No newline at end of file
... ...
src/main/java/com/huaheng/pc/tool/gen/domain/TableInfo.java deleted
1   -package com.huaheng.pc.tool.gen.domain;
2   -
3   -import java.util.List;
4   -import com.huaheng.common.utils.StringUtils;
5   -import com.huaheng.framework.web.domain.BaseEntity;
6   -
7   -/**
8   - * ry 数据库表
9   - *
10   - * @author huaheng
11   - */
12   -public class TableInfo extends BaseEntity
13   -{
14   - private static final long serialVersionUID = 1L;
15   -
16   - /** 表名称 */
17   - private String tableName;
18   -
19   - /** 表描述 */
20   - private String tableComment;
21   -
22   - /** 表的主键列信息 */
23   - private ColumnInfo primaryKey;
24   -
25   - /** 表的列名(不包含主键) */
26   - private List<ColumnInfo> columns;
27   -
28   - /** 类名(第一个字母大写) */
29   - private String className;
30   -
31   - /** 类名(第一个字母小写) */
32   - private String classname;
33   -
34   - public String getTableName()
35   - {
36   - return tableName;
37   - }
38   -
39   - public void setTableName(String tableName)
40   - {
41   - this.tableName = tableName;
42   - }
43   -
44   - public String getTableComment()
45   - {
46   - return tableComment;
47   - }
48   -
49   - public void setTableComment(String tableComment)
50   - {
51   - this.tableComment = tableComment;
52   - }
53   -
54   - public List<ColumnInfo> getColumns()
55   - {
56   - return columns;
57   - }
58   -
59   - public ColumnInfo getColumnsLast()
60   - {
61   - ColumnInfo columnInfo = null;
62   - if (StringUtils.isNotNull(columns) && columns.size() > 0)
63   - {
64   - columnInfo = columns.get(0);
65   - }
66   - return columnInfo;
67   - }
68   -
69   - public void setColumns(List<ColumnInfo> columns)
70   - {
71   - this.columns = columns;
72   - }
73   -
74   - public String getClassName()
75   - {
76   - return className;
77   - }
78   -
79   - public void setClassName(String className)
80   - {
81   - this.className = className;
82   - }
83   -
84   - public String getClassname()
85   - {
86   - return classname;
87   - }
88   -
89   - public void setClassname(String classname)
90   - {
91   - this.classname = classname;
92   - }
93   -
94   - public ColumnInfo getPrimaryKey()
95   - {
96   - return primaryKey;
97   - }
98   -
99   - public void setPrimaryKey(ColumnInfo primaryKey)
100   - {
101   - this.primaryKey = primaryKey;
102   - }
103   -
104   - @Override
105   - public String toString()
106   - {
107   - return "TableInfo [tableName=" + tableName + ", tableComment=" + tableComment + ", primaryKey=" + primaryKey
108   - + ", columns=" + columns + ", className=" + className + ", classname=" + classname + "]";
109   - }
110   -
111   -}
src/main/java/com/huaheng/pc/tool/gen/mapper/GenMapper.java deleted
1   -package com.huaheng.pc.tool.gen.mapper;
2   -
3   -import java.util.List;
4   -import com.huaheng.pc.tool.gen.domain.ColumnInfo;
5   -import com.huaheng.pc.tool.gen.domain.TableInfo;
6   -import org.springframework.stereotype.Service;
7   -
8   -/**
9   - * 代码生成 数据层
10   - *
11   - * @author huaheng
12   - */
13   -@Service
14   -public interface GenMapper
15   -{
16   - /**
17   - * 查询ry数据库表信息
18   - *
19   - * @param tableInfo 表信息
20   - * @return 数据库表列表
21   - */
22   - public List<TableInfo> selectTableList(TableInfo tableInfo);
23   -
24   - /**
25   - * 根据表名称查询信息
26   - *
27   - * @param tableName 表名称
28   - * @return 表信息
29   - */
30   - public TableInfo selectTableByName(String tableName);
31   -
32   - /**
33   - * 根据表名称查询列信息
34   - *
35   - * @param tableName 表名称
36   - * @return 列信息
37   - */
38   - public List<ColumnInfo> selectTableColumnsByName(String tableName);
39   -}
src/main/java/com/huaheng/pc/tool/gen/mapper/GenTableColumnMapper.java 0 → 100644
  1 +package com.huaheng.pc.tool.gen.mapper;
  2 +
  3 +import com.huaheng.pc.tool.gen.domain.GenTableColumn;
  4 +
  5 +import java.util.List;
  6 +
  7 +/**
  8 + * 业务字段 数据层
  9 + *
  10 + * @author ruoyi
  11 + */
  12 +public interface GenTableColumnMapper {
  13 + /**
  14 + * 根据表名称查询列信息
  15 + *
  16 + * @param tableName 表名称
  17 + * @return 列信息
  18 + */
  19 + List<GenTableColumn> selectDbTableColumnsByName(String tableName);
  20 +
  21 + /**
  22 + * 查询业务字段列表
  23 + *
  24 + * @param genTableColumn 业务字段信息
  25 + * @return 业务字段集合
  26 + */
  27 + List<GenTableColumn> selectGenTableColumnListByTableId(GenTableColumn genTableColumn);
  28 +
  29 + /**
  30 + * 新增业务字段
  31 + *
  32 + * @param genTableColumn 业务字段信息
  33 + * @return 结果
  34 + */
  35 + int insertGenTableColumn(GenTableColumn genTableColumn);
  36 +
  37 + /**
  38 + * 修改业务字段
  39 + *
  40 + * @param genTableColumn 业务字段信息
  41 + * @return 结果
  42 + */
  43 + int updateGenTableColumn(GenTableColumn genTableColumn);
  44 +
  45 + /**
  46 + * 批量删除业务字段
  47 + *
  48 + * @param ids 需要删除的数据ID
  49 + * @return 结果
  50 + */
  51 + int deleteGenTableColumnByIds(Long[] ids);
  52 +}
0 53 \ No newline at end of file
... ...
src/main/java/com/huaheng/pc/tool/gen/mapper/GenTableMapper.java 0 → 100644
  1 +package com.huaheng.pc.tool.gen.mapper;
  2 +
  3 +import com.huaheng.pc.tool.gen.domain.GenTable;
  4 +
  5 +import java.util.List;
  6 +
  7 +/**
  8 + * 业务 数据层
  9 + */
  10 +public interface GenTableMapper {
  11 + /**
  12 + * 查询业务列表
  13 + *
  14 + * @param genTable 业务信息
  15 + * @return 业务集合
  16 + */
  17 + List<GenTable> selectGenTableList(GenTable genTable);
  18 +
  19 + /**
  20 + * 查询据库列表
  21 + *
  22 + * @param genTable 业务信息
  23 + * @return 数据库表集合
  24 + */
  25 + List<GenTable> selectDbTableList(GenTable genTable);
  26 +
  27 + /**
  28 + * 查询据库列表
  29 + *
  30 + * @param tableNames 表名称组
  31 + * @return 数据库表集合
  32 + */
  33 + List<GenTable> selectDbTableListByNames(String[] tableNames);
  34 +
  35 + /**
  36 + * 查询所有表信息
  37 + *
  38 + * @return 表信息集合
  39 + */
  40 + List<GenTable> selectGenTableAll();
  41 +
  42 + /**
  43 + * 查询表ID业务信息
  44 + *
  45 + * @param id 业务ID
  46 + * @return 业务信息
  47 + */
  48 + GenTable selectGenTableById(Long id);
  49 +
  50 + /**
  51 + * 查询表名称业务信息
  52 + *
  53 + * @param tableName 表名称
  54 + * @return 业务信息
  55 + */
  56 + GenTable selectGenTableByName(String tableName);
  57 +
  58 + /**
  59 + * 新增业务
  60 + *
  61 + * @param genTable 业务信息
  62 + * @return 结果
  63 + */
  64 + int insertGenTable(GenTable genTable);
  65 +
  66 + /**
  67 + * 修改业务
  68 + *
  69 + * @param genTable 业务信息
  70 + * @return 结果
  71 + */
  72 + int updateGenTable(GenTable genTable);
  73 +
  74 + /**
  75 + * 批量删除业务
  76 + *
  77 + * @param ids 需要删除的数据ID
  78 + * @return 结果
  79 + */
  80 + int deleteGenTableByIds(Long[] ids);
  81 +}
0 82 \ No newline at end of file
... ...
src/main/java/com/huaheng/pc/tool/gen/service/GenServiceImpl.java deleted
1   -package com.huaheng.pc.tool.gen.service;
2   -
3   -import java.io.ByteArrayOutputStream;
4   -import java.io.IOException;
5   -import java.io.StringWriter;
6   -import java.util.List;
7   -import java.util.zip.ZipEntry;
8   -import java.util.zip.ZipOutputStream;
9   -import org.apache.commons.io.IOUtils;
10   -import org.apache.velocity.Template;
11   -import org.apache.velocity.VelocityContext;
12   -import org.apache.velocity.app.Velocity;
13   -import org.springframework.beans.factory.annotation.Autowired;
14   -import org.springframework.stereotype.Service;
15   -import com.huaheng.common.constant.Constants;
16   -import com.huaheng.common.exception.base.BaseException;
17   -import com.huaheng.common.utils.StringUtils;
18   -import com.huaheng.framework.config.GenConfig;
19   -import com.huaheng.pc.tool.gen.domain.ColumnInfo;
20   -import com.huaheng.pc.tool.gen.domain.TableInfo;
21   -import com.huaheng.pc.tool.gen.mapper.GenMapper;
22   -import com.huaheng.pc.tool.gen.util.GenUtils;
23   -import com.huaheng.pc.tool.gen.util.VelocityInitializer;
24   -
25   -/**
26   - * 代码生成 服务层处理
27   - *
28   - * @author huaheng
29   - */
30   -@Service
31   -public class GenServiceImpl implements IGenService
32   -{
33   - @Autowired
34   - private GenMapper genMapper;
35   -
36   - /**
37   - * 查询ry数据库表信息
38   - *
39   - * @param tableInfo 表信息
40   - * @return 数据库表列表
41   - */
42   - @Override
43   - public List<TableInfo> selectTableList(TableInfo tableInfo)
44   - {
45   - return genMapper.selectTableList(tableInfo);
46   - }
47   -
48   - /**
49   - * 生成代码
50   - *
51   - * @param tableName 表名称
52   - * @return 数据
53   - */
54   - @Override
55   - public byte[] generatorCode(String tableName)
56   - {
57   - ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
58   - ZipOutputStream zip = new ZipOutputStream(outputStream);
59   - // 查询表信息
60   - TableInfo table = genMapper.selectTableByName(tableName);
61   - // 查询列信息
62   - List<ColumnInfo> columns = genMapper.selectTableColumnsByName(tableName);
63   - // 生成代码
64   - generatorCode(table, columns, zip);
65   - IOUtils.closeQuietly(zip);
66   - return outputStream.toByteArray();
67   - }
68   -
69   - /**
70   - * 批量生成代码
71   - *
72   - * @param tableNames 表数组
73   - * @return 数据
74   - */
75   - @Override
76   - public byte[] generatorCode(String[] tableNames)
77   - {
78   - ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
79   - ZipOutputStream zip = new ZipOutputStream(outputStream);
80   - for (String tableName : tableNames)
81   - {
82   - // 查询表信息
83   - TableInfo table = genMapper.selectTableByName(tableName);
84   - // 查询列信息
85   - List<ColumnInfo> columns = genMapper.selectTableColumnsByName(tableName);
86   - // 生成代码
87   - generatorCode(table, columns, zip);
88   - }
89   - IOUtils.closeQuietly(zip);
90   - return outputStream.toByteArray();
91   - }
92   -
93   - /**
94   - * 生成代码
95   - */
96   - public void generatorCode(TableInfo table, List<ColumnInfo> columns, ZipOutputStream zip)
97   - {
98   - // 表名转换成Java属性名
99   - String className = GenUtils.tableToJava(table.getTableName());
100   - table.setClassName(className);
101   - table.setClassname(StringUtils.uncapitalize(className));
102   - // 列信息
103   - table.setColumns(GenUtils.transColums(columns));
104   - // 设置主键
105   - table.setPrimaryKey(table.getColumnsLast());
106   -
107   - VelocityInitializer.initVelocity();
108   -
109   - String packageName = GenConfig.getPackageName();
110   - String moduleName = GenUtils.getModuleName(packageName);
111   -
112   - VelocityContext context = GenUtils.getVelocityContext(table);
113   -
114   - // 获取模板列表
115   - List<String> templates = GenUtils.getTemplates();
116   - for (String template : templates)
117   - {
118   - // 渲染模板
119   - StringWriter sw = new StringWriter();
120   - Template tpl = Velocity.getTemplate(template, Constants.UTF8);
121   - tpl.merge(context, sw);
122   - try
123   - {
124   - // 添加到zip
125   - zip.putNextEntry(new ZipEntry(GenUtils.getFileName(template, table, moduleName)));
126   - IOUtils.write(sw.toString(), zip, Constants.UTF8);
127   - IOUtils.closeQuietly(sw);
128   - zip.closeEntry();
129   - }
130   - catch (IOException e)
131   - {
132   - throw new BaseException("渲染模板失败,表名:" + table.getTableName(), e.getMessage());
133   - }
134   - }
135   - }
136   -}
src/main/java/com/huaheng/pc/tool/gen/service/IGenService.java deleted
1   -package com.huaheng.pc.tool.gen.service;
2   -
3   -import java.util.List;
4   -import com.huaheng.pc.tool.gen.domain.TableInfo;
5   -
6   -/**
7   - * 代码生成 服务层
8   - *
9   - * @author huaheng
10   - */
11   -public interface IGenService
12   -{
13   - /**
14   - * 查询ry数据库表信息
15   - *
16   - * @param tableInfo 表信息
17   - * @return 数据库表列表
18   - */
19   - public List<TableInfo> selectTableList(TableInfo tableInfo);
20   -
21   - /**
22   - * 生成代码
23   - *
24   - * @param tableName 表名称
25   - * @return 数据
26   - */
27   - public byte[] generatorCode(String tableName);
28   -
29   - /**
30   - * 批量生成代码
31   - *
32   - * @param tableNames 表数组
33   - * @return 数据
34   - */
35   - public byte[] generatorCode(String[] tableNames);
36   -
37   -}
src/main/java/com/huaheng/pc/tool/gen/service/IGenTableColumnService.java 0 → 100644
  1 +package com.huaheng.pc.tool.gen.service;
  2 +
  3 +import com.huaheng.pc.tool.gen.domain.GenTableColumn;
  4 +
  5 +import java.util.List;
  6 +
  7 +/**
  8 + * 业务字段 服务层
  9 + * @author Enzo Cotter
  10 + * @date 2020/6/30
  11 + */
  12 +public interface IGenTableColumnService {
  13 +
  14 + /**
  15 + * 查询业务字段列表
  16 + *
  17 + * @param genTableColumn 业务字段信息
  18 + * @return 业务字段集合
  19 + */
  20 + List<GenTableColumn> selectGenTableColumnListByTableId(GenTableColumn genTableColumn);
  21 +
  22 + /**
  23 + * 新增业务字段
  24 + *
  25 + * @param genTableColumn 业务字段信息
  26 + * @return 结果
  27 + */
  28 + int insertGenTableColumn(GenTableColumn genTableColumn);
  29 +
  30 + /**
  31 + * 修改业务字段
  32 + *
  33 + * @param genTableColumn 业务字段信息
  34 + * @return 结果
  35 + */
  36 + int updateGenTableColumn(GenTableColumn genTableColumn);
  37 +
  38 + /**
  39 + * 删除业务字段信息
  40 + *
  41 + * @param ids 需要删除的数据ID
  42 + * @return 结果
  43 + */
  44 + int deleteGenTableColumnByIds(String ids);
  45 +}
... ...
src/main/java/com/huaheng/pc/tool/gen/service/IGenTableService.java 0 → 100644
  1 +package com.huaheng.pc.tool.gen.service;
  2 +
  3 +import com.huaheng.pc.tool.gen.domain.GenTable;
  4 +
  5 +import java.util.List;
  6 +import java.util.Map;
  7 +
  8 +/**
  9 + * 业务 服务层
  10 + * @author Enzo Cotter
  11 + * @date 2020/6/30
  12 + */
  13 +public interface IGenTableService {
  14 +
  15 + /**
  16 + * 查询业务列表
  17 + *
  18 + * @param genTable 业务信息
  19 + * @return 业务集合
  20 + */
  21 + public List<GenTable> selectGenTableList(GenTable genTable);
  22 +
  23 + /**
  24 + * 查询据库列表
  25 + *
  26 + * @param genTable 业务信息
  27 + * @return 数据库表集合
  28 + */
  29 + public List<GenTable> selectDbTableList(GenTable genTable);
  30 +
  31 + /**
  32 + * 查询据库列表
  33 + *
  34 + * @param tableNames 表名称组
  35 + * @return 数据库表集合
  36 + */
  37 + public List<GenTable> selectDbTableListByNames(String[] tableNames);
  38 +
  39 + /**
  40 + * 查询所有表信息
  41 + *
  42 + * @return 表信息集合
  43 + */
  44 + public List<GenTable> selectGenTableAll();
  45 +
  46 + /**
  47 + * 查询业务信息
  48 + *
  49 + * @param id 业务ID
  50 + * @return 业务信息
  51 + */
  52 + public GenTable selectGenTableById(Long id);
  53 +
  54 + /**
  55 + * 修改业务
  56 + *
  57 + * @param genTable 业务信息
  58 + * @return 结果
  59 + */
  60 + public void updateGenTable(GenTable genTable);
  61 +
  62 + /**
  63 + * 删除业务信息
  64 + *
  65 + * @param ids 需要删除的数据ID
  66 + * @return 结果
  67 + */
  68 + public void deleteGenTableByIds(String ids);
  69 +
  70 + /**
  71 + * 导入表结构
  72 + *
  73 + * @param tableList 导入表列表
  74 + * @param operName 操作人员
  75 + */
  76 + public void importGenTable(List<GenTable> tableList, String operName);
  77 +
  78 + /**
  79 + * 预览代码
  80 + *
  81 + * @param tableId 表编号
  82 + * @return 预览数据列表
  83 + */
  84 + public Map<String, String> previewCode(Long tableId);
  85 +
  86 + /**
  87 + * 生成代码
  88 + *
  89 + * @param tableName 表名称
  90 + * @return 数据
  91 + */
  92 + public byte[] generatorCode(String tableName);
  93 +
  94 + /**
  95 + * 批量生成代码
  96 + *
  97 + * @param tableNames 表数组
  98 + * @return 数据
  99 + */
  100 + public byte[] generatorCode(String[] tableNames);
  101 +
  102 + /**
  103 + * 修改保存参数校验
  104 + *
  105 + * @param genTable 业务信息
  106 + */
  107 + public void validateEdit(GenTable genTable);
  108 +}
... ...
src/main/java/com/huaheng/pc/tool/gen/service/impl/GenTableColumnServiceImpl.java 0 → 100644
  1 +package com.huaheng.pc.tool.gen.service.impl;
  2 +
  3 +import com.huaheng.common.support.Convert;
  4 +import com.huaheng.pc.tool.gen.domain.GenTableColumn;
  5 +import com.huaheng.pc.tool.gen.mapper.GenTableColumnMapper;
  6 +import com.huaheng.pc.tool.gen.service.IGenTableColumnService;
  7 +import org.springframework.beans.factory.annotation.Autowired;
  8 +import org.springframework.stereotype.Service;
  9 +
  10 +import java.util.List;
  11 +
  12 +/**
  13 + * 业务字段 服务层实现
  14 + * @author Enzo Cotter
  15 + * @date 2020/6/30
  16 + */
  17 +@Service
  18 +public class GenTableColumnServiceImpl implements IGenTableColumnService {
  19 +
  20 + @Autowired
  21 + private GenTableColumnMapper genTableColumnMapper;
  22 +
  23 + /**
  24 + * 查询业务字段列表
  25 + *
  26 + * @param genTableColumn 业务字段信息
  27 + * @return 业务字段集合
  28 + */
  29 + @Override
  30 + public List<GenTableColumn> selectGenTableColumnListByTableId(GenTableColumn genTableColumn) {
  31 + return genTableColumnMapper.selectGenTableColumnListByTableId(genTableColumn);
  32 + }
  33 +
  34 + /**
  35 + * 新增业务字段
  36 + *
  37 + * @param genTableColumn 业务字段信息
  38 + * @return 结果
  39 + */
  40 + @Override
  41 + public int insertGenTableColumn(GenTableColumn genTableColumn) {
  42 + return genTableColumnMapper.insertGenTableColumn(genTableColumn);
  43 + }
  44 +
  45 + /**
  46 + * 修改业务字段
  47 + *
  48 + * @param genTableColumn 业务字段信息
  49 + * @return 结果
  50 + */
  51 + @Override
  52 + public int updateGenTableColumn(GenTableColumn genTableColumn) {
  53 + return genTableColumnMapper.updateGenTableColumn(genTableColumn);
  54 + }
  55 +
  56 + /**
  57 + * 删除业务字段对象
  58 + *
  59 + * @param ids 需要删除的数据ID
  60 + * @return 结果
  61 + */
  62 + @Override
  63 + public int deleteGenTableColumnByIds(String ids) {
  64 + return genTableColumnMapper.deleteGenTableColumnByIds(Convert.toLongArray(ids));
  65 + }
  66 +}
... ...
src/main/java/com/huaheng/pc/tool/gen/service/impl/GenTableServiceImpl.java 0 → 100644
  1 +package com.huaheng.pc.tool.gen.service.impl;
  2 +
  3 +import com.alibaba.fastjson.JSON;
  4 +import com.alibaba.fastjson.JSONObject;
  5 +import com.huaheng.common.constant.Constants;
  6 +import com.huaheng.common.constant.GenConstants;
  7 +import com.huaheng.common.exception.BusinessException;
  8 +import com.huaheng.common.support.Convert;
  9 +import com.huaheng.common.utils.StringUtils;
  10 +import com.huaheng.common.utils.VelocityUtils;
  11 +import com.huaheng.pc.tool.gen.domain.GenTable;
  12 +import com.huaheng.pc.tool.gen.domain.GenTableColumn;
  13 +import com.huaheng.pc.tool.gen.mapper.GenTableColumnMapper;
  14 +import com.huaheng.pc.tool.gen.mapper.GenTableMapper;
  15 +import com.huaheng.pc.tool.gen.service.IGenTableService;
  16 +import com.huaheng.pc.tool.gen.util.GenUtils;
  17 +import com.huaheng.pc.tool.gen.util.VelocityInitializer;
  18 +import org.apache.velocity.Template;
  19 +import org.apache.velocity.VelocityContext;
  20 +import org.apache.velocity.app.Velocity;
  21 +import org.slf4j.Logger;
  22 +import org.slf4j.LoggerFactory;
  23 +import org.springframework.stereotype.Service;
  24 +import org.springframework.transaction.annotation.Transactional;
  25 +
  26 +import javax.annotation.Resource;
  27 +import java.io.IOException;
  28 +import java.io.StringWriter;
  29 +import java.io.ByteArrayOutputStream;
  30 +import org.apache.commons.io.IOUtils;
  31 +import java.util.LinkedHashMap;
  32 +import java.util.List;
  33 +import java.util.Map;
  34 +import java.util.zip.ZipEntry;
  35 +import java.util.zip.ZipOutputStream;
  36 +
  37 +/**
  38 + * Created by Enzo Cotter on 2020/6/30.
  39 + */
  40 +@Service
  41 +public class GenTableServiceImpl implements IGenTableService {
  42 +
  43 + private static final Logger log = LoggerFactory.getLogger(GenTableServiceImpl.class);
  44 +
  45 + @Resource
  46 + private GenTableMapper genTableMapper;
  47 +
  48 + @Resource
  49 + private GenTableColumnMapper genTableColumnMapper;
  50 +
  51 + /**
  52 + * 查询业务信息
  53 + *
  54 + * @param id 业务ID
  55 + * @return 业务信息
  56 + */
  57 + @Override
  58 + public GenTable selectGenTableById(Long id) {
  59 + GenTable genTable = genTableMapper.selectGenTableById(id);
  60 + setTableFromOptions(genTable);
  61 + return genTable;
  62 + }
  63 +
  64 + /**
  65 + * 查询业务列表
  66 + *
  67 + * @param genTable 业务信息
  68 + * @return 业务集合
  69 + */
  70 + @Override
  71 + public List<GenTable> selectGenTableList(GenTable genTable) {
  72 + return genTableMapper.selectGenTableList(genTable);
  73 + }
  74 +
  75 + /**
  76 + * 查询据库列表
  77 + *
  78 + * @param genTable 业务信息
  79 + * @return 数据库表集合
  80 + */
  81 + @Override
  82 + public List<GenTable> selectDbTableList(GenTable genTable) {
  83 + return genTableMapper.selectDbTableList(genTable);
  84 + }
  85 +
  86 + /**
  87 + * 查询据库列表
  88 + *
  89 + * @param tableNames 表名称组
  90 + * @return 数据库表集合
  91 + */
  92 + @Override
  93 + public List<GenTable> selectDbTableListByNames(String[] tableNames) {
  94 + return genTableMapper.selectDbTableListByNames(tableNames);
  95 + }
  96 +
  97 + /**
  98 + * 查询所有表信息
  99 + *
  100 + * @return 表信息集合
  101 + */
  102 + @Override
  103 + public List<GenTable> selectGenTableAll() {
  104 + return genTableMapper.selectGenTableAll();
  105 + }
  106 +
  107 + /**
  108 + * 修改业务
  109 + *
  110 + * @param genTable 业务信息
  111 + * @return 结果
  112 + */
  113 + @Override
  114 + @Transactional
  115 + public void updateGenTable(GenTable genTable) {
  116 + String options = JSON.toJSONString(genTable.getParams());
  117 + genTable.setOptions(options);
  118 + int row = genTableMapper.updateGenTable(genTable);
  119 + if (row > 0) {
  120 + for (GenTableColumn cenTableColumn : genTable.getColumns()) {
  121 + genTableColumnMapper.updateGenTableColumn(cenTableColumn);
  122 + }
  123 + }
  124 + }
  125 +
  126 + /**
  127 + * 删除业务对象
  128 + *
  129 + * @param ids 需要删除的数据ID
  130 + * @return 结果
  131 + */
  132 + @Override
  133 + @Transactional
  134 + public void deleteGenTableByIds(String ids) {
  135 + genTableMapper.deleteGenTableByIds(Convert.toLongArray(ids));
  136 + genTableColumnMapper.deleteGenTableColumnByIds(Convert.toLongArray(ids));
  137 + }
  138 +
  139 + /**
  140 + * 导入表结构
  141 + *
  142 + * @param tableList 导入表列表
  143 + * @param operName 操作人员
  144 + */
  145 + @Override
  146 + @Transactional
  147 + public void importGenTable(List<GenTable> tableList, String operName) {
  148 + try {
  149 + for (GenTable table : tableList) {
  150 + String tableName = table.getTableName();
  151 + GenUtils.initTable(table, operName);
  152 + int row = genTableMapper.insertGenTable(table);
  153 + if (row > 0) {
  154 + // 保存列信息
  155 + List<GenTableColumn> genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
  156 + for (GenTableColumn column : genTableColumns) {
  157 + GenUtils.initColumnField(column, table);
  158 + genTableColumnMapper.insertGenTableColumn(column);
  159 + }
  160 + }
  161 + }
  162 + } catch (Exception e) {
  163 + throw new BusinessException("导入失败:" + e.getMessage());
  164 + }
  165 + }
  166 +
  167 + /**
  168 + * 预览代码
  169 + *
  170 + * @param tableId 表编号
  171 + * @return 预览数据列表
  172 + */
  173 + @Override
  174 + public Map<String, String> previewCode(Long tableId) {
  175 + Map<String, String> dataMap = new LinkedHashMap<>();
  176 + // 查询表信息
  177 + GenTable table = genTableMapper.selectGenTableById(tableId);
  178 + // 设置主子表信息
  179 + setSubTable(table);
  180 + // 设置主键列信息
  181 + setPkColumn(table);
  182 + VelocityInitializer.initVelocity();
  183 +
  184 + VelocityContext context = VelocityUtils.prepareContext(table);
  185 +
  186 + // 获取模板列表
  187 + List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
  188 + for (String template : templates) {
  189 + // 渲染模板
  190 + StringWriter sw = new StringWriter();
  191 + Template tpl = Velocity.getTemplate(template, Constants.UTF8);
  192 + tpl.merge(context, sw);
  193 + dataMap.put(template, sw.toString());
  194 + }
  195 + return dataMap;
  196 + }
  197 +
  198 + /**
  199 + * 生成代码
  200 + *
  201 + * @param tableName 表名称
  202 + * @return 数据
  203 + */
  204 + @Override
  205 + public byte[] generatorCode(String tableName) {
  206 + ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
  207 + ZipOutputStream zip = new ZipOutputStream(outputStream);
  208 + generatorCode(tableName, zip);
  209 + IOUtils.closeQuietly(zip);
  210 + return outputStream.toByteArray();
  211 + }
  212 +
  213 + /**
  214 + * 批量生成代码
  215 + *
  216 + * @param tableNames 表数组
  217 + * @return 数据
  218 + */
  219 + @Override
  220 + public byte[] generatorCode(String[] tableNames) {
  221 + ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
  222 + ZipOutputStream zip = new ZipOutputStream(outputStream);
  223 + for (String tableName : tableNames) {
  224 + generatorCode(tableName, zip);
  225 + }
  226 + IOUtils.closeQuietly(zip);
  227 + return outputStream.toByteArray();
  228 + }
  229 +
  230 + /**
  231 + * 查询表信息并生成代码
  232 + */
  233 + private void generatorCode(String tableName, ZipOutputStream zip) {
  234 + // 查询表信息
  235 + GenTable table = genTableMapper.selectGenTableByName(tableName);
  236 + // 设置主子表信息
  237 + setSubTable(table);
  238 + // 设置主键列信息
  239 + setPkColumn(table);
  240 +
  241 + VelocityInitializer.initVelocity();
  242 +
  243 + VelocityContext context = VelocityUtils.prepareContext(table);
  244 +
  245 + // 获取模板列表
  246 + List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
  247 + for (String template : templates) {
  248 + // 渲染模板
  249 + StringWriter sw = new StringWriter();
  250 + Template tpl = Velocity.getTemplate(template, Constants.UTF8);
  251 + tpl.merge(context, sw);
  252 + try {
  253 + // 添加到zip
  254 + zip.putNextEntry(new ZipEntry(VelocityUtils.getFileName(template, table)));
  255 + IOUtils.write(sw.toString(), zip, Constants.UTF8);
  256 + IOUtils.closeQuietly(sw);
  257 + zip.flush();
  258 + zip.closeEntry();
  259 + } catch (IOException e) {
  260 + log.error("渲染模板失败,表名:" + table.getTableName(), e);
  261 + }
  262 + }
  263 + }
  264 +
  265 + /**
  266 + * 修改保存参数校验
  267 + *
  268 + * @param genTable 业务信息
  269 + */
  270 + @Override
  271 + public void validateEdit(GenTable genTable) {
  272 + if (GenConstants.TPL_TREE.equals(genTable.getTplCategory())) {
  273 + String options = JSON.toJSONString(genTable.getParams());
  274 + JSONObject paramsObj = JSONObject.parseObject(options);
  275 + if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_CODE))) {
  276 + throw new BusinessException("树编码字段不能为空");
  277 + } else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_PARENT_CODE))) {
  278 + throw new BusinessException("树父编码字段不能为空");
  279 + } else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_NAME))) {
  280 + throw new BusinessException("树名称字段不能为空");
  281 + }
  282 + } else if (GenConstants.TPL_SUB.equals(genTable.getTplCategory())) {
  283 + if (StringUtils.isEmpty(genTable.getSubTableName())) {
  284 + throw new BusinessException("关联子表的表名不能为空");
  285 + } else if (StringUtils.isEmpty(genTable.getSubTableFkName())) {
  286 + throw new BusinessException("子表关联的外键名不能为空");
  287 + }
  288 + }
  289 + }
  290 +
  291 + /**
  292 + * 设置主键列信息
  293 + *
  294 + * @param table 业务表信息
  295 + */
  296 + public void setPkColumn(GenTable table) {
  297 +
  298 + for (GenTableColumn column : table.getColumns()) {
  299 + if (column.isPk()) {
  300 + table.setPkColumn(column);
  301 + break;
  302 + }
  303 + }
  304 + if (StringUtils.isNull(table.getPkColumn())) {
  305 + table.setPkColumn(table.getColumns().get(0));
  306 + }
  307 + if (GenConstants.TPL_SUB.equals(table.getTplCategory())) {
  308 + for (GenTableColumn column : table.getSubTable().getColumns()) {
  309 + if (column.isPk()) {
  310 + table.getSubTable().setPkColumn(column);
  311 + break;
  312 + }
  313 + }
  314 + if (StringUtils.isNull(table.getSubTable().getPkColumn())) {
  315 + table.getSubTable().setPkColumn(table.getSubTable().getColumns().get(0));
  316 + }
  317 + }
  318 + }
  319 +
  320 + /**
  321 + * 设置主子表信息
  322 + *
  323 + * @param table 业务表信息
  324 + */
  325 + public void setSubTable(GenTable table) {
  326 + String subTableName = table.getSubTableName();
  327 + if (StringUtils.isNotEmpty(subTableName)) {
  328 + table.setSubTable(genTableMapper.selectGenTableByName(subTableName));
  329 + }
  330 + }
  331 +
  332 + /**
  333 + * 设置代码生成其他选项值
  334 + *
  335 + * @param genTable 设置后的生成对象
  336 + */
  337 + public void setTableFromOptions(GenTable genTable) {
  338 + JSONObject paramsObj = JSONObject.parseObject(genTable.getOptions());
  339 + if (StringUtils.isNotNull(paramsObj)) {
  340 + String treeCode = paramsObj.getString(GenConstants.TREE_CODE);
  341 + String treeParentCode = paramsObj.getString(GenConstants.TREE_PARENT_CODE);
  342 + String treeName = paramsObj.getString(GenConstants.TREE_NAME);
  343 + genTable.setTreeCode(treeCode);
  344 + genTable.setTreeParentCode(treeParentCode);
  345 + genTable.setTreeName(treeName);
  346 + }
  347 + }
  348 +}
... ...
src/main/java/com/huaheng/pc/tool/gen/util/GenUtils.java
1 1 package com.huaheng.pc.tool.gen.util;
2 2  
3   -import java.util.ArrayList;
4   -import java.util.List;
5   -import org.apache.velocity.VelocityContext;
6   -import com.huaheng.common.constant.Constants;
7   -import com.huaheng.common.constant.CommonMap;
8   -import com.huaheng.common.utils.DateUtils;
  3 +import java.time.LocalDateTime;
  4 +import java.util.Arrays;
  5 +
  6 +import com.huaheng.common.constant.GenConstants;
9 7 import com.huaheng.common.utils.StringUtils;
10 8 import com.huaheng.framework.config.GenConfig;
11   -import com.huaheng.pc.tool.gen.domain.ColumnInfo;
12   -import com.huaheng.pc.tool.gen.domain.TableInfo;
  9 +import com.huaheng.pc.tool.gen.domain.GenTable;
  10 +import com.huaheng.pc.tool.gen.domain.GenTableColumn;
  11 +import org.apache.commons.lang3.RegExUtils;
  12 +
13 13  
14 14 /**
15 15 * 代码生成器 工具类
16   - *
17   - * @author huaheng
  16 + *
  17 + * @author ruoyi
18 18 */
19   -public class GenUtils
20   -{
21   - /** 项目空间路径 */
22   - private static final String PROJECT_PATH = "main/java/com/huaheng/pc";
  19 +public class GenUtils {
  20 + /**
  21 + * 初始化表信息
  22 + */
  23 + public static void initTable(GenTable genTable, String operName) {
  24 + genTable.setClassName(convertClassName(genTable.getTableName()));
  25 + genTable.setPackageName(GenConfig.getPackageName());
  26 + genTable.setModuleName(getModuleName(GenConfig.getPackageName()));
  27 + genTable.setBusinessName(getBusinessName(genTable.getTableName()));
  28 + genTable.setFunctionName(replaceText(genTable.getTableComment()));
  29 + genTable.setFunctionAuthor(GenConfig.getAuthor());
  30 + genTable.setCreateBy(operName);
  31 + }
23 32  
24   - /** mybatis空间路径 */
25   - private static final String MYBATIS_PATH = "main/resources/mybatis";
  33 + /**
  34 + * 初始化列属性字段
  35 + */
  36 + public static void initColumnField(GenTableColumn column, GenTable table) {
  37 + String dataType = getDbType(column.getColumnType());
  38 + String columnName = column.getColumnName();
  39 + column.setTableId(table.getTableId());
  40 + column.setCreateBy(table.getCreateBy());
  41 + // 设置java字段名
  42 + column.setJavaField(StringUtils.toCamelCase(columnName));
  43 +
  44 + if (arraysContains(GenConstants.COLUMNTYPE_STR, dataType)) {
  45 + column.setJavaType(GenConstants.TYPE_STRING);
  46 + // 字符串长度超过500设置为文本域
  47 + Integer columnLength = getColumnLength(column.getColumnType());
  48 + String htmlType = columnLength >= 500 ? GenConstants.HTML_TEXTAREA : GenConstants.HTML_INPUT;
  49 + column.setHtmlType(htmlType);
  50 + } else if (arraysContains(GenConstants.COLUMNTYPE_DATETIME, dataType)) {
  51 + column.setJavaType(GenConstants.TYPE_DATETIME);
  52 + column.setHtmlType(GenConstants.HTML_DATETIME);
  53 + }else if (arraysContains(GenConstants.COLUMNTYPE_DATE, dataType)) {
  54 + column.setJavaType(GenConstants.TYPE_DATE);
  55 + column.setHtmlType(GenConstants.HTML_DATETIME);
  56 + }else if (arraysContains(GenConstants.COLUMNTYPE_TIME, dataType)) {
  57 + column.setJavaType(GenConstants.TYPE_TIME);
  58 + column.setHtmlType(GenConstants.HTML_DATETIME);
  59 + }else if (arraysContains(GenConstants.COLUMNTYPE_BIT, dataType)) {
  60 + column.setJavaType(GenConstants.TYPE_INTEGER);
  61 + column.setHtmlType(GenConstants.HTML_SELECT);
  62 + } else if (arraysContains(GenConstants.COLUMNTYPE_NUMBER, dataType)) {
  63 + column.setHtmlType(GenConstants.HTML_INPUT);
  64 +
  65 + // 如果是浮点型
  66 + String[] str = StringUtils.split(StringUtils.substringBetween(column.getColumnType(), "(", ")"), ",");
  67 + if (str != null && str.length == 2 && Integer.parseInt(str[1]) > 0) {
  68 + column.setJavaType(GenConstants.TYPE_BIGDECIMAL);
  69 + }
  70 + // 如果是整形
  71 + else if (str != null && str.length == 1 && Integer.parseInt(str[0]) <= 10) {
  72 + column.setJavaType(GenConstants.TYPE_INTEGER);
  73 + }
  74 + // 长整形
  75 + else {
  76 + column.setJavaType(GenConstants.TYPE_LONG);
  77 + }
  78 + }
26 79  
27   - /** html空间路径 */
28   - private static final String TEMPLATES_PATH = "main/resources/templates";
  80 + // 插入字段(默认所有字段都需要插入)
  81 + column.setIsInsert(GenConstants.REQUIRE);
  82 +
  83 + // 编辑字段
  84 + if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName) && !column.isPk()) {
  85 + column.setIsEdit(GenConstants.REQUIRE);
  86 + }
  87 + // 列表字段
  88 + if (!arraysContains(GenConstants.COLUMNNAME_NOT_LIST, columnName) && !column.isPk()) {
  89 + column.setIsList(GenConstants.REQUIRE);
  90 + }
  91 + // 查询字段
  92 + if (!arraysContains(GenConstants.COLUMNNAME_NOT_QUERY, columnName) && !column.isPk()) {
  93 + column.setIsQuery(GenConstants.REQUIRE);
  94 + }
  95 +
  96 + // 查询字段类型
  97 + if (StringUtils.endsWithIgnoreCase(columnName, "name")) {
  98 + column.setQueryType(GenConstants.QUERY_LIKE);
  99 + }
  100 + // 状态字段设置单选框
  101 + if (StringUtils.endsWithIgnoreCase(columnName, "status")) {
  102 + column.setHtmlType(GenConstants.HTML_RADIO);
  103 + }
  104 + // 类型&性别字段设置下拉框
  105 + else if (StringUtils.endsWithIgnoreCase(columnName, "type")
  106 + || StringUtils.endsWithIgnoreCase(columnName, "sex")) {
  107 + column.setHtmlType(GenConstants.HTML_SELECT);
  108 + }
  109 + }
29 110  
30 111 /**
31   - * 设置列信息
  112 + * 校验数组是否包含指定值
  113 + *
  114 + * @param arr 数组
  115 + * @param targetValue 值
  116 + * @return 是否包含
32 117 */
33   - public static List<ColumnInfo> transColums(List<ColumnInfo> columns)
34   - {
35   - // 列信息
36   - List<ColumnInfo> columsList = new ArrayList<>();
37   - for (ColumnInfo column : columns)
38   - {
39   - // 列名转换成Java属性名
40   - String attrName = StringUtils.convertToCamelCase(column.getColumnName());
41   - column.setAttrName(attrName);
42   - column.setAttrname(StringUtils.uncapitalize(attrName));
43   -
44   - // 列的数据类型,转换成Java类型
45   - String attrType = CommonMap.javaTypeMap.get(column.getDataType());
46   - column.setAttrType(attrType);
47   -
48   - columsList.add(column);
49   - }
50   - return columsList;
  118 + public static boolean arraysContains(String[] arr, String targetValue) {
  119 + return Arrays.asList(arr).contains(targetValue);
51 120 }
52 121  
53 122 /**
54   - * 获取模板信息
55   - *
56   - * @return 模板列表
  123 + * 获取模块名
  124 + *
  125 + * @param packageName 包名
  126 + * @return 模块名
57 127 */
58   - public static VelocityContext getVelocityContext(TableInfo table)
59   - {
60   - // java对象数据传递到模板文件vm
61   - VelocityContext velocityContext = new VelocityContext();
62   - String packageName = GenConfig.getPackageName();
63   - velocityContext.put("tableName", table.getTableName());
64   - velocityContext.put("tableComment", replaceKeyword(table.getTableComment()));
65   - velocityContext.put("primaryKey", table.getPrimaryKey());
66   - velocityContext.put("className", table.getClassName());
67   - velocityContext.put("classname", table.getClassname());
68   - velocityContext.put("moduleName", GenUtils.getModuleName(packageName));
69   - velocityContext.put("columns", table.getColumns());
70   - velocityContext.put("package", packageName + "." + table.getClassname());
71   - velocityContext.put("author", GenConfig.getAuthor());
72   - velocityContext.put("datetime", DateUtils.getDate());
73   - return velocityContext;
  128 + public static String getModuleName(String packageName) {
  129 + int lastIndex = packageName.lastIndexOf(".");
  130 + int nameLength = packageName.length();
  131 + String moduleName = StringUtils.substring(packageName, lastIndex + 1, nameLength);
  132 + return moduleName;
74 133 }
75 134  
76 135 /**
77   - * 获取模板信息
78   - *
79   - * @return 模板列表
  136 + * 获取业务名
  137 + *
  138 + * @param tableName 表名
  139 + * @return 业务名
80 140 */
81   - public static List<String> getTemplates()
82   - {
83   - List<String> templates = new ArrayList<String>();
84   - templates.add("templates/vm/java/domain.java.vm");
85   - templates.add("templates/vm/java/Mapper.java.vm");
86   - templates.add("templates/vm/java/Service.java.vm");
87   - templates.add("templates/vm/java/ServiceImpl.java.vm");
88   - templates.add("templates/vm/java/Controller.java.vm");
89   - templates.add("templates/vm/xml/Mapper.xml.vm");
90   - templates.add("templates/vm/html/list.html.vm");
91   - templates.add("templates/vm/html/add.html.vm");
92   - templates.add("templates/vm/html/edit.html.vm");
93   - templates.add("templates/vm/sql/sql.vm");
94   - return templates;
  141 + public static String getBusinessName(String tableName) {
  142 + int lastIndex = tableName.lastIndexOf("_");
  143 + int nameLength = tableName.length();
  144 + String businessName = StringUtils.substring(tableName, lastIndex + 1, nameLength);
  145 + return businessName;
95 146 }
96 147  
97 148 /**
98 149 * 表名转换成Java类名
  150 + *
  151 + * @param tableName 表名称
  152 + * @return 类名
99 153 */
100   - public static String tableToJava(String tableName)
101   - {
102   - if (Constants.AUTO_REOMVE_PRE.equals(GenConfig.getAutoRemovePre()))
103   - {
104   - tableName = tableName.substring(tableName.indexOf("_") + 1);
105   - }
106   - if (StringUtils.isNotEmpty(GenConfig.getTablePrefix()))
107   - {
108   - tableName = tableName.replace(GenConfig.getTablePrefix(), "");
  154 + public static String convertClassName(String tableName) {
  155 + boolean autoRemovePre = GenConfig.getAutoRemovePre();
  156 + String tablePrefix = GenConfig.getTablePrefix();
  157 + if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix)) {
  158 + String[] searchList = StringUtils.split(tablePrefix, ",");
  159 + tableName = replaceFirst(tableName, searchList);
109 160 }
110 161 return StringUtils.convertToCamelCase(tableName);
111 162 }
112 163  
113 164 /**
114   - * 获取文件名
  165 + * 批量替换前缀
  166 + *
  167 + * @param replacementm 替换值
  168 + * @param searchList 替换列表
  169 + * @return
115 170 */
116   - public static String getFileName(String template, TableInfo table, String moduleName)
117   - {
118   - // 小写类名
119   - String classname = table.getClassname();
120   - // 大写类名
121   - String className = table.getClassName();
122   - String javaPath = PROJECT_PATH + "/" + moduleName + "/";
123   - String mybatisPath = MYBATIS_PATH + "/" + moduleName + "/" + className;
124   - String htmlPath = TEMPLATES_PATH + "/" + moduleName + "/" + classname;
125   -
126   - if (StringUtils.isNotEmpty(classname))
127   - {
128   - javaPath += classname.replace(".", "/") + "/";
129   - }
130   -
131   - if (template.contains("domain.java.vm"))
132   - {
133   - return javaPath + "domain" + "/" + className + ".java";
134   - }
135   -
136   - if (template.contains("mapper.java.vm"))
137   - {
138   - return javaPath + "mapper" + "/" + className + "mapper.java";
139   - }
140   -
141   - if (template.contains("Service.java.vm"))
142   - {
143   - return javaPath + "service" + "/" + "I" + className + "Service.java";
144   - }
145   -
146   - if (template.contains("ServiceImpl.java.vm"))
147   - {
148   - return javaPath + "service" + "/" + className + "ServiceImpl.java";
149   - }
150   -
151   - if (template.contains("Controller.java.vm"))
152   - {
153   - return javaPath + "controller" + "/" + className + "Controller.java";
154   - }
155   -
156   - if (template.contains("mapper.xml.vm"))
157   - {
158   - return mybatisPath + "mapper.xml";
  171 + public static String replaceFirst(String replacementm, String[] searchList) {
  172 + String text = replacementm;
  173 + for (String searchString : searchList) {
  174 + if (replacementm.startsWith(searchString)) {
  175 + text = replacementm.replaceFirst(searchString, "");
  176 + break;
  177 + }
159 178 }
  179 + return text;
  180 + }
160 181  
161   - if (template.contains("list.html.vm"))
162   - {
163   - return htmlPath + "/" + classname + ".html";
164   - }
165   - if (template.contains("add.html.vm"))
166   - {
167   - return htmlPath + "/" + "add.html";
168   - }
169   - if (template.contains("edit.html.vm"))
170   - {
171   - return htmlPath + "/" + "edit.html";
172   - }
173   - if (template.contains("sql.vm"))
174   - {
175   - return classname + "Menu.sql";
176   - }
177   - return null;
  182 + /**
  183 + * 关键字替换
  184 + *
  185 + * @param text 需要被替换的名字
  186 + * @return 替换后的名字
  187 + */
  188 + public static String replaceText(String text) {
  189 + return RegExUtils.replaceAll(text, "(?:表|若依)", "");
178 190 }
179 191  
180 192 /**
181   - * 获取模块名
182   - *
183   - * @param packageName 包名
184   - * @return 模块名
  193 + * 获取数据库类型字段
  194 + *
  195 + * @param columnType 列类型
  196 + * @return 截取后的列类型
185 197 */
186   - public static String getModuleName(String packageName)
187   - {
188   - int lastIndex = packageName.lastIndexOf(".");
189   - int nameLength = packageName.length();
190   - String moduleName = StringUtils.substring(packageName, lastIndex + 1, nameLength);
191   - return moduleName;
  198 + public static String getDbType(String columnType) {
  199 + if (StringUtils.indexOf(columnType, "(") > 0) {
  200 + return StringUtils.substringBefore(columnType, "(");
  201 + } else {
  202 + return columnType;
  203 + }
192 204 }
193 205  
194   - public static String replaceKeyword(String keyword)
195   - {
196   - String keyName = keyword.replaceAll("(?:表|信息)", "");
197   - return keyName;
  206 + /**
  207 + * 获取字段长度
  208 + *
  209 + * @param columnType 列类型
  210 + * @return 截取后的列类型
  211 + */
  212 + public static Integer getColumnLength(String columnType) {
  213 + if (StringUtils.indexOf(columnType, "(") > 0) {
  214 + String length = StringUtils.substringBetween(columnType, "(", ")");
  215 + return Integer.valueOf(length);
  216 + } else {
  217 + return 0;
  218 + }
198 219 }
199 220  
200   - public static void main(String[] args)
201   - {
202   - System.out.println(StringUtils.convertToCamelCase("userName"));
203   - System.out.println(replaceKeyword("岗位信息表"));
204   - System.out.println(getModuleName("com.huaheng.pc.system"));
  221 + /**
  222 + * 获取空数组列表
  223 + *
  224 + * @param length 长度
  225 + * @return 数组信息
  226 + */
  227 + public static String[] emptyList(int length) {
  228 + String[] values = new String[length];
  229 + for (int i = 0; i < length; i++) {
  230 + values[i] = StringUtils.EMPTY;
  231 + }
  232 + return values;
205 233 }
206 234 -}
  235 +}
207 236 \ No newline at end of file
... ...
src/main/resources/generator.yml 0 → 100644
  1 +# 代码生成
  2 +gen:
  3 + # 作者
  4 + author: huaheng
  5 + # 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool
  6 + packageName: com.huaheng.pc
  7 + # 自动去除表前缀,默认是false
  8 + autoRemovePre: false
  9 + # 表前缀(生成类名不会包含表前缀,多个用逗号分隔)
  10 + tablePrefix: sys_
0 11 \ No newline at end of file
... ...
src/main/resources/mybatis/system/DictTypeMapper.xml
... ... @@ -45,7 +45,12 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
45 45 </if>
46 46 </where>
47 47 </select>
48   -
  48 +
  49 + <select id="selectDictTypeByType" parameterType="String" resultMap="DictTypeResult">
  50 + <include refid="selectDictTypeVo"/>
  51 + where dictType = #{dictType}
  52 + </select>
  53 +
49 54 <select id="selectDictTypeAll" resultMap="DictTypeResult">
50 55 <include refid="selectDictTypeVo"/>
51 56 where warehouseCode=#{warehouseCode}
... ...
src/main/resources/mybatis/tool/GenTableColumnMapper.xml 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8" ?>
  2 +<!DOCTYPE mapper
  3 +PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4 +"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5 +<mapper namespace="com.huaheng.pc.tool.gen.mapper.GenTableColumnMapper">
  6 +
  7 + <resultMap type="com.huaheng.pc.tool.gen.domain.GenTableColumn" id="GenTableColumnResult">
  8 + <id property="columnId" column="column_id" />
  9 + <result property="tableId" column="table_id" />
  10 + <result property="columnName" column="column_name" />
  11 + <result property="columnComment" column="column_comment" />
  12 + <result property="columnType" column="column_type" />
  13 + <result property="javaType" column="java_type" />
  14 + <result property="javaField" column="java_field" />
  15 + <result property="isPk" column="is_pk" />
  16 + <result property="isIncrement" column="is_increment" />
  17 + <result property="isRequired" column="is_required" />
  18 + <result property="isInsert" column="is_insert" />
  19 + <result property="isEdit" column="is_edit" />
  20 + <result property="isList" column="is_list" />
  21 + <result property="isQuery" column="is_query" />
  22 + <result property="queryType" column="query_type" />
  23 + <result property="htmlType" column="html_type" />
  24 + <result property="dictType" column="dict_type" />
  25 + <result property="sort" column="sort" />
  26 + <result property="createBy" column="create_by" />
  27 + <result property="createTime" column="create_time" />
  28 + <result property="updateBy" column="update_by" />
  29 + <result property="updateTime" column="update_time" />
  30 + </resultMap>
  31 +
  32 + <sql id="selectGenTableColumnVo">
  33 + select column_id, table_id, column_name, column_comment, column_type, java_type, java_field, is_pk, is_increment, is_required, is_insert, is_edit, is_list, is_query, query_type, html_type, dict_type, sort, create_by, create_time, update_by, update_time from gen_table_column
  34 + </sql>
  35 +
  36 + <select id="selectGenTableColumnListByTableId" parameterType="com.huaheng.pc.tool.gen.domain.GenTableColumn" resultMap="GenTableColumnResult">
  37 + <include refid="selectGenTableColumnVo"/>
  38 + where table_id = #{tableId}
  39 + order by sort
  40 + </select>
  41 +
  42 + <select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult">
  43 + select column_name, (case when (is_nullable = 'no' <![CDATA[ && ]]> column_key != 'PRI') then '1' else null end) as is_required, (case when column_key = 'PRI' then '1' else '0' end) as is_pk, ordinal_position as sort, column_comment, (case when extra = 'auto_increment' then '1' else '0' end) as is_increment, column_type
  44 + from information_schema.columns where table_schema = (select database()) and table_name = (#{tableName})
  45 + order by ordinal_position
  46 + </select>
  47 +
  48 + <insert id="insertGenTableColumn" parameterType="com.huaheng.pc.tool.gen.domain.GenTableColumn" useGeneratedKeys="true" keyProperty="columnId">
  49 + insert into gen_table_column (
  50 + <if test="tableId != null and tableId != ''">table_id,</if>
  51 + <if test="columnName != null and columnName != ''">column_name,</if>
  52 + <if test="columnComment != null and columnComment != ''">column_comment,</if>
  53 + <if test="columnType != null and columnType != ''">column_type,</if>
  54 + <if test="javaType != null and javaType != ''">java_type,</if>
  55 + <if test="javaField != null and javaField != ''">java_field,</if>
  56 + <if test="isPk != null and isPk != ''">is_pk,</if>
  57 + <if test="isIncrement != null and isIncrement != ''">is_increment,</if>
  58 + <if test="isRequired != null and isRequired != ''">is_required,</if>
  59 + <if test="isInsert != null and isInsert != ''">is_insert,</if>
  60 + <if test="isEdit != null and isEdit != ''">is_edit,</if>
  61 + <if test="isList != null and isList != ''">is_list,</if>
  62 + <if test="isQuery != null and isQuery != ''">is_query,</if>
  63 + <if test="queryType != null and queryType != ''">query_type,</if>
  64 + <if test="htmlType != null and htmlType != ''">html_type,</if>
  65 + <if test="dictType != null and dictType != ''">dict_type,</if>
  66 + <if test="sort != null">sort,</if>
  67 + <if test="createBy != null and createBy != ''">create_by,</if>
  68 + create_time
  69 + )values(
  70 + <if test="tableId != null and tableId != ''">#{tableId},</if>
  71 + <if test="columnName != null and columnName != ''">#{columnName},</if>
  72 + <if test="columnComment != null and columnComment != ''">#{columnComment},</if>
  73 + <if test="columnType != null and columnType != ''">#{columnType},</if>
  74 + <if test="javaType != null and javaType != ''">#{javaType},</if>
  75 + <if test="javaField != null and javaField != ''">#{javaField},</if>
  76 + <if test="isPk != null and isPk != ''">#{isPk},</if>
  77 + <if test="isIncrement != null and isIncrement != ''">#{isIncrement},</if>
  78 + <if test="isRequired != null and isRequired != ''">#{isRequired},</if>
  79 + <if test="isInsert != null and isInsert != ''">#{isInsert},</if>
  80 + <if test="isEdit != null and isEdit != ''">#{isEdit},</if>
  81 + <if test="isList != null and isList != ''">#{isList},</if>
  82 + <if test="isQuery != null and isQuery != ''">#{isQuery},</if>
  83 + <if test="queryType != null and queryType != ''">#{queryType},</if>
  84 + <if test="htmlType != null and htmlType != ''">#{htmlType},</if>
  85 + <if test="dictType != null and dictType != ''">#{dictType},</if>
  86 + <if test="sort != null">#{sort},</if>
  87 + <if test="createBy != null and createBy != ''">#{createBy},</if>
  88 + sysdate()
  89 + )
  90 + </insert>
  91 +
  92 + <update id="updateGenTableColumn" parameterType="com.huaheng.pc.tool.gen.domain.GenTableColumn">
  93 + update gen_table_column
  94 + <set>
  95 + column_comment = #{columnComment},
  96 + java_type = #{javaType},
  97 + java_field = #{javaField},
  98 + is_insert = #{isInsert},
  99 + is_edit = #{isEdit},
  100 + is_list = #{isList},
  101 + is_query = #{isQuery},
  102 + is_required = #{isRequired},
  103 + query_type = #{queryType},
  104 + html_type = #{htmlType},
  105 + dict_type = #{dictType},
  106 + sort = #{sort},
  107 + update_by = #{updateBy},
  108 + update_time = sysdate()
  109 + </set>
  110 + where column_id = #{columnId}
  111 + </update>
  112 +
  113 + <delete id="deleteGenTableColumnByIds" parameterType="Long">
  114 + delete from gen_table_column where table_id in
  115 + <foreach collection="array" item="tableId" open="(" separator="," close=")">
  116 + #{tableId}
  117 + </foreach>
  118 + </delete>
  119 +
  120 +</mapper>
0 121 \ No newline at end of file
... ...
src/main/resources/mybatis/tool/GenTableMapper.xml 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8" ?>
  2 +<!DOCTYPE mapper
  3 +PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4 +"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5 +<mapper namespace="com.huaheng.pc.tool.gen.mapper.GenTableMapper">
  6 +
  7 + <resultMap type="com.huaheng.pc.tool.gen.domain.GenTable" id="GenTableResult">
  8 + <id property="tableId" column="table_id" />
  9 + <result property="tableName" column="table_name" />
  10 + <result property="tableComment" column="table_comment" />
  11 + <result property="subTableName" column="sub_table_name" />
  12 + <result property="subTableFkName" column="sub_table_fk_name" />
  13 + <result property="className" column="class_name" />
  14 + <result property="tplCategory" column="tpl_category" />
  15 + <result property="packageName" column="package_name" />
  16 + <result property="moduleName" column="module_name" />
  17 + <result property="businessName" column="business_name" />
  18 + <result property="functionName" column="function_name" />
  19 + <result property="functionAuthor" column="function_author" />
  20 + <result property="options" column="options" />
  21 + <result property="createBy" column="create_by" />
  22 + <result property="createTime" column="create_time" />
  23 + <result property="updateBy" column="update_by" />
  24 + <result property="updateTime" column="update_time" />
  25 + <result property="remark" column="remark" />
  26 + <collection property="columns" javaType="java.util.List" resultMap="GenTableColumnResult" />
  27 + </resultMap>
  28 +
  29 + <resultMap type="com.huaheng.pc.tool.gen.domain.GenTableColumn" id="GenTableColumnResult">
  30 + <id property="columnId" column="column_id" />
  31 + <result property="tableId" column="table_id" />
  32 + <result property="columnName" column="column_name" />
  33 + <result property="columnComment" column="column_comment" />
  34 + <result property="columnType" column="column_type" />
  35 + <result property="javaType" column="java_type" />
  36 + <result property="javaField" column="java_field" />
  37 + <result property="isPk" column="is_pk" />
  38 + <result property="isIncrement" column="is_increment" />
  39 + <result property="isRequired" column="is_required" />
  40 + <result property="isInsert" column="is_insert" />
  41 + <result property="isEdit" column="is_edit" />
  42 + <result property="isList" column="is_list" />
  43 + <result property="isQuery" column="is_query" />
  44 + <result property="queryType" column="query_type" />
  45 + <result property="htmlType" column="html_type" />
  46 + <result property="dictType" column="dict_type" />
  47 + <result property="sort" column="sort" />
  48 + <result property="createBy" column="create_by" />
  49 + <result property="createTime" column="create_time" />
  50 + <result property="updateBy" column="update_by" />
  51 + <result property="updateTime" column="update_time" />
  52 + </resultMap>
  53 +
  54 + <sql id="selectGenTableVo">
  55 + select table_id, table_name, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, options, create_by, create_time, update_by, update_time, remark from gen_table
  56 + </sql>
  57 +
  58 + <select id="selectGenTableList" parameterType="com.huaheng.pc.tool.gen.domain.GenTable" resultMap="GenTableResult">
  59 + <include refid="selectGenTableVo"/>
  60 + <where>
  61 + <if test="tableName != null and tableName != ''">
  62 + AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
  63 + </if>
  64 + <if test="tableComment != null and tableComment != ''">
  65 + AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
  66 + </if>
  67 + </where>
  68 + </select>
  69 +
  70 + <select id="selectDbTableList" parameterType="com.huaheng.pc.tool.gen.domain.GenTable" resultMap="GenTableResult">
  71 + select table_name, table_comment, create_time, update_time from information_schema.tables
  72 + where table_schema = (select database())
  73 + AND table_name NOT LIKE 'qrtz_%' AND table_name NOT LIKE 'gen_%'
  74 + AND table_name NOT IN (select table_name from gen_table)
  75 + <if test="tableName != null and tableName != ''">
  76 + AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
  77 + </if>
  78 + <if test="tableComment != null and tableComment != ''">
  79 + AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
  80 + </if>
  81 + </select>
  82 +
  83 + <select id="selectDbTableListByNames" resultMap="GenTableResult">
  84 + select table_name, table_comment, create_time, update_time from information_schema.tables
  85 + where table_name NOT LIKE 'qrtz_%' and table_name NOT LIKE 'gen_%' and table_schema = (select database())
  86 + and table_name in
  87 + <foreach collection="array" item="name" open="(" separator="," close=")">
  88 + #{name}
  89 + </foreach>
  90 + </select>
  91 +
  92 + <select id="selectTableByName" parameterType="String" resultMap="GenTableResult">
  93 + select table_name, table_comment, create_time, update_time from information_schema.tables
  94 + where table_comment <![CDATA[ <> ]]> '' and table_schema = (select database())
  95 + and table_name = #{tableName}
  96 + </select>
  97 +
  98 + <select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult">
  99 + SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark,
  100 + c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
  101 + FROM gen_table t
  102 + LEFT JOIN gen_table_column c ON t.table_id = c.table_id
  103 + where t.table_id = #{tableId} order by c.sort
  104 + </select>
  105 +
  106 + <select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
  107 + SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark,
  108 + c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
  109 + FROM gen_table t
  110 + LEFT JOIN gen_table_column c ON t.table_id = c.table_id
  111 + where t.table_name = #{tableName} order by c.sort
  112 + </select>
  113 +
  114 + <select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult">
  115 + SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark,
  116 + c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
  117 + FROM gen_table t
  118 + LEFT JOIN gen_table_column c ON t.table_id = c.table_id
  119 + order by c.sort
  120 + </select>
  121 +
  122 + <insert id="insertGenTable" parameterType="com.huaheng.pc.tool.gen.domain.GenTable" useGeneratedKeys="true" keyProperty="tableId">
  123 + insert into gen_table (
  124 + <if test="tableName != null">table_name,</if>
  125 + <if test="tableComment != null and tableComment != ''">table_comment,</if>
  126 + <if test="className != null and className != ''">class_name,</if>
  127 + <if test="tplCategory != null and tplCategory != ''">tpl_category,</if>
  128 + <if test="packageName != null and packageName != ''">package_name,</if>
  129 + <if test="moduleName != null and moduleName != ''">module_name,</if>
  130 + <if test="businessName != null and businessName != ''">business_name,</if>
  131 + <if test="functionName != null and functionName != ''">function_name,</if>
  132 + <if test="functionAuthor != null and functionAuthor != ''">function_author,</if>
  133 + <if test="remark != null and remark != ''">remark,</if>
  134 + <if test="createBy != null and createBy != ''">create_by,</if>
  135 + create_time
  136 + )values(
  137 + <if test="tableName != null">#{tableName},</if>
  138 + <if test="tableComment != null and tableComment != ''">#{tableComment},</if>
  139 + <if test="className != null and className != ''">#{className},</if>
  140 + <if test="tplCategory != null and tplCategory != ''">#{tplCategory},</if>
  141 + <if test="packageName != null and packageName != ''">#{packageName},</if>
  142 + <if test="moduleName != null and moduleName != ''">#{moduleName},</if>
  143 + <if test="businessName != null and businessName != ''">#{businessName},</if>
  144 + <if test="functionName != null and functionName != ''">#{functionName},</if>
  145 + <if test="functionAuthor != null and functionAuthor != ''">#{functionAuthor},</if>
  146 + <if test="remark != null and remark != ''">#{remark},</if>
  147 + <if test="createBy != null and createBy != ''">#{createBy},</if>
  148 + sysdate()
  149 + )
  150 + </insert>
  151 +
  152 + <update id="updateGenTable" parameterType="com.huaheng.pc.tool.gen.domain.GenTable">
  153 + update gen_table
  154 + <set>
  155 + <if test="tableName != null">table_name = #{tableName},</if>
  156 + <if test="tableComment != null and tableComment != ''">table_comment = #{tableComment},</if>
  157 + <if test="subTableName != null and subTableName != ''">sub_table_name = #{subTableName},</if>
  158 + <if test="subTableFkName != null and subTableFkName != ''">sub_table_fk_name = #{subTableFkName},</if>
  159 + <if test="className != null and className != ''">class_name = #{className},</if>
  160 + <if test="functionAuthor != null and functionAuthor != ''">function_author = #{functionAuthor},</if>
  161 + <if test="tplCategory != null and tplCategory != ''">tpl_category = #{tplCategory},</if>
  162 + <if test="packageName != null and packageName != ''">package_name = #{packageName},</if>
  163 + <if test="moduleName != null and moduleName != ''">module_name = #{moduleName},</if>
  164 + <if test="businessName != null and businessName != ''">business_name = #{businessName},</if>
  165 + <if test="functionName != null and functionName != ''">function_name = #{functionName},</if>
  166 + <if test="options != null and options != ''">options = #{options},</if>
  167 + <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
  168 + <if test="remark != null">remark = #{remark},</if>
  169 + update_time = sysdate()
  170 + </set>
  171 + where table_id = #{tableId}
  172 + </update>
  173 +
  174 + <delete id="deleteGenTableByIds" parameterType="Long">
  175 + delete from gen_table where table_id in
  176 + <foreach collection="array" item="tableId" open="(" separator="," close=")">
  177 + #{tableId}
  178 + </foreach>
  179 + </delete>
  180 +
  181 +</mapper>
0 182 \ No newline at end of file
... ...
src/main/resources/static/ajax/libs/bootstrap-fileinput/fileinput.css 0 → 100644
  1 +/*!
  2 + * bootstrap-fileinput v5.0.4
  3 + * http://plugins.krajee.com/file-input
  4 + *
  5 + * Krajee default styling for bootstrap-fileinput.
  6 + *
  7 + * Author: Kartik Visweswaran
  8 + * Copyright: 2014 - 2019, Kartik Visweswaran, Krajee.com
  9 + *
  10 + * Licensed under the BSD-3-Clause
  11 + * https://github.com/kartik-v/bootstrap-fileinput/blob/master/LICENSE.md
  12 + */
  13 +.file-loading input[type=file], input[type=file].file-loading {
  14 + width: 0;
  15 + height: 0;
  16 +}
  17 +
  18 +.file-no-browse {
  19 + position: absolute;
  20 + left: 50%;
  21 + bottom: 20%;
  22 + width: 1px;
  23 + height: 1px;
  24 + font-size: 0;
  25 + opacity: 0;
  26 + border: none;
  27 + background: none;
  28 + outline: none;
  29 + box-shadow: none;
  30 +}
  31 +
  32 +.kv-hidden, .file-caption-icon, .file-zoom-dialog .modal-header:before, .file-zoom-dialog .modal-header:after, .file-input-new .file-preview, .file-input-new .close, .file-input-new .glyphicon-file, .file-input-new .fileinput-remove-button, .file-input-new .fileinput-upload-button, .file-input-new .no-browse .input-group-btn, .file-input-ajax-new .fileinput-remove-button, .file-input-ajax-new .fileinput-upload-button, .file-input-ajax-new .no-browse .input-group-btn, .hide-content .kv-file-content, .is-locked .fileinput-upload-button, .is-locked .fileinput-remove-button {
  33 + display: none;
  34 +}
  35 +
  36 +.btn-file input[type=file], .file-caption-icon, .file-preview .fileinput-remove, .krajee-default .file-thumb-progress, .file-zoom-dialog .btn-navigate, .file-zoom-dialog .floating-buttons {
  37 + position: absolute;
  38 +}
  39 +
  40 +.file-caption-icon .kv-caption-icon {
  41 + line-height: inherit;
  42 +}
  43 +
  44 +.file-input, .file-loading:before, .btn-file, .file-caption, .file-preview, .krajee-default.file-preview-frame, .krajee-default .file-thumbnail-footer, .file-zoom-dialog .modal-dialog {
  45 + position: relative;
  46 +}
  47 +
  48 +.file-error-message pre, .file-error-message ul, .krajee-default .file-actions, .krajee-default .file-other-error {
  49 + text-align: left;
  50 +}
  51 +
  52 +.file-error-message pre, .file-error-message ul {
  53 + margin: 0;
  54 +}
  55 +
  56 +.krajee-default .file-drag-handle, .krajee-default .file-upload-indicator {
  57 + float: left;
  58 + margin-top: 10px;
  59 + width: 16px;
  60 + height: 16px;
  61 +}
  62 +
  63 +.krajee-default .file-thumb-progress .progress, .krajee-default .file-thumb-progress .progress-bar {
  64 + height: 20px;
  65 + font-family: Verdana, Helvetica, sans-serif;
  66 + font-size: 9px;
  67 +}
  68 +
  69 +.krajee-default .file-thumb-progress .progress, .kv-upload-progress .progress {
  70 + background-color: #ccc;
  71 +}
  72 +
  73 +.krajee-default .file-caption-info, .krajee-default .file-size-info {
  74 + display: block;
  75 + white-space: nowrap;
  76 + overflow: hidden;
  77 + text-overflow: ellipsis;
  78 + width: 160px;
  79 + height: 15px;
  80 + margin: auto;
  81 +}
  82 +
  83 +.file-zoom-content > .file-object.type-video, .file-zoom-content > .file-object.type-flash, .file-zoom-content > .file-object.type-image {
  84 + max-width: 100%;
  85 + max-height: 100%;
  86 + width: auto;
  87 +}
  88 +
  89 +.file-zoom-content > .file-object.type-video, .file-zoom-content > .file-object.type-flash {
  90 + height: 100%;
  91 +}
  92 +
  93 +.file-zoom-content > .file-object.type-pdf, .file-zoom-content > .file-object.type-html, .file-zoom-content > .file-object.type-text, .file-zoom-content > .file-object.type-default {
  94 + width: 100%;
  95 +}
  96 +
  97 +.file-loading:before {
  98 + content: " Loading...";
  99 + display: inline-block;
  100 + padding-left: 20px;
  101 + line-height: 16px;
  102 + font-size: 13px;
  103 + font-variant: small-caps;
  104 + color: #999;
  105 + background: transparent url(loading.gif) top left no-repeat;
  106 +}
  107 +
  108 +.file-object {
  109 + margin: 0 0 -5px 0;
  110 + padding: 0;
  111 +}
  112 +
  113 +.btn-file {
  114 + overflow: hidden;
  115 +}
  116 +
  117 +.btn-file input[type=file] {
  118 + top: 0;
  119 + left: 0;
  120 + min-width: 100%;
  121 + min-height: 100%;
  122 + text-align: right;
  123 + opacity: 0;
  124 + background: none repeat scroll 0 0 transparent;
  125 + cursor: inherit;
  126 + display: block;
  127 +}
  128 +
  129 +.btn-file ::-ms-browse {
  130 + font-size: 10000px;
  131 + width: 100%;
  132 + height: 100%;
  133 +}
  134 +
  135 +.file-caption .file-caption-name {
  136 + width: 100%;
  137 + margin: 0;
  138 + padding: 0;
  139 + box-shadow: none;
  140 + border: none;
  141 + background: none;
  142 + outline: none;
  143 +}
  144 +
  145 +.file-caption.icon-visible .file-caption-icon {
  146 + display: inline-block;
  147 +}
  148 +
  149 +.file-caption.icon-visible .file-caption-name {
  150 + padding-left: 15px;
  151 +}
  152 +
  153 +.file-caption-icon {
  154 + left: 8px;
  155 +}
  156 +
  157 +.file-error-message {
  158 + color: #a94442;
  159 + background-color: #f2dede;
  160 + margin: 5px;
  161 + border: 1px solid #ebccd1;
  162 + border-radius: 4px;
  163 + padding: 15px;
  164 +}
  165 +
  166 +.file-error-message pre {
  167 + margin: 5px 0;
  168 +}
  169 +
  170 +.file-caption-disabled {
  171 + background-color: #eee;
  172 + cursor: not-allowed;
  173 + opacity: 1;
  174 +}
  175 +
  176 +.file-preview {
  177 + border-radius: 5px;
  178 + border: 1px solid #ddd;
  179 + padding: 8px;
  180 + width: 100%;
  181 + margin-bottom: 5px;
  182 +}
  183 +
  184 +.file-preview .btn-xs {
  185 + padding: 1px 5px;
  186 + font-size: 12px;
  187 + line-height: 1.5;
  188 + border-radius: 3px;
  189 +}
  190 +
  191 +.file-preview .fileinput-remove {
  192 + top: 1px;
  193 + right: 1px;
  194 + line-height: 10px;
  195 +}
  196 +
  197 +.file-preview .clickable {
  198 + cursor: pointer;
  199 +}
  200 +
  201 +.file-preview-image {
  202 + font: 40px Impact, Charcoal, sans-serif;
  203 + color: #008000;
  204 +}
  205 +
  206 +.krajee-default.file-preview-frame {
  207 + margin: 8px;
  208 + border: 1px solid rgba(0,0,0,0.2);
  209 + box-shadow: 0 0 10px 0 rgba(0,0,0,0.2);
  210 + padding: 6px;
  211 + float: left;
  212 + text-align: center;
  213 +}
  214 +
  215 +.krajee-default.file-preview-frame .kv-file-content {
  216 + width: 213px;
  217 + height: 160px;
  218 +}
  219 +
  220 +.krajee-default .file-preview-other-frame {
  221 + display: flex;
  222 + align-items: center;
  223 + justify-content: center;
  224 +}
  225 +
  226 +.krajee-default.file-preview-frame .kv-file-content.kv-pdf-rendered {
  227 + width: 400px;
  228 +}
  229 +
  230 +.krajee-default.file-preview-frame[data-template="audio"] .kv-file-content {
  231 + width: 240px;
  232 + height: 55px;
  233 +}
  234 +
  235 +.krajee-default.file-preview-frame .file-thumbnail-footer {
  236 + height: 70px;
  237 +}
  238 +
  239 +.krajee-default.file-preview-frame:not(.file-preview-error):hover {
  240 + border: 1px solid rgba(0,0,0,0.3);
  241 + box-shadow: 0 0 10px 0 rgba(0,0,0,0.4);
  242 +}
  243 +
  244 +.krajee-default .file-preview-text {
  245 + display: block;
  246 + color: #428bca;
  247 + border: 1px solid #ddd;
  248 + font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
  249 + outline: none;
  250 + padding: 8px;
  251 + resize: none;
  252 +}
  253 +
  254 +.krajee-default .file-preview-html {
  255 + border: 1px solid #ddd;
  256 + padding: 8px;
  257 + overflow: auto;
  258 +}
  259 +
  260 +.krajee-default .file-other-icon {
  261 + font-size: 6em;
  262 + line-height: 1;
  263 +}
  264 +
  265 +.krajee-default .file-footer-buttons {
  266 + float: right;
  267 +}
  268 +
  269 +.krajee-default .file-footer-caption {
  270 + display: block;
  271 + text-align: center;
  272 + padding-top: 4px;
  273 + font-size: 11px;
  274 + color: #777;
  275 + margin-bottom: 30px;
  276 +}
  277 +
  278 +.file-upload-stats {
  279 + font-size: 10px;
  280 + text-align: center;
  281 + width: 100%;
  282 +}
  283 +
  284 +.kv-upload-progress .file-upload-stats {
  285 + font-size: 12px;
  286 + margin: -10px 0 5px;
  287 +}
  288 +
  289 +.krajee-default .file-preview-error {
  290 + opacity: 0.65;
  291 + box-shadow: none;
  292 +}
  293 +
  294 +.krajee-default .file-thumb-progress {
  295 + height: 11px;
  296 + top: 37px;
  297 + left: 0;
  298 + right: 0;
  299 +}
  300 +
  301 +.krajee-default.kvsortable-ghost {
  302 + background: #e1edf7;
  303 + border: 2px solid #a1abff;
  304 +}
  305 +
  306 +.krajee-default .file-preview-other:hover {
  307 + opacity: 0.8;
  308 +}
  309 +
  310 +.krajee-default .file-preview-frame:not(.file-preview-error) .file-footer-caption:hover {
  311 + color: #000;
  312 +}
  313 +
  314 +.kv-upload-progress .progress {
  315 + height: 20px;
  316 + margin: 10px 0;
  317 + overflow: hidden;
  318 +}
  319 +
  320 +.kv-upload-progress .progress-bar {
  321 + height: 20px;
  322 + font-family: Verdana, Helvetica, sans-serif;
  323 +}
  324 +
  325 +/*noinspection CssOverwrittenProperties*/
  326 +.file-zoom-dialog .file-other-icon {
  327 + font-size: 22em;
  328 + font-size: 50vmin;
  329 +}
  330 +
  331 +.file-zoom-dialog .modal-dialog {
  332 + width: auto;
  333 +}
  334 +
  335 +.file-zoom-dialog .modal-header {
  336 + display: flex;
  337 + align-items: center;
  338 + justify-content: space-between;
  339 +}
  340 +
  341 +.file-zoom-dialog .btn-navigate {
  342 + padding: 0;
  343 + margin: 0;
  344 + background: transparent;
  345 + text-decoration: none;
  346 + outline: none;
  347 + opacity: 0.7;
  348 + top: 45%;
  349 + font-size: 4em;
  350 + color: #1c94c4;
  351 +}
  352 +
  353 +.file-zoom-dialog .btn-navigate:not([disabled]):hover {
  354 + outline: none;
  355 + box-shadow: none;
  356 + opacity: 0.6;
  357 +}
  358 +
  359 +.file-zoom-dialog .floating-buttons {
  360 + top: 5px;
  361 + right: 10px;
  362 +}
  363 +
  364 +.file-zoom-dialog .btn-navigate[disabled] {
  365 + opacity: 0.3;
  366 +}
  367 +
  368 +.file-zoom-dialog .btn-prev {
  369 + left: 1px;
  370 +}
  371 +
  372 +.file-zoom-dialog .btn-next {
  373 + right: 1px;
  374 +}
  375 +
  376 +.file-zoom-dialog .kv-zoom-title {
  377 + font-weight: 300;
  378 + color: #999;
  379 + max-width: 50%;
  380 + overflow: hidden;
  381 + white-space: nowrap;
  382 + text-overflow: ellipsis;
  383 +}
  384 +
  385 +.file-input-new .no-browse .form-control {
  386 + border-top-right-radius: 4px;
  387 + border-bottom-right-radius: 4px;
  388 +}
  389 +
  390 +.file-input-ajax-new .no-browse .form-control {
  391 + border-top-right-radius: 4px;
  392 + border-bottom-right-radius: 4px;
  393 +}
  394 +
  395 +.file-caption-main {
  396 + width: 100%;
  397 +}
  398 +
  399 +.file-thumb-loading {
  400 + background: transparent url(loading.gif) no-repeat scroll center center content-box !important;
  401 +}
  402 +
  403 +.file-drop-zone {
  404 + border: 1px dashed #aaa;
  405 + border-radius: 4px;
  406 + text-align: center;
  407 + vertical-align: middle;
  408 + margin: 12px 15px 12px 12px;
  409 + padding: 5px;
  410 +}
  411 +
  412 +.file-drop-zone.clickable:hover {
  413 + border: 2px dashed #999;
  414 +}
  415 +
  416 +.file-drop-zone.clickable:focus {
  417 + border: 2px solid #5acde2;
  418 +}
  419 +
  420 +.file-drop-zone .file-preview-thumbnails {
  421 + cursor: default;
  422 +}
  423 +
  424 +.file-drop-zone-title {
  425 + color: #aaa;
  426 + font-size: 1.6em;
  427 + padding: 85px 10px;
  428 + cursor: default;
  429 +}
  430 +
  431 +.file-highlighted {
  432 + border: 2px dashed #999 !important;
  433 + background-color: #eee;
  434 +}
  435 +
  436 +.file-uploading {
  437 + background: url(loading-sm.gif) no-repeat center bottom 10px;
  438 + opacity: 0.65;
  439 +}
  440 +
  441 +.file-zoom-fullscreen .modal-dialog {
  442 + min-width: 100%;
  443 + margin: 0;
  444 +}
  445 +
  446 +.file-zoom-fullscreen .modal-content {
  447 + border-radius: 0;
  448 + box-shadow: none;
  449 + min-height: 100vh;
  450 +}
  451 +
  452 +.file-zoom-fullscreen .modal-body {
  453 + overflow-y: auto;
  454 +}
  455 +
  456 +.floating-buttons {
  457 + z-index: 3000;
  458 +}
  459 +
  460 +.floating-buttons .btn-kv {
  461 + margin-left: 3px;
  462 + z-index: 3000;
  463 +}
  464 +
  465 +.kv-zoom-actions .btn-kv {
  466 + margin-left: 3px;
  467 +}
  468 +
  469 +.file-zoom-content {
  470 + height: 480px;
  471 + text-align: center;
  472 +}
  473 +
  474 +.file-zoom-content .file-preview-image {
  475 + max-height: 100%;
  476 +}
  477 +
  478 +.file-zoom-content .file-preview-video {
  479 + max-height: 100%;
  480 +}
  481 +
  482 +.file-zoom-content > .file-object.type-image {
  483 + height: auto;
  484 + min-height: inherit;
  485 +}
  486 +
  487 +.file-zoom-content > .file-object.type-audio {
  488 + width: auto;
  489 + height: 30px;
  490 +}
  491 +
  492 +@media (min-width: 576px) {
  493 + .file-zoom-dialog .modal-dialog {
  494 + max-width: 500px;
  495 + }
  496 +}
  497 +
  498 +@media (min-width: 992px) {
  499 + .file-zoom-dialog .modal-lg {
  500 + max-width: 800px;
  501 + }
  502 +}
  503 +
  504 +@media (max-width: 767px) {
  505 + .file-preview-thumbnails {
  506 + display: flex;
  507 + justify-content: center;
  508 + align-items: center;
  509 + flex-direction: column;
  510 + }
  511 +
  512 + .file-zoom-dialog .modal-header {
  513 + flex-direction: column;
  514 + }
  515 +}
  516 +
  517 +@media (max-width: 350px) {
  518 + .krajee-default.file-preview-frame:not([data-template="audio"]) .kv-file-content {
  519 + width: 160px;
  520 + }
  521 +}
  522 +
  523 +@media (max-width: 420px) {
  524 + .krajee-default.file-preview-frame .kv-file-content.kv-pdf-rendered {
  525 + width: 100%;
  526 + }
  527 +}
  528 +
  529 +.file-loading[dir=rtl]:before {
  530 + background: transparent url(loading.gif) top right no-repeat;
  531 + padding-left: 0;
  532 + padding-right: 20px;
  533 +}
  534 +
  535 +.file-sortable .file-drag-handle {
  536 + cursor: move;
  537 + opacity: 1;
  538 +}
  539 +
  540 +.file-sortable .file-drag-handle:hover {
  541 + opacity: 0.7;
  542 +}
  543 +
  544 +.clickable .file-drop-zone-title {
  545 + cursor: pointer;
  546 +}
  547 +
  548 +.file-preview-initial.sortable-chosen {
  549 + background-color: #d9edf7;
  550 +}
0 551 \ No newline at end of file
... ...