提交 bc961d21 编写于 作者: O o2null

Merge branch 'feature/增加解锁用户的接口' into 'wrdp'

[用户组织管理]增加解锁用户的接口,用于管理员解锁登录多次失败被锁定的用户.

See merge request o2oa/o2oa!2612
package com.x.organization.assemble.control.jaxrs.person;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WrapBoolean;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Person;
class ActionUnlock extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionUnlock.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Business business = new Business(emc);
Person person = business.person().pick(flag);
if (null == person) {
throw new ExceptionPersonNotExist(flag);
}
if (!this.editable(business, effectivePerson, person)) {
throw new ExceptionAccessDenied(effectivePerson);
}
emc.beginTransaction(Person.class);
Person entityPerson = emc.find(person.getId(), Person.class);
entityPerson.setFailureCount(0);
emc.check(entityPerson, CheckPersistType.all);
emc.commit();
CacheManager.notify(Person.class);
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
return result;
}
}
public static class Wo extends WrapBoolean {
}
}
......@@ -364,4 +364,22 @@ public class PersonAction extends StandardJaxrsAction {
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "用户解锁,用于管理员解锁登录多次失败被锁定的用户.", action = ActionUnlock.class)
@GET
@Path("unlock/{flag}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void unlockPerson(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("人员标识") @PathParam("flag") String flag) {
ActionResult<ActionUnlock.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionUnlock().execute(effectivePerson, flag);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册