|
|
@@ -1,12 +1,15 @@
|
|
|
package com.x.query.assemble.surface.jaxrs.statement;
|
|
|
|
|
|
+import com.google.gson.JsonElement;
|
|
|
import com.x.base.core.container.EntityManagerContainer;
|
|
|
import com.x.base.core.container.factory.EntityManagerContainerFactory;
|
|
|
import com.x.base.core.entity.JpaObject;
|
|
|
+import com.x.base.core.project.annotation.FieldDescribe;
|
|
|
import com.x.base.core.project.bean.WrapCopier;
|
|
|
import com.x.base.core.project.bean.WrapCopierFactory;
|
|
|
import com.x.base.core.project.exception.ExceptionAccessDenied;
|
|
|
import com.x.base.core.project.exception.ExceptionEntityNotExist;
|
|
|
+import com.x.base.core.project.gson.GsonPropertyObject;
|
|
|
import com.x.base.core.project.http.ActionResult;
|
|
|
import com.x.base.core.project.http.EffectivePerson;
|
|
|
import com.x.query.assemble.surface.Business;
|
|
|
@@ -19,10 +22,11 @@ import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
class ActionListWithQuery extends BaseAction {
|
|
|
- ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, String queryFlag, Boolean justSelect, Boolean hasView) throws Exception {
|
|
|
+ ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, String queryFlag, JsonElement jsonElement) throws Exception {
|
|
|
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
|
|
|
ActionResult<List<Wo>> result = new ActionResult<>();
|
|
|
Business business = new Business(emc);
|
|
|
+ Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
|
|
|
Query query = emc.flag(queryFlag, Query.class);
|
|
|
if (null == query) {
|
|
|
throw new ExceptionEntityNotExist(queryFlag);
|
|
|
@@ -34,10 +38,10 @@ class ActionListWithQuery extends BaseAction {
|
|
|
for (String id : emc.idsEqual(Statement.class, Statement.query_FIELDNAME, query.getId())) {
|
|
|
Statement o = business.pick(id, Statement.class);
|
|
|
if (null != o) {
|
|
|
- if(BooleanUtils.isTrue(hasView) && StringUtils.isBlank(o.getView())){
|
|
|
+ if(BooleanUtils.isTrue(wi.getHasView()) && StringUtils.isBlank(o.getView())){
|
|
|
continue;
|
|
|
}
|
|
|
- if(BooleanUtils.isTrue(justSelect) && !Statement.TYPE_SELECT.equals(o.getType())){
|
|
|
+ if(BooleanUtils.isTrue(wi.getJustSelect()) && !Statement.TYPE_SELECT.equals(o.getType())){
|
|
|
continue;
|
|
|
}
|
|
|
if (business.readable(effectivePerson, o)) {
|
|
|
@@ -50,6 +54,30 @@ class ActionListWithQuery extends BaseAction {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public static class Wi extends GsonPropertyObject{
|
|
|
+
|
|
|
+ @FieldDescribe("是否只查询select语句.")
|
|
|
+ private Boolean justSelect;
|
|
|
+ @FieldDescribe("是否只查询含有视图的语句.")
|
|
|
+ private Boolean hasView;
|
|
|
+
|
|
|
+ public Boolean getJustSelect() {
|
|
|
+ return justSelect;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setJustSelect(Boolean justSelect) {
|
|
|
+ this.justSelect = justSelect;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Boolean getHasView() {
|
|
|
+ return hasView;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setHasView(Boolean hasView) {
|
|
|
+ this.hasView = hasView;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public static class Wo extends Statement {
|
|
|
|
|
|
private static final long serialVersionUID = -5755898083219447939L;
|