Skip to content

Commit

Permalink
索引导致导入异常,主键、外键排序至第一位
Browse files Browse the repository at this point in the history
  • Loading branch information
NiccoloTang committed Apr 9, 2017
1 parent 2fb43d3 commit 100c540
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions api/src/main/java/cn/crap/utils/SqlToDictionaryUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -115,7 +117,13 @@ public static Article mysqlToDictionary(String sql, String brief, String moduleI
}
List<DictionaryDto> fieldList = new ArrayList<DictionaryDto>();
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;
Expand Down Expand Up @@ -219,7 +227,13 @@ public static Article sqlserviceToDictionary(String sql, String brief, String mo
}
List<DictionaryDto> fieldList = new ArrayList<DictionaryDto>();
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;
Expand Down

0 comments on commit 100c540

Please sign in to comment.