提交 173a593b 编写于 作者: NoSubject's avatar NoSubject

Merge branch '增加注销用户日志分页查询接口' into 'develop'

增加注销用户日志分页查询接口

See merge request o2oa/o2oa!2572
package com.x.organization.assemble.control.jaxrs.person;
import java.util.Date;
import java.util.List;
import com.x.base.core.container.EntityManagerContainer;
......@@ -109,9 +110,10 @@ class ActionDelete extends BaseAction {
emc.beginTransaction(Custom.class);
Custom custom = new Custom();
custom.setPerson(person.getDistinguishedName());
custom.setName("person#delete");
custom.setName(PERSON_DELETE_CUSTOM_NAME);
CustomPersonInfo customPersonInfo = new CustomPersonInfo();
customPersonInfo.setOperator(effectivePerson.getDistinguishedName());
customPersonInfo.setOperateTime(new Date());
customPersonInfo.setPerson(WrapPerson.copier.copy(person));
custom.setData(gson.toJson(customPersonInfo));
emc.persist(custom);
......
package com.x.organization.assemble.control.jaxrs.person;
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.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.tools.StringTools;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Custom;
import com.x.organization.core.entity.Custom_;
import org.apache.commons.lang3.StringUtils;
import javax.persistence.EntityManager;
import javax.persistence.Tuple;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.util.ArrayList;
import java.util.List;
class ActionListDeletePaging extends BaseAction {
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, Integer page, Integer size, JsonElement jsonElement) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Business business = new Business(emc);
if (!this.editable(business, effectivePerson, "")) {
throw new ExceptionAccessDenied(effectivePerson);
}
Predicate p = toFilterPredicate(business, wi);
List<WoCustom> woCustoms = emc.fetchDescPaging(Custom.class, WoCustom.copier, p, page, size, JpaObject.sequence_FIELDNAME);
List<Wo> wos = new ArrayList<>();
for (WoCustom woCustom : woCustoms){
Wo wo = gson.fromJson(woCustom.getData(), Wo.class);
wo.setOperateTime(woCustom.getCreateTime());
wos.add(wo);
}
result.setData(wos);
result.setCount(emc.count(Custom.class, p));
return result;
}
}
private Predicate toFilterPredicate(Business business, Wi wi) throws Exception {
EntityManager em = business.entityManagerContainer().get(Custom.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Tuple> cq = cb.createQuery(Tuple.class);
Root<Custom> root = cq.from(Custom.class);
Predicate p = cb.equal(root.get(Custom_.name), PERSON_DELETE_CUSTOM_NAME);
if(StringUtils.isNotBlank(wi.getPerson())){
p = cb.and(p, cb.like(root.get(Custom_.person), "%" + wi.getPerson() + "%", StringTools.SQL_ESCAPE_CHAR));
}
return p;
}
public static class Wi extends GsonPropertyObject {
@FieldDescribe("用户")
private String person;
public String getPerson() {
return person;
}
public void setPerson(String person) {
this.person = person;
}
}
public static class Wo extends CustomPersonInfo {
private static final long serialVersionUID = 8462618330733553654L;
}
public static class WoCustom extends Custom {
private static final long serialVersionUID = 8501479874360244059L;
static WrapCopier<Custom, WoCustom> copier = WrapCopierFactory.wo(Custom.class, WoCustom.class,
JpaObject.singularAttributeField(Custom.class, true, false), null);
}
}
package com.x.organization.assemble.control.jaxrs.person;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
......@@ -57,6 +54,8 @@ import com.x.organization.core.entity.Unit_;
abstract class BaseAction extends StandardJaxrsAction {
protected static final String PERSON_DELETE_CUSTOM_NAME = "person#delete";
private static final List<String> KEYWORDS = ListUtils
.unmodifiableList(Arrays.asList(Token.defaultInitialManager, TernaryManagement.INIT_SYSTEM_MANAGER,
TernaryManagement.INIT_SECURITY_MANAGER, TernaryManagement.INIT_AUDIT_MANAGER));
......@@ -418,8 +417,12 @@ abstract class BaseAction extends StandardJaxrsAction {
}
}
public class CustomPersonInfo{
protected static class CustomPersonInfo extends GsonPropertyObject{
@FieldDescribe("操作人")
private String operator;
@FieldDescribe("操作时间")
private Date operateTime;
@FieldDescribe("被操作用户对象")
private WrapPerson person;
private List<WrapIdentity> identityList;
......@@ -431,6 +434,14 @@ abstract class BaseAction extends StandardJaxrsAction {
this.operator = operator;
}
public Date getOperateTime() {
return operateTime;
}
public void setOperateTime(Date operateTime) {
this.operateTime = operateTime;
}
public WrapPerson getPerson() {
return person;
}
......
......@@ -625,4 +625,23 @@ public class PersonAction extends StandardJaxrsAction {
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result, jsonElement));
}
@JaxrsMethodDescribe(value = "分页查询删除(注销)用户信息.", action = ActionListDeletePaging.class)
@POST
@Path("list/delete/{page}/size/{size}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listDeletePaging(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("分页") @PathParam("page") Integer page,
@JaxrsParameterDescribe("数量") @PathParam("size") Integer size, JsonElement jsonElement) {
ActionResult<List<ActionListDeletePaging.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListDeletePaging().execute(effectivePerson, page, size, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result, jsonElement));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册