From c2b88a03f3d0d5ebe92949e64d17ee4d0ac3f6b7 Mon Sep 17 00:00:00 2001
From: skyouc
Date: 星期二, 09 九月 2025 15:14:00 +0800
Subject: [PATCH] 发货清空缓存站点
---
zy-asrs-framework/src/main/java/com/zy/asrs/framework/generators/domain/Column.java | 577 +++++++++++++++++++++++++++++----------------------------
1 files changed, 292 insertions(+), 285 deletions(-)
diff --git a/zy-asrs-framework/src/main/java/com/zy/asrs/framework/generators/domain/Column.java b/zy-asrs-framework/src/main/java/com/zy/asrs/framework/generators/domain/Column.java
index 926c148..2eb3788 100644
--- a/zy-asrs-framework/src/main/java/com/zy/asrs/framework/generators/domain/Column.java
+++ b/zy-asrs-framework/src/main/java/com/zy/asrs/framework/generators/domain/Column.java
@@ -1,285 +1,292 @@
-package com.zy.asrs.framework.generators.domain;
-
-import com.zy.asrs.framework.common.Cools;
-import com.zy.asrs.framework.generators.CoolGenerator;
-import com.zy.asrs.framework.generators.constant.SqlOsType;
-import com.zy.asrs.framework.generators.utils.GeneratorUtils;
-
-import java.sql.Connection;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Created by vincent on 2019-06-18
- */
-public class Column {
-
- private String name; // 琛ㄥ瓧娈靛悕
- private String type; // 绫诲瀷
- private String comment; // 澶囨敞
- private String humpName; // 灏忛┘宄�
- private boolean primaryKey; // 鍞竴涓婚敭
- private boolean mainKey; // 鏅�氫富閿�
- private boolean notNull; // 闈炵┖
- private boolean major; // 涓昏
- private boolean image; // 鍥剧墖
- private boolean checkBox; // 澶嶉�夋
- private String foreignKey; // 澶栧仴瀹炰緥鍚�(澶ч┘宄�,濡俿ys_user ==> User)
- private String foreignKeyMajor; // 澶栭敭(灏忛┘宄�)
- private List<Map<String, Object>> enums; // 鏋氫妇鍊�
- private Integer length; // 瀛楁闀垮害
-
- public Column(Connection conn, String name, String type, String comment, boolean primaryKey, boolean mainKey, boolean notNull, Integer length, boolean init, SqlOsType sqlOsType) {
- this.name = name;
- this.type = type;
- this.comment = "";
- if (!Cools.isEmpty(comment)){
- // 鏋氫妇
- Pattern pattern1 = Pattern.compile("(.+?)(?=\\{)");
- Matcher matcher1 = pattern1.matcher(comment);
- // 澶栭敭
- Pattern pattern11 = Pattern.compile("(.+?)(?=\\[)");
- Matcher matcher11 = pattern11.matcher(comment);
- // 鏋氫妇
- if (matcher1.find()) {
- this.comment = matcher1.group();
- Pattern pattern2 = Pattern.compile("(?<=\\{)(.+?)(?=})");
- Matcher matcher2 = pattern2.matcher(comment);
- if (matcher2.find()) {
- String group = matcher2.group();
- if (!Cools.isEmpty(group)) {
- String[] values = group.split(",");
- this.enums = new ArrayList<>();
- for (String val : values) {
- Map<String, Object> map = new HashMap<>();
- String[] split = val.split(":");
- map.put(split[0], split[1]);
- enums.add(map);
- }
- }
- }
- // 澶栭敭
- } else if (matcher11.find()){
- this.comment = matcher11.group();
- Pattern pattern22 = Pattern.compile("(?<=\\[)(.+?)(?=])");
- Matcher matcher22 = pattern22.matcher(comment);
- if (matcher22.find()) {
- String group = matcher22.group();
- if (!Cools.isEmpty(group)) {
- this.foreignKey = GeneratorUtils.getNameSpace(group);
- List<Column> foreignColumns = new ArrayList<>();
- if (init) {
- try {
- switch (sqlOsType) {
- case MYSQL:
- foreignColumns = CoolGenerator.getMysqlColumns(conn, group, false, sqlOsType);
- break;
- case SQL_SERVER:
- foreignColumns = CoolGenerator.getSqlServerColumns(conn, group, false, sqlOsType);
- break;
- default:
- break;
- }
-
- } catch (Exception e){
- e.printStackTrace();
- }
- }
- if (!Cools.isEmpty(foreignColumns)){
- for (Column column : foreignColumns){
- if (column.isMajor()){
- this.foreignKeyMajor = GeneratorUtils.firstCharConvert(column.getHumpName(), false);
- }
- }
- if (Cools.isEmpty(this.foreignKeyMajor)){
- this.foreignKeyMajor = "Id";
- }
- }
- }
- }
- } else {
- this.comment = comment;
- }
- // 涓昏瀛楁
- if (comment.endsWith("(*)")){
- this.comment = comment.substring(0, comment.length()-3);
- this.major = true;
- }
- // 鍥剧墖瀛楁
- if (comment.endsWith("(img)")){
- this.comment = comment.substring(0, comment.length()-5);
- this.image = true;
- }
- // 澶嶉�夋
- if (comment.endsWith("(checkbox)")){
- this.comment = comment.substring(0, comment.length()-10);
- this.checkBox = true;
- }
- }
-// if (primaryKey || mainKey){
-// this.primaryKey = true;
-// } else {
-// this.primaryKey = false;
-// }
- this.primaryKey = primaryKey;
- this.mainKey = mainKey;
- this.notNull = notNull;
- this.length = length;
- this.humpName = GeneratorUtils._convert(name);
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(final String name) {
- this.name = name;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(final String type) {
- this.type = type;
- }
-
- public String getComment() {
- return comment;
- }
-
- public String getWholeComment() {
- if (!Cools.isEmpty(this.enums)){
- StringBuilder sb = new StringBuilder(" ");
- for (Map<String, Object> val : enums){
- for (Map.Entry<String, Object> entry : val.entrySet()){
- sb.append(entry.getKey())
- .append(": ")
- .append(entry.getValue())
- .append(" ");
- }
- }
- return comment + sb.toString();
- }
- return comment;
- }
-
- public void setComment(final String comment) {
- this.comment = comment;
- }
-
- public String getHumpName() {
- return humpName;
- }
-
-// public boolean isPrimaryKey() {
-// return primaryKey || mainKey;
-// }
-
- public boolean isPrimaryKey() {
- return primaryKey;
- }
-
- public boolean isOnly(){
- return primaryKey;
- }
-
- public void setPrimaryKey(boolean primaryKey) {
- this.primaryKey = primaryKey;
- }
-
- public boolean isNotNull() {
- return notNull;
- }
-
- public void setNotNull(final boolean notNull) {
- this.notNull = notNull;
- }
-
- public String getForeignKey() {
- return foreignKey;
- }
-
- public void setForeignKey(final String foreignKey) {
- this.foreignKey = foreignKey;
- }
-
- public String getForeignKeyMajor() {
- return foreignKeyMajor;
- }
-
- public void setForeignKeyMajor(final String foreignKeyMajor) {
- this.foreignKeyMajor = foreignKeyMajor;
- }
-
- public List<Map<String, Object>> getEnums() {
- return enums;
- }
-
- public void setEnums(List<Map<String, Object>> enums) {
- this.enums = enums;
- }
-
- public Integer getLength() {
- return length;
- }
-
- public void setLength(final Integer length) {
- this.length = length;
- }
-
- public boolean isMajor() {
- return major;
- }
-
- public void setMajor(final boolean major) {
- this.major = major;
- }
-
- public boolean isImage() {
- return image;
- }
-
- public void setImage(final boolean image) {
- this.image = image;
- }
-
- public boolean isCheckBox() {
- return checkBox;
- }
-
- public void setCheckBox(boolean checkBox) {
- this.checkBox = checkBox;
- }
-
- public boolean isMainKey() {
- return mainKey;
- }
-
- public void setMainKey(boolean mainKey) {
- this.mainKey = mainKey;
- }
-
- @Override
- public String toString() {
- return "Column{" +
- "name='" + name + '\'' +
- ", type='" + type + '\'' +
- ", comment='" + comment + '\'' +
- ", humpName='" + humpName + '\'' +
- ", primaryKey=" + primaryKey +
- ", notNull=" + notNull +
- ", major=" + major +
- ", image=" + image +
- ", foreignKey='" + foreignKey + '\'' +
- ", foreignKeyMajor='" + foreignKeyMajor + '\'' +
- ", enums=" + enums +
- ", length=" + length +
- '}';
- }
-
-}
+package com.zy.asrs.framework.generators.domain;
+
+import com.zy.asrs.framework.common.Cools;
+import com.zy.asrs.framework.generators.CoolGenerator;
+import com.zy.asrs.framework.generators.constant.SqlOsType;
+import com.zy.asrs.framework.generators.utils.GeneratorUtils;
+
+import java.sql.Connection;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Created by vincent on 2019-06-18
+ */
+public class Column {
+
+ private String name; // 琛ㄥ瓧娈靛悕
+ private String type; // 绫诲瀷
+ private String comment; // 澶囨敞
+ private String humpName; // 灏忛┘宄�
+ private boolean primaryKey; // 鍞竴涓婚敭
+ private boolean mainKey; // 鏅�氫富閿�
+ private boolean notNull; // 闈炵┖
+ private boolean major; // 涓昏
+ private boolean image; // 鍥剧墖
+ private boolean checkBox; // 澶嶉�夋
+ private String foreignKey; // 澶栧仴瀹炰緥鍚�(澶ч┘宄�,濡俿ys_user ==> User)
+ private String foreignKeyMajor; // 澶栭敭(灏忛┘宄�)
+ private List<Map<String, Object>> enums; // 鏋氫妇鍊�
+ private Integer length; // 瀛楁闀垮害
+
+ public Column(Connection conn, String name, String type, String comment, boolean primaryKey, boolean mainKey, boolean notNull, Integer length, boolean init, SqlOsType sqlOsType) {
+ this.name = name;
+ this.type = type;
+ this.comment = "";
+ if (!Cools.isEmpty(comment)){
+ // 鏋氫妇
+ Pattern pattern1 = Pattern.compile("(.+?)(?=\\{)");
+ Matcher matcher1 = pattern1.matcher(comment);
+ // 澶栭敭
+ Pattern pattern11 = Pattern.compile("(.+?)(?=\\[)");
+ Matcher matcher11 = pattern11.matcher(comment);
+ // 鏋氫妇
+ if (matcher1.find()) {
+ this.comment = matcher1.group();
+ Pattern pattern2 = Pattern.compile("(?<=\\{)(.+?)(?=})");
+ Matcher matcher2 = pattern2.matcher(comment);
+ if (matcher2.find()) {
+ String group = matcher2.group();
+ if (!Cools.isEmpty(group)) {
+ String[] values = group.split(",");
+ this.enums = new ArrayList<>();
+ for (String val : values) {
+ Map<String, Object> map = new HashMap<>();
+ String[] split = val.split(":");
+ map.put(split[0], split[1]);
+ enums.add(map);
+ }
+ }
+ }
+ // 澶栭敭
+ } else if (matcher11.find()){
+ this.comment = matcher11.group();
+ Pattern pattern22 = Pattern.compile("(?<=\\[)(.+?)(?=])");
+ Matcher matcher22 = pattern22.matcher(comment);
+ if (matcher22.find()) {
+ String group = matcher22.group();
+ if (!Cools.isEmpty(group)) {
+ this.foreignKey = GeneratorUtils.getNameSpace(group);
+ List<Column> foreignColumns = new ArrayList<>();
+ if (init) {
+ try {
+ switch (sqlOsType) {
+ case MYSQL:
+ foreignColumns = CoolGenerator.getMysqlColumns(conn, group, false, sqlOsType);
+ break;
+ case SQL_SERVER:
+ foreignColumns = CoolGenerator.getSqlServerColumns(conn, group, false, sqlOsType);
+ break;
+ default:
+ break;
+ }
+
+ } catch (Exception e){
+ e.printStackTrace();
+ }
+ }
+ if (!Cools.isEmpty(foreignColumns)){
+ for (Column column : foreignColumns){
+ if (column.isMajor()){
+ this.foreignKeyMajor = GeneratorUtils.firstCharConvert(column.getHumpName(), false);
+ }
+ }
+ if (Cools.isEmpty(this.foreignKeyMajor)){
+ this.foreignKeyMajor = "Id";
+ }
+ }
+ }
+ }
+ } else {
+ this.comment = comment;
+ }
+ // 涓昏瀛楁
+ if (comment.endsWith("(*)")){
+ this.comment = comment.substring(0, comment.length()-3);
+ this.major = true;
+ }
+ // 鍥剧墖瀛楁
+ if (comment.endsWith("(img)")){
+ this.comment = comment.substring(0, comment.length()-5);
+ this.image = true;
+ }
+ // 澶嶉�夋
+ if (comment.endsWith("(checkbox)")){
+ this.comment = comment.substring(0, comment.length()-10);
+ this.checkBox = true;
+ }
+ }
+// if (primaryKey || mainKey){
+// this.primaryKey = true;
+// } else {
+// this.primaryKey = false;
+// }
+ this.primaryKey = primaryKey;
+ this.mainKey = mainKey;
+ this.notNull = notNull;
+ this.length = length;
+ this.humpName = GeneratorUtils._convert(name);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(final String type) {
+ this.type = type;
+ }
+
+ public String getComment() {
+ return comment;
+ }
+
+ public String getWholeComment() {
+ if (!Cools.isEmpty(this.enums)){
+ StringBuilder sb = new StringBuilder(" ");
+ for (Map<String, Object> val : enums){
+ for (Map.Entry<String, Object> entry : val.entrySet()){
+ sb.append(entry.getKey())
+ .append(": ")
+ .append(entry.getValue())
+ .append(" ");
+ }
+ }
+ return comment + sb.toString();
+ }
+ return comment;
+ }
+
+ public void setComment(final String comment) {
+ this.comment = comment;
+ }
+
+ public String getHumpName() {
+ return humpName;
+ }
+
+// public boolean isPrimaryKey() {
+// return primaryKey || mainKey;
+// }
+
+ public boolean isPrimaryKey() {
+ return primaryKey;
+ }
+
+ public boolean isOnly(){
+ return primaryKey;
+ }
+
+ public void setPrimaryKey(boolean primaryKey) {
+ this.primaryKey = primaryKey;
+ }
+
+ public boolean isNotNull() {
+ return notNull;
+ }
+
+ public void setNotNull(final boolean notNull) {
+ this.notNull = notNull;
+ }
+
+ public String getForeignKey() {
+ return foreignKey;
+ }
+
+ public String getForeignKey$() {
+ if (this.foreignKey != null) {
+ return this.foreignKey.substring(0, 1).toLowerCase() + this.foreignKey.substring(1);
+ }
+ return foreignKey;
+ }
+
+ public void setForeignKey(final String foreignKey) {
+ this.foreignKey = foreignKey;
+ }
+
+ public String getForeignKeyMajor() {
+ return foreignKeyMajor;
+ }
+
+ public void setForeignKeyMajor(final String foreignKeyMajor) {
+ this.foreignKeyMajor = foreignKeyMajor;
+ }
+
+ public List<Map<String, Object>> getEnums() {
+ return enums;
+ }
+
+ public void setEnums(List<Map<String, Object>> enums) {
+ this.enums = enums;
+ }
+
+ public Integer getLength() {
+ return length;
+ }
+
+ public void setLength(final Integer length) {
+ this.length = length;
+ }
+
+ public boolean isMajor() {
+ return major;
+ }
+
+ public void setMajor(final boolean major) {
+ this.major = major;
+ }
+
+ public boolean isImage() {
+ return image;
+ }
+
+ public void setImage(final boolean image) {
+ this.image = image;
+ }
+
+ public boolean isCheckBox() {
+ return checkBox;
+ }
+
+ public void setCheckBox(boolean checkBox) {
+ this.checkBox = checkBox;
+ }
+
+ public boolean isMainKey() {
+ return mainKey;
+ }
+
+ public void setMainKey(boolean mainKey) {
+ this.mainKey = mainKey;
+ }
+
+ @Override
+ public String toString() {
+ return "Column{" +
+ "name='" + name + '\'' +
+ ", type='" + type + '\'' +
+ ", comment='" + comment + '\'' +
+ ", humpName='" + humpName + '\'' +
+ ", primaryKey=" + primaryKey +
+ ", notNull=" + notNull +
+ ", major=" + major +
+ ", image=" + image +
+ ", foreignKey='" + foreignKey + '\'' +
+ ", foreignKeyMajor='" + foreignKeyMajor + '\'' +
+ ", enums=" + enums +
+ ", length=" + length +
+ '}';
+ }
+
+}
--
Gitblit v1.9.1