|
|
@@ -0,0 +1,247 @@
|
|
|
+package com.x.query.assemble.surface.jaxrs.table;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.ws.rs.Consumes;
|
|
|
+import javax.ws.rs.DELETE;
|
|
|
+import javax.ws.rs.GET;
|
|
|
+import javax.ws.rs.POST;
|
|
|
+import javax.ws.rs.PUT;
|
|
|
+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.google.gson.JsonElement;
|
|
|
+import com.google.gson.JsonObject;
|
|
|
+import com.x.base.core.project.annotation.JaxrsDescribe;
|
|
|
+import com.x.base.core.project.annotation.JaxrsMethodDescribe;
|
|
|
+import com.x.base.core.project.annotation.JaxrsParameterDescribe;
|
|
|
+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;
|
|
|
+
|
|
|
+@Path("table")
|
|
|
+@JaxrsDescribe("表")
|
|
|
+public class TableAction extends StandardJaxrsAction {
|
|
|
+
|
|
|
+ private static Logger logger = LoggerFactory.getLogger(TableAction.class);
|
|
|
+
|
|
|
+ @JaxrsMethodDescribe(value = "列示表对象,下一页.", action = ActionListNext.class)
|
|
|
+ @GET
|
|
|
+ @Path("list/{id}/next/{count}")
|
|
|
+ @Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
|
|
|
+ @Consumes(MediaType.APPLICATION_JSON)
|
|
|
+ public void listNext(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
|
|
|
+ @JaxrsParameterDescribe("标识") @PathParam("id") String id,
|
|
|
+ @JaxrsParameterDescribe("数量") @PathParam("count") Integer count) {
|
|
|
+ ActionResult<List<ActionListNext.Wo>> result = new ActionResult<>();
|
|
|
+ EffectivePerson effectivePerson = this.effectivePerson(request);
|
|
|
+ try {
|
|
|
+ result = new ActionListNext().execute(effectivePerson, id, count);
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error(e, effectivePerson, request, null);
|
|
|
+ result.error(e);
|
|
|
+ }
|
|
|
+ asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
|
|
|
+ }
|
|
|
+
|
|
|
+ @JaxrsMethodDescribe(value = "列示Stat对象,上一页.", action = ActionListPrev.class)
|
|
|
+ @GET
|
|
|
+ @Path("list/{id}/prev/{count}")
|
|
|
+ @Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
|
|
|
+ @Consumes(MediaType.APPLICATION_JSON)
|
|
|
+ public void listPrev(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
|
|
|
+ @JaxrsParameterDescribe("标识") @PathParam("id") String id,
|
|
|
+ @JaxrsParameterDescribe("数量") @PathParam("count") Integer count) {
|
|
|
+ ActionResult<List<ActionListPrev.Wo>> result = new ActionResult<>();
|
|
|
+ EffectivePerson effectivePerson = this.effectivePerson(request);
|
|
|
+ try {
|
|
|
+ result = new ActionListPrev().execute(effectivePerson, id, count);
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error(e, effectivePerson, request, null);
|
|
|
+ result.error(e);
|
|
|
+ }
|
|
|
+ asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
|
|
|
+ }
|
|
|
+
|
|
|
+ @JaxrsMethodDescribe(value = "获取表中某一行数据", action = ActionRowGet.class)
|
|
|
+ @GET
|
|
|
+ @Path("{tableFlag}/row/{id}")
|
|
|
+ @Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
|
|
|
+ @Consumes(MediaType.APPLICATION_JSON)
|
|
|
+ public void rowGet(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
|
|
|
+ @JaxrsParameterDescribe("表标识") @PathParam("tableFlag") String tableFlag,
|
|
|
+ @JaxrsParameterDescribe("行标识") @PathParam("id") String id) {
|
|
|
+ ActionResult<Object> result = new ActionResult<>();
|
|
|
+ EffectivePerson effectivePerson = this.effectivePerson(request);
|
|
|
+ try {
|
|
|
+ result = new ActionRowGet().execute(effectivePerson, tableFlag, id);
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error(e, effectivePerson, request, null);
|
|
|
+ result.error(e);
|
|
|
+ }
|
|
|
+ asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
|
|
|
+ }
|
|
|
+
|
|
|
+ @JaxrsMethodDescribe(value = "通过where 获取表中的数据,格式为jpql语法,o.name='zhangsan'", action = ActionListRowSelectWhere.class)
|
|
|
+ @GET
|
|
|
+ @Path("list/{tableFlag}/row/select/where/{where}")
|
|
|
+ @Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
|
|
|
+ @Consumes(MediaType.APPLICATION_JSON)
|
|
|
+ public void listRowSelectWhere(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
|
|
|
+ @JaxrsParameterDescribe("表标识") @PathParam("tableFlag") String tableFlag,
|
|
|
+ @JaxrsParameterDescribe("where语句") @PathParam("where") String where) {
|
|
|
+ ActionResult<List<?>> result = new ActionResult<>();
|
|
|
+ EffectivePerson effectivePerson = this.effectivePerson(request);
|
|
|
+ try {
|
|
|
+ result = new ActionListRowSelectWhere().execute(effectivePerson, tableFlag, where);
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error(e, effectivePerson, request, null);
|
|
|
+ result.error(e);
|
|
|
+ }
|
|
|
+ asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
|
|
|
+ }
|
|
|
+
|
|
|
+ @JaxrsMethodDescribe(value = "通过where 统计数量", action = ActionRowCountWhere.class)
|
|
|
+ @GET
|
|
|
+ @Path("{tableFlag}/row/count/where/{where}")
|
|
|
+ @Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
|
|
|
+ @Consumes(MediaType.APPLICATION_JSON)
|
|
|
+ public void rowCountWhere(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
|
|
|
+ @JaxrsParameterDescribe("表标识") @PathParam("tableFlag") String tableFlag,
|
|
|
+ @JaxrsParameterDescribe("where语句") @PathParam("where") String where) {
|
|
|
+ ActionResult<ActionRowCountWhere.Wo> result = new ActionResult<>();
|
|
|
+ EffectivePerson effectivePerson = this.effectivePerson(request);
|
|
|
+ try {
|
|
|
+ result = new ActionRowCountWhere().execute(effectivePerson, tableFlag, where);
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error(e, effectivePerson, request, null);
|
|
|
+ result.error(e);
|
|
|
+ }
|
|
|
+ asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
|
|
|
+ }
|
|
|
+
|
|
|
+ @JaxrsMethodDescribe(value = "指定表中插入数据.", action = ActionRowInsert.class)
|
|
|
+ @POST
|
|
|
+ @Path("{tableFlag}/row")
|
|
|
+ @Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
|
|
|
+ @Consumes(MediaType.APPLICATION_JSON)
|
|
|
+ public void rowInsert(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
|
|
|
+ @JaxrsParameterDescribe("表标识") @PathParam("tableFlag") String tableFlag, JsonElement jsonElement) {
|
|
|
+ ActionResult<ActionRowInsert.Wo> result = new ActionResult<>();
|
|
|
+ EffectivePerson effectivePerson = this.effectivePerson(request);
|
|
|
+ try {
|
|
|
+ result = new ActionRowInsert().execute(effectivePerson, tableFlag, jsonElement);
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error(e, effectivePerson, request, jsonElement);
|
|
|
+ result.error(e);
|
|
|
+ }
|
|
|
+ asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
|
|
|
+ }
|
|
|
+
|
|
|
+ @JaxrsMethodDescribe(value = "更新指定表中指定行数据.", action = ActionRowUpdate.class)
|
|
|
+ @PUT
|
|
|
+ @Path("{tableFlag}/row/{id}")
|
|
|
+ @Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
|
|
|
+ @Consumes(MediaType.APPLICATION_JSON)
|
|
|
+ public void rowUpdate(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
|
|
|
+ @JaxrsParameterDescribe("表标识") @PathParam("tableFlag") String tableFlag,
|
|
|
+ @JaxrsParameterDescribe("行标识") @PathParam("id") String id, JsonElement jsonElement) {
|
|
|
+ ActionResult<ActionRowUpdate.Wo> result = new ActionResult<>();
|
|
|
+ EffectivePerson effectivePerson = this.effectivePerson(request);
|
|
|
+ try {
|
|
|
+ result = new ActionRowUpdate().execute(effectivePerson, tableFlag, id, jsonElement);
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error(e, effectivePerson, request, jsonElement);
|
|
|
+ result.error(e);
|
|
|
+ }
|
|
|
+ asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
|
|
|
+ }
|
|
|
+
|
|
|
+ @JaxrsMethodDescribe(value = "更新指定表中指定行数据.", action = ActionRowDelete.class)
|
|
|
+ @DELETE
|
|
|
+ @Path("{tableFlag}/row/{id}")
|
|
|
+ @Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
|
|
|
+ @Consumes(MediaType.APPLICATION_JSON)
|
|
|
+ public void rowDelete(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
|
|
|
+ @JaxrsParameterDescribe("表标识") @PathParam("tableFlag") String tableFlag,
|
|
|
+ @JaxrsParameterDescribe("行标识") @PathParam("id") String id) {
|
|
|
+ ActionResult<ActionRowDelete.Wo> result = new ActionResult<>();
|
|
|
+ EffectivePerson effectivePerson = this.effectivePerson(request);
|
|
|
+ try {
|
|
|
+ result = new ActionRowDelete().execute(effectivePerson, tableFlag, id);
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error(e, effectivePerson, request, null);
|
|
|
+ result.error(e);
|
|
|
+ }
|
|
|
+ asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
|
|
|
+ }
|
|
|
+
|
|
|
+ @JaxrsMethodDescribe(value = "更新指定表中指定行数据.", action = ActionRowDeleteAll.class)
|
|
|
+ @DELETE
|
|
|
+ @Path("{tableFlag}/row/delete/all")
|
|
|
+ @Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
|
|
|
+ @Consumes(MediaType.APPLICATION_JSON)
|
|
|
+ public void rowDeleteAll(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
|
|
|
+ @JaxrsParameterDescribe("表标识") @PathParam("tableFlag") String tableFlag) {
|
|
|
+ ActionResult<ActionRowDeleteAll.Wo> result = new ActionResult<>();
|
|
|
+ EffectivePerson effectivePerson = this.effectivePerson(request);
|
|
|
+ try {
|
|
|
+ result = new ActionRowDeleteAll().execute(effectivePerson, tableFlag);
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error(e, effectivePerson, request, null);
|
|
|
+ result.error(e);
|
|
|
+ }
|
|
|
+ asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
|
|
|
+ }
|
|
|
+
|
|
|
+ @JaxrsMethodDescribe(value = "列示表中的行对象,下一页.", action = ActionListRowNext.class)
|
|
|
+ @GET
|
|
|
+ @Path("list/{tableFlag}/row/{id}/next/{count}")
|
|
|
+ @Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
|
|
|
+ @Consumes(MediaType.APPLICATION_JSON)
|
|
|
+ public void listRowNext(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
|
|
|
+ @JaxrsParameterDescribe("表标识") @PathParam("tableFlag") String tableFlag,
|
|
|
+ @JaxrsParameterDescribe("标识") @PathParam("id") String id,
|
|
|
+ @JaxrsParameterDescribe("数量") @PathParam("count") Integer count) {
|
|
|
+ ActionResult<List<JsonObject>> result = new ActionResult<>();
|
|
|
+ EffectivePerson effectivePerson = this.effectivePerson(request);
|
|
|
+ try {
|
|
|
+ result = new ActionListRowNext().execute(effectivePerson, tableFlag, id, count);
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error(e, effectivePerson, request, null);
|
|
|
+ result.error(e);
|
|
|
+ }
|
|
|
+ asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
|
|
|
+ }
|
|
|
+
|
|
|
+ @JaxrsMethodDescribe(value = "列示表中的行对象,上一页.", action = ActionListRowPrev.class)
|
|
|
+ @GET
|
|
|
+ @Path("list/{tableFlag}/row/{id}/prev/{count}")
|
|
|
+ @Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
|
|
|
+ @Consumes(MediaType.APPLICATION_JSON)
|
|
|
+ public void listRowPrev(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
|
|
|
+ @JaxrsParameterDescribe("表标识") @PathParam("tableFlag") String tableFlag,
|
|
|
+ @JaxrsParameterDescribe("标识") @PathParam("id") String id,
|
|
|
+ @JaxrsParameterDescribe("数量") @PathParam("count") Integer count) {
|
|
|
+ ActionResult<List<JsonObject>> result = new ActionResult<>();
|
|
|
+ EffectivePerson effectivePerson = this.effectivePerson(request);
|
|
|
+ try {
|
|
|
+ result = new ActionListRowPrev().execute(effectivePerson, tableFlag, id, count);
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error(e, effectivePerson, request, null);
|
|
|
+ result.error(e);
|
|
|
+ }
|
|
|
+ asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|