KeyLockAction.java 2.6 KB
Newer Older
R
roo00 已提交
1 2 3 4
package com.x.processplatform.assemble.surface.jaxrs.keylock;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
Z
mock  
zhourui 已提交
5
import javax.ws.rs.POST;
R
roo00 已提交
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;

import com.google.gson.JsonElement;
import com.x.base.core.project.annotation.JaxrsDescribe;
import com.x.base.core.project.annotation.JaxrsMethodDescribe;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.http.HttpMediaType;
import com.x.base.core.project.jaxrs.ResponseFactory;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;

Z
zhourui 已提交
24 25 26
import io.swagger.v3.oas.annotations.tags.Tag;

@Tag(name = "KeyLockAction", description = "工作锁接口.")
R
roo00 已提交
27
@Path("keylock")
Z
zhourui 已提交
28
@JaxrsDescribe("工作锁接口.")
R
roo00 已提交
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
public class KeyLockAction extends BaseAction {

	private static Logger logger = LoggerFactory.getLogger(KeyLockAction.class);

	@JaxrsMethodDescribe(value = "当前用户身份锁定值.", action = ActionLock.class)
	@PUT
	@Path("lock")
	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
	@Consumes(MediaType.APPLICATION_JSON)
	public void lock(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
			JsonElement jsonElement) {
		ActionResult<ActionLock.Wo> result = new ActionResult<>();
		EffectivePerson effectivePerson = this.effectivePerson(request);
		try {
			result = new ActionLock().execute(effectivePerson, jsonElement);
		} catch (Exception e) {
			logger.error(e, effectivePerson, request, jsonElement);
			result.error(e);
		}
		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
	}

Z
mock  
zhourui 已提交
51 52
	@JaxrsMethodDescribe(value = "Mock Post To Put.", action = ActionLock.class)
	@POST
Z
zhourui 已提交
53
	@Path("lock/mockputtopost")
Z
mock  
zhourui 已提交
54 55
	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
	@Consumes(MediaType.APPLICATION_JSON)
Z
zhourui 已提交
56
	public void lockMockPutToPost(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
Z
mock  
zhourui 已提交
57 58 59 60 61 62 63 64 65 66 67 68
			JsonElement jsonElement) {
		ActionResult<ActionLock.Wo> result = new ActionResult<>();
		EffectivePerson effectivePerson = this.effectivePerson(request);
		try {
			result = new ActionLock().execute(effectivePerson, jsonElement);
		} catch (Exception e) {
			logger.error(e, effectivePerson, request, jsonElement);
			result.error(e);
		}
		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
	}

R
roo00 已提交
69
}