没导入表备注bug
This commit is contained in:
+49
-1
@@ -19,8 +19,10 @@ import org.apache.commons.lang.StringUtils;
|
||||
import com.jero.codegenerate.database.util.CodeStringUtils;
|
||||
import com.jero.codegenerate.generate.pojo.ColumnVo;
|
||||
import com.jero.codegenerate.generate.util.TableConvert;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DbReadTableUtil {
|
||||
|
||||
private static Connection connection;
|
||||
@@ -32,7 +34,6 @@ public class DbReadTableUtil {
|
||||
private static final String CONNECT_DATABASE_NAME = " connect databaseName : ";
|
||||
private static final String COLUMN_GET_FIELD_NAME = "columnt.getFieldName() -------------";
|
||||
|
||||
|
||||
public static void main(String[] args) throws SQLException {
|
||||
try {
|
||||
List<ColumnVo> list = listColumns("demo");
|
||||
@@ -526,4 +527,51 @@ public class DbReadTableUtil {
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
//获取当前使用数据库名
|
||||
public String database() throws Exception {
|
||||
Class.forName(com.jero.codegenerate.properties.CodeConfigProperties.driverName);
|
||||
connection = DriverManager.getConnection(com.jero.codegenerate.properties.CodeConfigProperties.databaseUrl, com.jero.codegenerate.properties.CodeConfigProperties.username, com.jero.codegenerate.properties.CodeConfigProperties.password);
|
||||
statement = connection.createStatement(1005, 1007);
|
||||
String sqlStr = "select database()";
|
||||
ResultSet resultSet = statement.executeQuery(sqlStr);
|
||||
while(resultSet.next()) {
|
||||
String name = resultSet.getString(1);
|
||||
this.release(connection,statement);
|
||||
return name;
|
||||
}
|
||||
this.release(connection,statement);
|
||||
return "";
|
||||
}
|
||||
|
||||
//通过表名获取表备注
|
||||
public String remarks(String a) throws Exception {
|
||||
String database = this.database();
|
||||
|
||||
Class.forName(com.jero.codegenerate.properties.CodeConfigProperties.driverName);
|
||||
connection = DriverManager.getConnection(com.jero.codegenerate.properties.CodeConfigProperties.databaseUrl, com.jero.codegenerate.properties.CodeConfigProperties.username, com.jero.codegenerate.properties.CodeConfigProperties.password);
|
||||
statement = connection.createStatement(1005, 1007);
|
||||
|
||||
String sqlStr = "SELECT table_comment FROM information_schema.TABLES WHERE table_schema = " + "'"+database+"'" + " AND table_name = " + "'"+a+"'";
|
||||
ResultSet resultSet = statement.executeQuery(sqlStr);
|
||||
while(resultSet.next()) {
|
||||
String name = resultSet.getString(1);
|
||||
this.release(connection,statement);
|
||||
return name;
|
||||
}
|
||||
this.release(connection,statement);
|
||||
return "";
|
||||
}
|
||||
|
||||
//释放连接资源
|
||||
public void release(Connection connection, Statement statement) throws Exception {
|
||||
if (statement != null) {
|
||||
statement.close();
|
||||
statement = null;
|
||||
}
|
||||
if (connection != null) {
|
||||
connection.close();
|
||||
connection = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
-1
@@ -89,6 +89,8 @@ public class OnlCgformHeadServiceImpl extends ServiceImpl<OnlCgformHeadMapper, O
|
||||
private DataBaseConfig dataBaseConfig;
|
||||
@Autowired
|
||||
private IOnlAuthPageService onlAuthPageService;
|
||||
@Autowired
|
||||
private DbReadTableUtil dbReadTableUtil;
|
||||
|
||||
private static final String CONF_IS_NULL = "实体配置不存在";
|
||||
private static final String DB_ID = "数据库主表ID[";
|
||||
@@ -497,7 +499,13 @@ public class OnlCgformHeadServiceImpl extends ServiceImpl<OnlCgformHeadMapper, O
|
||||
var2.setIsPage("Y");
|
||||
var2.setQueryMode("group");
|
||||
var2.setTableName(tbname.toLowerCase());
|
||||
var2.setTableTxt(tbname);
|
||||
String remarks = "";
|
||||
try {
|
||||
remarks = dbReadTableUtil.remarks(tbname);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
var2.setTableTxt(remarks);
|
||||
var2.setTableVersion(1);
|
||||
var2.setFormTemplate("1");
|
||||
var2.setCopyType(0);
|
||||
|
||||
Reference in New Issue
Block a user