提交 ba9141db 编写于 作者: 程剑

Merge branch 'feature/脚本和数据字典增加分页查询接口' into 'develop'

【平台】脚本和数据字典增加分页查询接口

See merge request o2oa/o2oa!1223
package com.x.cms.assemble.control.jaxrs.appdictdesign;
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.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.cms.core.entity.AppInfo;
import com.x.cms.core.entity.element.AppDict;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.Predicate;
import java.util.List;
class ActionListPaging extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionListPaging.class);
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, Integer page, Integer size) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
EntityManager em = emc.get(AppDict.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
Predicate p = cb.conjunction();;
List<Wo> wos = emc.fetchDescPaging(AppDict.class, Wo.copier, p, page, size, AppDict.sequence_FIELDNAME);
wos.stream().forEach(wo -> {
try {
AppInfo appInfo = emc.find( wo.getAppId(), AppInfo.class );
if(appInfo != null){
wo.setAppName(appInfo.getAppName());
}
} catch (Exception e) {
}
});
result.setData(wos);
result.setCount(emc.count(AppDict.class, p));
return result;
}
}
public static class Wo extends AppDict {
private static final long serialVersionUID = -2252387711917161807L;
static WrapCopier<AppDict, Wo> copier = WrapCopierFactory.wo(AppDict.class, Wo.class, null,
JpaObject.FieldsInvisible);
@FieldDescribe("应用名称.")
private String appName;
public String getAppName() {
return appName;
}
public void setAppName(String appName) {
this.appName = appName;
}
}
}
...@@ -120,4 +120,23 @@ public class AppDictDesignAction extends BaseAction { ...@@ -120,4 +120,23 @@ public class AppDictDesignAction extends BaseAction {
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result)); asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
} }
@JaxrsMethodDescribe(value = "分页列示数据字典对象.", action = ActionListPaging.class)
@POST
@Path("list/paging/{page}/size/{size}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listPaging(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("分页") @PathParam("page") Integer page,
@JaxrsParameterDescribe("每页数量") @PathParam("size") Integer size) {
ActionResult<List<ActionListPaging.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListPaging().execute(effectivePerson, page, size);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
} }
\ No newline at end of file
package com.x.cms.assemble.control.jaxrs.script;
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.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.tools.ListTools;
import com.x.cms.core.entity.AppInfo;
import com.x.cms.core.entity.element.Script;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.Predicate;
import java.util.List;
class ActionListPaging extends BaseAction {
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, Integer page, Integer size) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
EntityManager em = emc.get(Script.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
Predicate p = cb.conjunction();
List<Wo> wos = emc.fetchDescPaging(Script.class, Wo.copier, p, page, size, Script.sequence_FIELDNAME);
wos.stream().forEach(wo -> {
try {
AppInfo appInfo = emc.find( wo.getAppId(), AppInfo.class );
if(appInfo != null){
wo.setAppName(appInfo.getAppName());
}
} catch (Exception e) {
}
});
result.setData(wos);
result.setCount(emc.count(Script.class, p));
return result;
}
}
public static class Wo extends Script {
private static final long serialVersionUID = -8095369685452823624L;
static WrapCopier<Script, Wo> copier = WrapCopierFactory.wo(Script.class, Wo.class, null,
ListTools.toList(JpaObject.FieldsInvisible, Script.dependScriptList_FIELDNAME, Script.text_FIELDNAME));
@FieldDescribe("应用名称.")
private String appName;
public String getAppName() {
return appName;
}
public void setAppName(String appName) {
this.appName = appName;
}
}
}
...@@ -245,4 +245,23 @@ public class ScriptAction extends StandardJaxrsAction { ...@@ -245,4 +245,23 @@ public class ScriptAction extends StandardJaxrsAction {
} }
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result)); asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
} }
@JaxrsMethodDescribe(value = "分页列示Script对象.", action = ActionListPaging.class)
@POST
@Path("list/paging/{page}/size/{size}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listPaging(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("分页") @PathParam("page") Integer page,
@JaxrsParameterDescribe("每页数量") @PathParam("size") Integer size) {
ActionResult<List<ActionListPaging.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListPaging().execute(effectivePerson, page, size);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
} }
\ No newline at end of file
package com.x.portal.assemble.designer.jaxrs.script;
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.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.tools.ListTools;
import com.x.portal.assemble.designer.Business;
import com.x.portal.core.entity.Portal;
import com.x.portal.core.entity.Script;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.Predicate;
import java.util.List;
class ActionListPaging extends BaseAction {
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, Integer page, Integer size) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<List<Wo>> result = new ActionResult<>();
if (!business.editable(effectivePerson, null)) {
throw new PortalInvisibleException(effectivePerson.getDistinguishedName(), "all",
"all");
}
EntityManager em = emc.get(Script.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
Predicate p = cb.conjunction();;
List<Wo> wos = emc.fetchDescPaging(Script.class, Wo.copier, p, page, size, Script.sequence_FIELDNAME);
wos.stream().forEach(wo -> {
try {
Portal portal = emc.find(wo.getPortal(), Portal.class);
if(portal != null){
wo.setPortalName(portal.getName());
}
} catch (Exception e) {
}
});
result.setData(wos);
result.setCount(emc.count(Script.class, p));
return result;
}
}
public static class Wo extends Script {
private static final long serialVersionUID = 1211311928431174895L;
static WrapCopier<Script, Wo> copier = WrapCopierFactory.wo(Script.class, Wo.class, null,
ListTools.toList(JpaObject.FieldsInvisible, Script.dependScriptList_FIELDNAME, Script.text_FIELDNAME));
@FieldDescribe("门户应用名称.")
private String portalName;
public String getPortalName() {
return portalName;
}
public void setPortalName(String portalName) {
this.portalName = portalName;
}
}
}
...@@ -123,4 +123,23 @@ public class ScriptAction extends StandardJaxrsAction { ...@@ -123,4 +123,23 @@ public class ScriptAction extends StandardJaxrsAction {
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result)); asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
} }
@JaxrsMethodDescribe(value = "分页列示Script对象.", action = ActionListPaging.class)
@POST
@Path("list/paging/{page}/size/{size}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listPaging(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("分页") @PathParam("page") Integer page,
@JaxrsParameterDescribe("每页数量") @PathParam("size") Integer size) {
ActionResult<List<ActionListPaging.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListPaging().execute(effectivePerson, page, size);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
} }
\ No newline at end of file
package com.x.processplatform.assemble.designer.jaxrs.applicationdict;
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.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.processplatform.assemble.designer.Business;
import com.x.processplatform.core.entity.element.Application;
import com.x.processplatform.core.entity.element.ApplicationDict;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.Predicate;
import java.util.List;
class ActionListPaging extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionListPaging.class);
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, Integer page, Integer size) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Business business = new Business(emc);
if (!business.editable(effectivePerson, null)) {
throw new ExceptionApplicationAccessDenied(effectivePerson.getDistinguishedName(),
"all", "all");
}
EntityManager em = emc.get(ApplicationDict.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
Predicate p = cb.conjunction();;
List<Wo> wos = emc.fetchDescPaging(ApplicationDict.class, Wo.copier, p, page, size, ApplicationDict.sequence_FIELDNAME);
wos.stream().forEach(wo -> {
try {
Application app = emc.find(wo.getApplication(), Application.class);
if(app != null){
wo.setApplicationName(app.getName());
}
} catch (Exception e) {
}
});
result.setData(wos);
result.setCount(emc.count(ApplicationDict.class, p));
return result;
}
}
public static class Wo extends ApplicationDict {
private static final long serialVersionUID = -192812264880120309L;
static WrapCopier<ApplicationDict, Wo> copier = WrapCopierFactory.wo(ApplicationDict.class, Wo.class, null,
JpaObject.FieldsInvisible);
@FieldDescribe("应用名称.")
private String applicationName;
public String getApplicationName() {
return applicationName;
}
public void setApplicationName(String applicationName) {
this.applicationName = applicationName;
}
}
}
...@@ -122,4 +122,23 @@ public class ApplicationDictAction extends BaseAction { ...@@ -122,4 +122,23 @@ public class ApplicationDictAction extends BaseAction {
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result)); asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
} }
@JaxrsMethodDescribe(value = "分页列示数据字典对象.", action = ActionListPaging.class)
@POST
@Path("list/paging/{page}/size/{size}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listPaging(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("分页") @PathParam("page") Integer page,
@JaxrsParameterDescribe("每页数量") @PathParam("size") Integer size) {
ActionResult<List<ActionListPaging.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListPaging().execute(effectivePerson, page, size);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
} }
\ No newline at end of file
package com.x.processplatform.assemble.designer.jaxrs.script;
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.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.tools.ListTools;
import com.x.processplatform.core.entity.element.Application;
import com.x.processplatform.core.entity.element.Script;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.Predicate;
import java.util.List;
class ActionListPaging extends BaseAction {
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, Integer page, Integer size) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
EntityManager em = emc.get(Script.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
Predicate p = cb.conjunction();
List<Wo> wos = emc.fetchDescPaging(Script.class, Wo.copier, p, page, size, Script.sequence_FIELDNAME);
wos.stream().forEach(wo -> {
try {
Application app = emc.find(wo.getApplication(), Application.class);
if(app != null){
wo.setApplicationName(app.getName());
}
} catch (Exception e) {
}
});
result.setData(wos);
result.setCount(emc.count(Script.class, p));
return result;
}
}
public static class Wo extends Script {
private static final long serialVersionUID = -4409718421906673933L;
static WrapCopier<Script, Wo> copier = WrapCopierFactory.wo(Script.class, Wo.class, null,
ListTools.toList(JpaObject.FieldsInvisible, Script.dependScriptList_FIELDNAME, Script.text_FIELDNAME));
@FieldDescribe("应用名称.")
private String applicationName;
public String getApplicationName() {
return applicationName;
}
public void setApplicationName(String applicationName) {
this.applicationName = applicationName;
}
}
}
...@@ -180,4 +180,23 @@ public class ScriptAction extends StandardJaxrsAction { ...@@ -180,4 +180,23 @@ public class ScriptAction extends StandardJaxrsAction {
} }
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result)); asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
} }
@JaxrsMethodDescribe(value = "分页列示Script对象.", action = ActionListPaging.class)
@POST
@Path("list/paging/{page}/size/{size}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listPaging(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("分页") @PathParam("page") Integer page,
@JaxrsParameterDescribe("每页数量") @PathParam("size") Integer size) {
ActionResult<List<ActionListPaging.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListPaging().execute(effectivePerson, page, size);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册