From 100c540bfc473746d793755ac305cd58b02beca6 Mon Sep 17 00:00:00 2001 From: IhsanTang Date: Sun, 9 Apr 2017 21:19:04 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B4=A2=E5=BC=95=E5=AF=BC=E8=87=B4=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E5=BC=82=E5=B8=B8=EF=BC=8C=E4=B8=BB=E9=94=AE=E3=80=81?= =?UTF-8?q?=E5=A4=96=E9=94=AE=E6=8E=92=E5=BA=8F=E8=87=B3=E7=AC=AC=E4=B8=80?= =?UTF-8?q?=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/crap/utils/SqlToDictionaryUtil.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/cn/crap/utils/SqlToDictionaryUtil.java b/api/src/main/java/cn/crap/utils/SqlToDictionaryUtil.java index 119759285..f2be7c25b 100644 --- a/api/src/main/java/cn/crap/utils/SqlToDictionaryUtil.java +++ b/api/src/main/java/cn/crap/utils/SqlToDictionaryUtil.java @@ -19,6 +19,8 @@ public static Article mysqlToDictionary(String sql, String brief, String moduleI if(!sql.toLowerCase().replaceAll(" ", "").startsWith("createtable")){ throw new MyException("000046"); } + // 联合主键等被切分 + sql = sql.replace("`,`", ""); Article article = new Article(); article.setType(ArticleType.DICTIONARY.name()); article.setBrief(brief); @@ -115,7 +117,13 @@ public static Article mysqlToDictionary(String sql, String brief, String moduleI } List fieldList = new ArrayList(); for(String key: propertys.keySet()){ - fieldList.add(propertys.get(key)); + if( propertys.get(key).getFlag().equals( DictionaryPropertyType.primary.getName() ) + || propertys.get(key).getFlag().equals( DictionaryPropertyType.foreign.getName() ) + || propertys.get(key).getFlag().equals( DictionaryPropertyType.associate.getName() ) ){ + fieldList.add(0,propertys.get(key)); + }else{ + fieldList.add(propertys.get(key)); + } } article.setContent(JSONArray.fromObject(fieldList).toString()); return article; @@ -219,7 +227,13 @@ public static Article sqlserviceToDictionary(String sql, String brief, String mo } List fieldList = new ArrayList(); for(String key: propertys.keySet()){ - fieldList.add(propertys.get(key)); + if( propertys.get(key).getFlag().equals( DictionaryPropertyType.primary.getName() ) + || propertys.get(key).getFlag().equals( DictionaryPropertyType.foreign.getName() ) + || propertys.get(key).getFlag().equals( DictionaryPropertyType.associate.getName() ) ){ + fieldList.add(0,propertys.get(key)); + }else{ + fieldList.add(propertys.get(key)); + } } article.setContent(JSONArray.fromObject(fieldList).toString()); return article;