You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.5 KiB
46 lines
1.5 KiB
package org.yangliu.codegenerate.util;
|
|
|
|
import com.google.common.base.CaseFormat;
|
|
import org.yangliu.codegenerate.util.fieldType.DbColumnType;
|
|
import org.yangliu.codegenerate.util.fieldType.MySqlTypeConvert;
|
|
import org.yangliu.codegenerate.util.fieldType.PostgreSqlTypeConvert;
|
|
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* @Description
|
|
* @Author ZhouWenTao
|
|
* @Date 2023/8/13 21:54
|
|
*/
|
|
public class TableFieldUtil {
|
|
private static List<String> strArray= Arrays.asList("char","varchar","text","xml");
|
|
|
|
|
|
private static List<String> integerArray= Arrays.asList("int","int2","int4","int8","text","xml");
|
|
|
|
/**
|
|
* 将 数据库字段类型转成 java类型
|
|
* @param fieldType
|
|
* @return
|
|
*/
|
|
public static String fieldTypeParseJava(String databaseType,String fieldType){
|
|
if (databaseType.equals("mysql")) {
|
|
DbColumnType dbColumnType = MySqlTypeConvert.processTypeConvert(fieldType);
|
|
return dbColumnType.getType();
|
|
}else if(databaseType.equals("postgresql")){
|
|
DbColumnType dbColumnType = PostgreSqlTypeConvert.processTypeConvert(fieldType);
|
|
return dbColumnType.getType();
|
|
}
|
|
System.out.println("暂不支持该数据库");
|
|
return null;
|
|
}
|
|
|
|
|
|
public static String tableNameToEntityName(String tableName){
|
|
String to = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, tableName);
|
|
String orderColumn = CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL,to);
|
|
return orderColumn;
|
|
}
|
|
}
|