From c6942e4ca126fa2d73b17a9849cbde94ab377e2f Mon Sep 17 00:00:00 2001 From: RB Date: Sun, 19 Feb 2023 17:20:23 +0800 Subject: [PATCH] fix: QueryDecorator with bizz --- .../java/com/rebuild/core/Application.java | 2 +- .../core/privileges/RoleBaseQueryFilter.java | 5 +--- .../com/rebuild/core/service/BaseService.java | 3 +- .../core/service/query/QueryDecorator.java | 8 +++-- .../web/assets/js/bizuser/user-view.js | 2 +- .../service/query/QueryDecoratorTest.java | 30 +++++++++++++++++++ 6 files changed, 41 insertions(+), 9 deletions(-) create mode 100644 src/test/java/com/rebuild/core/service/query/QueryDecoratorTest.java diff --git a/src/main/java/com/rebuild/core/Application.java b/src/main/java/com/rebuild/core/Application.java index 90907238f..a80abb885 100644 --- a/src/main/java/com/rebuild/core/Application.java +++ b/src/main/java/com/rebuild/core/Application.java @@ -71,7 +71,7 @@ public class Application implements ApplicationListener /** * Rebuild Build [MAJOR]{1}[MINOR]{2}[PATCH]{2}[BUILD]{2} */ - public static final int BUILD = 3020106; + public static final int BUILD = 3020107; static { // Driver for DB diff --git a/src/main/java/com/rebuild/core/privileges/RoleBaseQueryFilter.java b/src/main/java/com/rebuild/core/privileges/RoleBaseQueryFilter.java index 3712c2bd5..6edb73485 100644 --- a/src/main/java/com/rebuild/core/privileges/RoleBaseQueryFilter.java +++ b/src/main/java/com/rebuild/core/privileges/RoleBaseQueryFilter.java @@ -101,16 +101,14 @@ public class RoleBaseQueryFilter implements Filter, QueryFilter { Entity useMainEntity = null; if (!MetadataHelper.hasPrivilegesField(entity)) { - // NOTE BIZZ 实体全部用户可见 + // TODO BIZZ 实体全部用户可见??? if (MetadataHelper.isBizzEntity(entity) || EasyMetaFactory.valueOf(entity).isPlainEntity()) { return ALLOWED.evaluate(null); - } else if (entity.getMainEntity() != null) { useMainEntity = entity.getMainEntity(); } else { log.warn("None privileges entity use `Application#createQueryNoFilter` please : {} \n\t{}", entity, StringUtils.join(Thread.currentThread().getStackTrace(), "\n\t")); - return DENIED.evaluate(null); } } @@ -159,7 +157,6 @@ public class RoleBaseQueryFilter implements Filter, QueryFilter { if (depth == BizzDepthEntry.LOCAL) { return joinFilters(deptFilter, customFilter, shareFilter); - } else if (depth == BizzDepthEntry.DEEPDOWN) { Set set = new HashSet<>(); set.add(deptFilter); diff --git a/src/main/java/com/rebuild/core/service/BaseService.java b/src/main/java/com/rebuild/core/service/BaseService.java index fec79633b..548c44c8b 100644 --- a/src/main/java/com/rebuild/core/service/BaseService.java +++ b/src/main/java/com/rebuild/core/service/BaseService.java @@ -92,6 +92,7 @@ public class BaseService extends InternalPersistService { * @param record * @param isNew * @return + * @see DisplayType#N2NREFERENCE */ private Callable2 processN2NReference(final Record record, boolean isNew) { final Entity entity = record.getEntity(); @@ -221,7 +222,7 @@ public class BaseService extends InternalPersistService { * @param record * @param isNew * @return - * @see #processN2NReference(Record, boolean) + * @see DisplayType#TAG */ private Callable2 processTag(final Record record, boolean isNew) { final Entity entity = record.getEntity(); diff --git a/src/main/java/com/rebuild/core/service/query/QueryDecorator.java b/src/main/java/com/rebuild/core/service/query/QueryDecorator.java index 69d0fd7a0..7786b6715 100644 --- a/src/main/java/com/rebuild/core/service/query/QueryDecorator.java +++ b/src/main/java/com/rebuild/core/service/query/QueryDecorator.java @@ -7,6 +7,7 @@ See LICENSE and COMMERCIAL in the project root for license information. package com.rebuild.core.service.query; +import cn.devezhao.persist4j.Entity; import cn.devezhao.persist4j.Filter; import cn.devezhao.persist4j.PersistManagerFactory; import cn.devezhao.persist4j.query.AjqlQuery; @@ -29,9 +30,12 @@ public class QueryDecorator extends AjqlQuery { @Override public Result result() { - if (be == null) be = MetadataHelper.isBusinessEntity(getRootEntity()); + if (be == null) { + Entity e = getRootEntity(); + be = MetadataHelper.isBusinessEntity(e) || MetadataHelper.isBizzEntity(e); + } - // 仅业务实体用 + // 仅业务实体或BIZZ if (be) { if (result == null) result = new ResultDecorator(this); return result; diff --git a/src/main/resources/web/assets/js/bizuser/user-view.js b/src/main/resources/web/assets/js/bizuser/user-view.js index 356f4f905..fb2a98ad5 100644 --- a/src/main/resources/web/assets/js/bizuser/user-view.js +++ b/src/main/resources/web/assets/js/bizuser/user-view.js @@ -178,7 +178,7 @@ class DlgEnableUser extends RbModalHandler { super(props) if (props.enable) this._title = $L('激活用户') - else this._title = props.dept ? $L('修改部门') : $L('修改角色') + else this._title = props.deptSet ? $L('修改部门') : $L('修改角色') } render() { diff --git a/src/test/java/com/rebuild/core/service/query/QueryDecoratorTest.java b/src/test/java/com/rebuild/core/service/query/QueryDecoratorTest.java new file mode 100644 index 000000000..4da211874 --- /dev/null +++ b/src/test/java/com/rebuild/core/service/query/QueryDecoratorTest.java @@ -0,0 +1,30 @@ +/*! +Copyright (c) REBUILD and/or its owners. All rights reserved. + +rebuild is dual-licensed under commercial and open source licenses (GPLv3). +See LICENSE and COMMERCIAL in the project root for license information. +*/ + +package com.rebuild.core.service.query; + +import cn.devezhao.persist4j.Record; +import com.rebuild.TestSupport; +import com.rebuild.core.Application; +import org.junit.jupiter.api.Test; + +import java.util.Arrays; + +/** + * @author devezhao + * @since 02/19/2023 + */ +class QueryDecoratorTest extends TestSupport { + + @Test + void test() { + Record r = Application.createQueryNoFilter( + "select guanlibumen,userId from User where userId = '001-9000000000000001'") + .record(); + System.out.println(Arrays.toString(r.getIDArray("guanlibumen"))); + } +} \ No newline at end of file