better quickfields

This commit is contained in:
devezhao 2020-12-29 20:55:46 +08:00
parent 8893547f19
commit df180ca360
4 changed files with 16 additions and 10 deletions

View file

@ -170,9 +170,13 @@ public class ParseHelper {
// 引用字段要保证其兼容 LIKE 条件的语法要求
if (dt == DisplayType.REFERENCE) {
Field nameField = field.getOwnEntity().getNameField();
if (nameField.getType() == FieldType.REFERENCE) {
log.warn("Quick field cannot be circular reference : " + nameField);
return null;
}
if (nameField.getType() == FieldType.REFERENCE) return null;
else return useQuickField(nameField);
String can = useQuickField(nameField);
return can == null ? null : (QueryCompiler.NAME_FIELD_PREFIX + field.getName());
} else if (dt == DisplayType.PICKLIST
|| dt == DisplayType.CLASSIFICATION) {
@ -212,7 +216,7 @@ public class ParseHelper {
if (validField != null) {
String can = useQuickField(validField);
if (can != null) {
usesFields.add(field);
usesFields.add(can);
}
} else {

View file

@ -215,11 +215,10 @@ public class QueryParser {
}
this.sql = fullSql.toString();
this.countSql = new StringBuilder("select ")
.append("count(").append(pkName).append(')')
.append(" from ").append(entity.getName())
.append(" where ").append(sqlWhere)
.toString();
this.countSql = "select " +
"count(" + pkName + ')' +
" from " + entity.getName() +
" where " + sqlWhere;
int pageNo = NumberUtils.toInt(queryExpr.getString("pageNo"), 1);
int pageSize = NumberUtils.toInt(queryExpr.getString("pageSize"), 20);

View file

@ -29,6 +29,7 @@
<logger name="cn.devezhao.persist4j" level="WARN" />
<logger name="org.apache.commons.digester" level="ERROR" />
<logger name="com.rebuild.core" level="INFO" />
<!-- <logger name="cn.devezhao.persist4j.query.AjqlResultImpl" level="DEBUG" />-->
<!-- <logger name="org.springframework.transaction.support" level="DEBUG" />-->
<!-- <logger name="org.springframework.jdbc.datasource" level="DEBUG" />-->

View file

@ -107,6 +107,8 @@ $(document).ready(function () {
.trigger('change')
// 快速查询
// 非系统级引用字段
const _SYS_REF_FIELDS = ['createdBy', 'modifiedBy', 'owningUser', 'owningDept', 'approvalId']
const cQuickFields = d.data.map((item) => {
const canQuick =
item.type === 'TEXT' ||
@ -118,7 +120,7 @@ $(document).ready(function () {
item.type === 'CLASSIFICATION' ||
// item.type === 'DATE' ||
// item.type === 'DATETIME'
(item.type === 'REFERENCE' && item.creatable) // 非系统级引用字段
(item.type === 'REFERENCE' && _SYS_REF_FIELDS.indexOf(item.name) === -1)
return {
id: item.name,