fix: QueryDecorator with bizz

This commit is contained in:
RB 2023-02-19 17:20:23 +08:00
parent 0b2cc23eab
commit c6942e4ca1
6 changed files with 41 additions and 9 deletions

View file

@ -71,7 +71,7 @@ public class Application implements ApplicationListener<ApplicationStartedEvent>
/** /**
* Rebuild Build [MAJOR]{1}[MINOR]{2}[PATCH]{2}[BUILD]{2} * Rebuild Build [MAJOR]{1}[MINOR]{2}[PATCH]{2}[BUILD]{2}
*/ */
public static final int BUILD = 3020106; public static final int BUILD = 3020107;
static { static {
// Driver for DB // Driver for DB

View file

@ -101,16 +101,14 @@ public class RoleBaseQueryFilter implements Filter, QueryFilter {
Entity useMainEntity = null; Entity useMainEntity = null;
if (!MetadataHelper.hasPrivilegesField(entity)) { if (!MetadataHelper.hasPrivilegesField(entity)) {
// NOTE BIZZ 实体全部用户可见 // TODO BIZZ 实体全部用户可见???
if (MetadataHelper.isBizzEntity(entity) || EasyMetaFactory.valueOf(entity).isPlainEntity()) { if (MetadataHelper.isBizzEntity(entity) || EasyMetaFactory.valueOf(entity).isPlainEntity()) {
return ALLOWED.evaluate(null); return ALLOWED.evaluate(null);
} else if (entity.getMainEntity() != null) { } else if (entity.getMainEntity() != null) {
useMainEntity = entity.getMainEntity(); useMainEntity = entity.getMainEntity();
} else { } else {
log.warn("None privileges entity use `Application#createQueryNoFilter` please : {} \n\t{}", log.warn("None privileges entity use `Application#createQueryNoFilter` please : {} \n\t{}",
entity, StringUtils.join(Thread.currentThread().getStackTrace(), "\n\t")); entity, StringUtils.join(Thread.currentThread().getStackTrace(), "\n\t"));
return DENIED.evaluate(null); return DENIED.evaluate(null);
} }
} }
@ -159,7 +157,6 @@ public class RoleBaseQueryFilter implements Filter, QueryFilter {
if (depth == BizzDepthEntry.LOCAL) { if (depth == BizzDepthEntry.LOCAL) {
return joinFilters(deptFilter, customFilter, shareFilter); return joinFilters(deptFilter, customFilter, shareFilter);
} else if (depth == BizzDepthEntry.DEEPDOWN) { } else if (depth == BizzDepthEntry.DEEPDOWN) {
Set<String> set = new HashSet<>(); Set<String> set = new HashSet<>();
set.add(deptFilter); set.add(deptFilter);

View file

@ -92,6 +92,7 @@ public class BaseService extends InternalPersistService {
* @param record * @param record
* @param isNew * @param isNew
* @return * @return
* @see DisplayType#N2NREFERENCE
*/ */
private Callable2<Integer, Record> processN2NReference(final Record record, boolean isNew) { private Callable2<Integer, Record> processN2NReference(final Record record, boolean isNew) {
final Entity entity = record.getEntity(); final Entity entity = record.getEntity();
@ -221,7 +222,7 @@ public class BaseService extends InternalPersistService {
* @param record * @param record
* @param isNew * @param isNew
* @return * @return
* @see #processN2NReference(Record, boolean) * @see DisplayType#TAG
*/ */
private Callable2<Integer, Record> processTag(final Record record, boolean isNew) { private Callable2<Integer, Record> processTag(final Record record, boolean isNew) {
final Entity entity = record.getEntity(); final Entity entity = record.getEntity();

View file

@ -7,6 +7,7 @@ See LICENSE and COMMERCIAL in the project root for license information.
package com.rebuild.core.service.query; package com.rebuild.core.service.query;
import cn.devezhao.persist4j.Entity;
import cn.devezhao.persist4j.Filter; import cn.devezhao.persist4j.Filter;
import cn.devezhao.persist4j.PersistManagerFactory; import cn.devezhao.persist4j.PersistManagerFactory;
import cn.devezhao.persist4j.query.AjqlQuery; import cn.devezhao.persist4j.query.AjqlQuery;
@ -29,9 +30,12 @@ public class QueryDecorator extends AjqlQuery {
@Override @Override
public Result result() { 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 (be) {
if (result == null) result = new ResultDecorator(this); if (result == null) result = new ResultDecorator(this);
return result; return result;

View file

@ -178,7 +178,7 @@ class DlgEnableUser extends RbModalHandler {
super(props) super(props)
if (props.enable) this._title = $L('激活用户') if (props.enable) this._title = $L('激活用户')
else this._title = props.dept ? $L('修改部门') : $L('修改角色') else this._title = props.deptSet ? $L('修改部门') : $L('修改角色')
} }
render() { render() {

View file

@ -0,0 +1,30 @@
/*!
Copyright (c) REBUILD <https://getrebuild.com/> 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")));
}
}