dao.getEntity(TableInfo.class).getField(orderByColumn); dao.getEntity 除此之外 还有没有方法 可以获取
定义抽象类 封装不同数控 查询表 那么问题来了
MappingField field =dao.getEntity(TableInfo.class).getField(orderByColumn);
这个类 没有dao 有没有方法可以替代 dao.getEntity(TableInfo.class)
public class MySqlQuery extends AbstractDbQuery {
@Override
public Sql tableList(String tableName, String tableComment, String orderByColumn, String isAsc) {
String sqlstr = "select table_name, table_comment, create_time, update_time from information_schema.tables " +
"where table_comment <> '' and table_schema = (select database()) ";
if (Strings.isNotBlank(tableName)) {
sqlstr += "and table_name like @tableName";
}
if (Strings.isNotBlank(tableComment)) {
sqlstr += "and table_comment like @tableComment";
}
if (Strings.isNotBlank(orderByColumn) && Strings.isNotBlank(isAsc)) {
MappingField field =dao.getEntity(TableInfo.class).getField(orderByColumn);
if(Lang.isNotEmpty(field)){
sqlstr += " order by " + field.getColumnName() + " " + isAsc;
}
}
Sql sql = Sqls.create(sqlstr);
sql.params().set("tableName", "%" + tableName + "%");
sql.params().set("tableComment", "%" + tableComment + "%");
sql.setCallback(Sqls.callback.entities());
return sql;
}
@Override
public Sql tableByName(String tableName) {
return null;
}
@Override
public Sql selectTableColumnsByName(String tableName) {
return null;
}
}