WorkLogAction.java 4.9 KB
Newer Older
R
roo00 已提交
1
package com.x.processplatform.assemble.surface.jaxrs.worklog;
caixiangyi's avatar
caixiangyi 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
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.x.base.core.project.annotation.JaxrsDescribe;
import com.x.base.core.project.annotation.JaxrsMethodDescribe;
R
roo00 已提交
18
import com.x.base.core.project.annotation.JaxrsParameterDescribe;
caixiangyi's avatar
caixiangyi 已提交
19 20 21 22 23 24 25 26
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.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;

Z
zhourui 已提交
27 28
import io.swagger.v3.oas.annotations.tags.Tag;
@Tag(name = "WorkLogAction", description = "工作日志接口.")
R
roo00 已提交
29
@Path("worklog")
Z
zhourui 已提交
30
@JaxrsDescribe("工作日志接口.")
R
roo00 已提交
31
public class WorkLogAction extends StandardJaxrsAction {
caixiangyi's avatar
caixiangyi 已提交
32

R
roo00 已提交
33
	private static Logger logger = LoggerFactory.getLogger(WorkLogAction.class);
caixiangyi's avatar
caixiangyi 已提交
34

R
roo00 已提交
35
	@JaxrsMethodDescribe(value = "根据指定job获取工作日志.", action = ActionListWithJob.class)
caixiangyi's avatar
caixiangyi 已提交
36
	@GET
R
roo00 已提交
37
	@Path("list/job/{job}")
caixiangyi's avatar
caixiangyi 已提交
38 39
	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
	@Consumes(MediaType.APPLICATION_JSON)
NoSubject's avatar
NoSubject 已提交
40
	public void listWithJob(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
R
roo00 已提交
41 42
			@JaxrsParameterDescribe("任务标识") @PathParam("job") String job) {
		ActionResult<List<ActionListWithJob.Wo>> result = new ActionResult<>();
caixiangyi's avatar
caixiangyi 已提交
43 44
		EffectivePerson effectivePerson = this.effectivePerson(request);
		try {
R
roo00 已提交
45
			result = new ActionListWithJob().execute(effectivePerson, job);
caixiangyi's avatar
caixiangyi 已提交
46 47 48 49
		} catch (Exception e) {
			logger.error(e, effectivePerson, request, null);
			result.error(e);
		}
R
update  
roo00 已提交
50
		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
caixiangyi's avatar
caixiangyi 已提交
51
	}
R
roo00 已提交
52

R
roo00 已提交
53 54 55 56 57
	@JaxrsMethodDescribe(value = "根据指定Work或者WorkCompleted获取工作日志.", action = ActionListWithWorkOrWorkCompleted.class)
	@GET
	@Path("list/workorworkcompleted/{workOrWorkCompleted}")
	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
	@Consumes(MediaType.APPLICATION_JSON)
R
roo00 已提交
58 59
	public void listWithWorkOrWorkCompleted(@Suspended final AsyncResponse asyncResponse,
			@Context HttpServletRequest request,
R
roo00 已提交
60 61 62 63 64 65 66 67 68
			@JaxrsParameterDescribe("工作或已完成工作标识") @PathParam("workOrWorkCompleted") String workOrWorkCompleted) {
		ActionResult<List<ActionListWithWorkOrWorkCompleted.Wo>> result = new ActionResult<>();
		EffectivePerson effectivePerson = this.effectivePerson(request);
		try {
			result = new ActionListWithWorkOrWorkCompleted().execute(effectivePerson, workOrWorkCompleted);
		} catch (Exception e) {
			logger.error(e, effectivePerson, request, null);
			result.error(e);
		}
R
update  
roo00 已提交
69
		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
R
roo00 已提交
70 71
	}

R
roo00 已提交
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
	@JaxrsMethodDescribe(value = "获取工作或完成工作可回滚的工作日志.", action = ActionListRollbackWithWorkOrWorkCompleted.class)
	@GET
	@Path("list/rollback/workorworkcompleted/{workOrWorkCompleted}")
	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
	@Consumes(MediaType.APPLICATION_JSON)
	public void listRollbackWithWorkOrWorkCompleted(@Suspended final AsyncResponse asyncResponse,
			@Context HttpServletRequest request,
			@JaxrsParameterDescribe("工作或已完成工作标识") @PathParam("workOrWorkCompleted") String workOrWorkCompleted) {
		ActionResult<List<ActionListRollbackWithWorkOrWorkCompleted.Wo>> result = new ActionResult<>();
		EffectivePerson effectivePerson = this.effectivePerson(request);
		try {
			result = new ActionListRollbackWithWorkOrWorkCompleted().execute(effectivePerson, workOrWorkCompleted);
		} catch (Exception e) {
			logger.error(e, effectivePerson, request, null);
			result.error(e);
		}
R
update  
roo00 已提交
88
		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
R
roo00 已提交
89 90
	}

R
roo00 已提交
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
	@JaxrsMethodDescribe(value = "获取工作或完成工作可回滚的工作日志.", action = ActionListAddSplitWithWork.class)
	@GET
	@Path("list/add/split/work/{workId}")
	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
	@Consumes(MediaType.APPLICATION_JSON)
	public void listAddSplitWithWork(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
			@JaxrsParameterDescribe("工作标识") @PathParam("workId") String workId) {
		ActionResult<List<ActionListAddSplitWithWork.Wo>> result = new ActionResult<>();
		EffectivePerson effectivePerson = this.effectivePerson(request);
		try {
			result = new ActionListAddSplitWithWork().execute(effectivePerson, workId);
		} catch (Exception e) {
			logger.error(e, effectivePerson, request, null);
			result.error(e);
		}
R
update  
roo00 已提交
106
		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
R
roo00 已提交
107 108
	}

caixiangyi's avatar
caixiangyi 已提交
109
}