提交 29676c42 编写于 作者: Z zhourui

增加二维码生成接口

上级 17edc893
......@@ -4,6 +4,7 @@ import java.util.Set;
import javax.ws.rs.ApplicationPath;
import com.x.base.core.project.Version;
import com.x.base.core.project.jaxrs.AbstractActionApplication;
import com.x.general.assemble.control.jaxrs.area.AreaAction;
import com.x.general.assemble.control.jaxrs.ecnet.EcnetAction;
......@@ -14,6 +15,14 @@ import com.x.general.assemble.control.jaxrs.search.SearchAction;
import com.x.general.assemble.control.jaxrs.upgrade.UpgradeAction;
import com.x.general.assemble.control.jaxrs.worktime.WorkTimeAction;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Contact;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.info.License;
import io.swagger.v3.oas.annotations.servers.Server;
@OpenAPIDefinition(servers = {
@Server(url = "../../x_general_assemble_control", description = "current server.") }, info = @Info(title = "公共模块", version = Version.VALUE, description = "o2server x_general_assemble_control", license = @License(name = "AGPL-3.0", url = "https://www.o2oa.net/license.html"), contact = @Contact(url = "https://www.o2oa.net", name = "o2oa", email = "admin@o2oa.net")))
@ApplicationPath("jaxrs")
public class ActionApplication extends AbstractActionApplication {
......
......@@ -23,14 +23,27 @@ 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;
import com.x.general.assemble.control.jaxrs.qrcode.ActionGetCreate;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
@Tag(name = "AreaAction", description = "行政区域.")
@Path("area")
@JaxrsDescribe("行政区域")
@JaxrsDescribe("行政区域.")
public class AreaAction extends StandardJaxrsAction {
private static Logger logger = LoggerFactory.getLogger(AreaAction.class);
private static final Logger logger = LoggerFactory.getLogger(AreaAction.class);
private static final String OPERATIONID_PREFIX = "AreaAction::";
@JaxrsMethodDescribe(value = "获取指定的Attachment信息.", action = ActionListProvince.class)
@Operation(summary = "列示省级行政区域信息.", operationId = OPERATIONID_PREFIX + "listProvince", responses = {
@ApiResponse(content = {
@Content(array = @ArraySchema(schema = @Schema(implementation = ActionListProvince.Wo.class))) }) })
@JaxrsMethodDescribe(value = "列示省级行政区域信息.", action = ActionListProvince.class)
@GET
@Path("list")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
......@@ -47,7 +60,10 @@ public class AreaAction extends StandardJaxrsAction {
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "列示指定省下属市", action = ActionListCity.class)
@Operation(summary = "列示指定省所属市级行政区域信息.", operationId = OPERATIONID_PREFIX + "listCity", responses = {
@ApiResponse(content = {
@Content(array = @ArraySchema(schema = @Schema(implementation = ActionListCity.Wo.class))) }) })
@JaxrsMethodDescribe(value = "列示指定省所属市级行政区域信息.", action = ActionListCity.class)
@GET
@Path("list/province/{province}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
......@@ -65,7 +81,10 @@ public class AreaAction extends StandardJaxrsAction {
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "列示指定省/市下属区", action = ActionListStreet.class)
@Operation(summary = "列示指定省市所属区行政区域信息.", operationId = OPERATIONID_PREFIX + "listDistrict", responses = {
@ApiResponse(content = {
@Content(array = @ArraySchema(schema = @Schema(implementation = ActionListDistrict.Wo.class))) }) })
@JaxrsMethodDescribe(value = "列示指定省市所属区行政区域信息.", action = ActionListDistrict.class)
@GET
@Path("list/province/{province}/city/{city}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
......@@ -84,7 +103,10 @@ public class AreaAction extends StandardJaxrsAction {
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "列示指定省/市/区的下属街道", action = ActionListStreet.class)
@Operation(summary = "列示指定省市区所属街道行政区域信息.", operationId = OPERATIONID_PREFIX + "listStreet", responses = {
@ApiResponse(content = {
@Content(array = @ArraySchema(schema = @Schema(implementation = ActionListStreet.Wo.class))) }) })
@JaxrsMethodDescribe(value = "列示指定省市区所属街道行政区域信息.", action = ActionListStreet.class)
@GET
@Path("list/province/{province}/city/{city}/district/{district}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
......
......@@ -4,8 +4,7 @@ import java.util.ArrayList;
import java.util.List;
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.project.annotation.FieldDescribe;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.connection.ActionResponse;
import com.x.base.core.project.connection.ConnectionAction;
......@@ -13,33 +12,55 @@ 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.jaxrs.WrapString;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import io.swagger.v3.oas.annotations.media.Schema;
public class ActionCheck extends BaseAction {
private static final Logger LOGGER = LoggerFactory.getLogger(ActionCheck.class);
private static final String ADDRESS = "/o2_collect_assemble/jaxrs/ecnet/check";
ActionResult<Wo> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
ActionResponse response = ConnectionAction.post(Config.collect().url(ADDRESS), null, wi);
Wo wo = response.getData(Wo.class);
result.setData(wo);
return result;
}
LOGGER.debug("execute:{}.", effectivePerson::getDistinguishedName);
ActionResult<Wo> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
ActionResponse response = ConnectionAction.post(Config.collect().url(ADDRESS), null, wi);
Wo wo = response.getData(Wo.class);
result.setData(wo);
return result;
}
@Schema(name = "com.x.general.assemble.control.jaxrs.ecnet.ActionCheck$Wi")
public static class Wi extends WrapString {
private static final long serialVersionUID = 965883153862679625L;
}
@Schema(name = "com.x.general.assemble.control.jaxrs.ecnet.ActionCheck$Wo")
public static class Wo extends GsonPropertyObject {
private static final long serialVersionUID = 7549440867585619008L;
@FieldDescribe("位置.")
@Schema(description = "位置.")
private Integer pos = 0;
@FieldDescribe("原始值.")
@Schema(description = "原始值.")
private String origin = "";
@FieldDescribe("纠正值.")
@Schema(description = "纠正值.")
private String correct = "";
@FieldDescribe("纠正项.")
@Schema(description = "纠正项.")
private List<WoItem> itemList = new ArrayList<>();
public String getOrigin() {
......@@ -76,14 +97,25 @@ public class ActionCheck extends BaseAction {
}
@Schema(name = "com.x.general.assemble.control.jaxrs.ecnet.ActionCheck$WoItem")
public static class WoItem extends GsonPropertyObject {
private static final long serialVersionUID = 8709219948318947232L;
@FieldDescribe("原始值.")
@Schema(description = "原始值.")
private String origin;
@FieldDescribe("纠正值.")
@Schema(description = "纠正值.")
private String correct;
@FieldDescribe("开始位置.")
@Schema(description = "开始位置.")
private Integer begin;
@FieldDescribe("结束位置.")
@Schema(description = "结束位置.")
private Integer end;
public String getOrigin() {
......
......@@ -20,14 +20,27 @@ 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;
import com.x.general.assemble.control.jaxrs.qrcode.ActionPostCreate;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
@Tag(name = "EcnetAction", description = "文本纠错.")
@Path("ecnet")
@JaxrsDescribe("文本纠错")
@JaxrsDescribe("文本纠错.")
public class EcnetAction extends StandardJaxrsAction {
private static Logger logger = LoggerFactory.getLogger(EcnetAction.class);
private static final Logger logger = LoggerFactory.getLogger(EcnetAction.class);
private static final String OPERATIONID_PREFIX = "EcnetAction::";
@JaxrsMethodDescribe(value = "文本纠错.", action = ActionCheck.class)
@Operation(summary = "文本纠错检查.", operationId = OPERATIONID_PREFIX + "check", responses = { @ApiResponse(content = {
@Content(schema = @Schema(implementation = ActionCheck.Wo.class)) }) }, requestBody = @RequestBody(content = {
@Content(schema = @Schema(implementation = ActionCheck.Wi.class)) }))
@JaxrsMethodDescribe(value = "文本纠错检查.", action = ActionCheck.class)
@POST
@Path("check")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
......@@ -39,7 +52,7 @@ public class EcnetAction extends StandardJaxrsAction {
try {
result = new ActionCheck().execute(effectivePerson, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
......
......@@ -3,6 +3,7 @@ package com.x.general.assemble.control.jaxrs.generalfile;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.project.config.StorageMapping;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoFile;
......@@ -11,38 +12,42 @@ import com.x.base.core.project.logger.LoggerFactory;
import com.x.general.assemble.control.ThisApplication;
import com.x.general.core.entity.GeneralFile;
import io.swagger.v3.oas.annotations.media.Schema;
public class ActionGet extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionGet.class);
protected ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag) throws Exception {
logger.debug(effectivePerson, "flag:{}.", flag);
ActionResult<Wo> result = new ActionResult<>();
Wo wo = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
GeneralFile generalFile = emc.find(flag, GeneralFile.class);
if(generalFile!=null){
StorageMapping gfMapping = ThisApplication.context().storageMappings().get(GeneralFile.class,
generalFile.getStorage());
wo = new Wo(generalFile.readContent(gfMapping), this.contentType(false, generalFile.getName()),
this.contentDisposition(false, generalFile.getName()));
result.setData(wo);
} else {
throw new ExceptionInputFileObject(flag);
}
}
result.setData(wo);
return result;
}
public static class Wo extends WoFile {
public Wo(byte[] bytes, String contentType, String contentDisposition) {
super(bytes, contentType, contentDisposition);
}
}
private static final Logger LOGGER = LoggerFactory.getLogger(ActionGet.class);
protected ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag) throws Exception {
LOGGER.debug("execute:{}.", effectivePerson::getDistinguishedName);
ActionResult<Wo> result = new ActionResult<>();
Wo wo = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
GeneralFile generalFile = emc.find(flag, GeneralFile.class);
if (null == generalFile) {
throw new ExceptionEntityNotExist(flag);
}
StorageMapping mapping = ThisApplication.context().storageMappings().get(GeneralFile.class,
generalFile.getStorage());
wo = new Wo(generalFile.readContent(mapping), this.contentType(false, generalFile.getName()),
this.contentDisposition(false, generalFile.getName()));
result.setData(wo);
}
result.setData(wo);
return result;
}
@Schema(name = "com.x.general.assemble.control.jaxrs.generalfile.ActionGet$Wo")
public static class Wo extends WoFile {
private static final long serialVersionUID = 1445774150055126293L;
public Wo(byte[] bytes, String contentType, String contentDisposition) {
super(bytes, contentType, contentDisposition);
}
}
}
package com.x.general.assemble.control.jaxrs.generalfile;
import com.x.base.core.project.exception.PromptException;
public class ExceptionInputFileObject extends PromptException {
private static final long serialVersionUID = 9085364457175859374L;
ExceptionInputFileObject(String flag) {
super("对象不存在:{}.", flag);
}
}
\ No newline at end of file
......@@ -20,24 +20,34 @@ import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
@Tag(name = "GeneralFileAction", description = "通用附件.")
@Path("generalfile")
@JaxrsDescribe("获取附件")
@JaxrsDescribe("通用附件.")
public class GeneralFileAction extends StandardJaxrsAction {
private static Logger logger = LoggerFactory.getLogger(GeneralFileAction.class);
private static final Logger LOGGER = LoggerFactory.getLogger(GeneralFileAction.class);
private static final String OPERATIONID_PREFIX = "GeneralFileAction::";
@Operation(summary = "获取通用附件.", operationId = OPERATIONID_PREFIX + "get", responses = {
@ApiResponse(content = { @Content(schema = @Schema(implementation = ActionGet.Wo.class)) }) })
@JaxrsMethodDescribe(value = "获取附件.", action = ActionGet.class)
@GET
@Path("flag/{flag}")
@Consumes(MediaType.APPLICATION_JSON)
public void get(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("附件标记") @PathParam("flag") String flag) {
@JaxrsParameterDescribe("附件标识") @PathParam("flag") String flag) {
ActionResult<ActionGet.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionGet().execute(effectivePerson, flag);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
......
......@@ -2,7 +2,9 @@ package com.x.general.assemble.control.jaxrs.office;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
......@@ -15,11 +17,20 @@ 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.jaxrs.WoId;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.StringTools;
import io.swagger.v3.oas.annotations.media.Schema;
class ActionHtmlToWord extends BaseAction {
private static final Logger LOGGER = LoggerFactory.getLogger(ActionHtmlToWord.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
LOGGER.debug("execute:{}.", effectivePerson::getDistinguishedName);
ActionResult<Wo> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
byte[] bytes = this.local(wi);
......@@ -38,10 +49,10 @@ class ActionHtmlToWord extends BaseAction {
return result;
}
private byte[] local(Wi wi) throws Exception {
private byte[] local(Wi wi) throws IOException {
String content = "<html><head></head><body>" + wi.getContent() + "</body></html>";
try (POIFSFileSystem fs = new POIFSFileSystem();
InputStream is = new ByteArrayInputStream(content.getBytes("UTF-8"));
InputStream is = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8));
ByteArrayOutputStream out = new ByteArrayOutputStream()) {
fs.createDocument(is, "WordDocument");
fs.writeFilesystem(out);
......@@ -49,17 +60,26 @@ class ActionHtmlToWord extends BaseAction {
}
}
@Schema(name = "com.x.general.assemble.control.jaxrs.office.ActionHtmlToWord$Wo")
public static class Wo extends WoId {
private static final long serialVersionUID = 2125735475191163975L;
}
@Schema(name = "com.x.general.assemble.control.jaxrs.office.ActionHtmlToWord$Wi")
public static class Wi extends GsonPropertyObject {
private static final long serialVersionUID = -5654491825938383970L;
@FieldDescribe("转换文件名.")
@Schema(description = "转换文件名.")
private String fileName;
@FieldDescribe("内容.")
@Schema(description = "内容.")
private String content;
public String getFileName() throws Exception {
public String getFileName() {
return StringUtils.isEmpty(fileName) ? StringTools.uniqueToken() + ".doc" : fileName;
}
......
......@@ -13,12 +13,14 @@ import com.x.base.core.project.jaxrs.WoFile;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import io.swagger.v3.oas.annotations.media.Schema;
class ActionHtmlToWordResult extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionHtmlToWordResult.class);
private static final Logger LOGGER = LoggerFactory.getLogger(ActionHtmlToWordResult.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag) throws Exception {
logger.info("{}", flag);
LOGGER.debug("execute:{}.", effectivePerson::getDistinguishedName);
ActionResult<Wo> result = new ActionResult<>();
CacheKey cacheKey = new CacheKey(flag);
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
......@@ -35,9 +37,12 @@ class ActionHtmlToWordResult extends BaseAction {
}
return result;
}
@Schema(name = "com.x.general.assemble.control.jaxrs.office.ActionHtmlToWordResult$Wo")
public static class Wo extends WoFile {
private static final long serialVersionUID = 565805012046296971L;
public Wo(byte[] bytes, String contentType, String contentDisposition) {
super(bytes, contentType, contentDisposition);
}
......
......@@ -32,6 +32,7 @@ import fr.opensagres.poi.xwpf.converter.xhtml.XHTMLConverter;
import fr.opensagres.poi.xwpf.converter.xhtml.XHTMLOptions;
import fr.opensagres.xdocreport.converter.Options;
import fr.opensagres.xdocreport.converter.docx.poi.xhtml.XWPF2XHTMLConverter;
import io.swagger.v3.oas.annotations.media.Schema;
public class ActionToHtml extends BaseAction {
......@@ -56,7 +57,7 @@ public class ActionToHtml extends BaseAction {
*/
ActionResult<Wo> execute(EffectivePerson effectivePerson, byte[] bytes, FormDataContentDisposition disposition)
throws ParserConfigurationException, IOException, TransformerException, ExceptionUnsupportType {
LOGGER.debug("{} execute, fileName:{}.", effectivePerson::getDistinguishedName, disposition::getFileName);
LOGGER.debug("execute:{}, fileName:{}.", effectivePerson::getDistinguishedName, disposition::getFileName);
ActionResult<Wo> result = new ActionResult<>();
Tika tika = new Tika();
String type = tika.detect(bytes);
......@@ -108,6 +109,7 @@ public class ActionToHtml extends BaseAction {
}
}
@Schema(name = "com.x.general.assemble.control.jaxrs.office.ActionToHtml$Wo")
public static class Wo extends WrapString {
private static final long serialVersionUID = 6581539366197332222L;
}
......
......@@ -10,6 +10,8 @@ abstract class BaseAction extends StandardJaxrsAction {
public static class HtmlToWordResultObject extends GsonPropertyObject {
private static final long serialVersionUID = 2715784686635081821L;
private byte[] bytes;
private String name;
private String person;
......
......@@ -26,14 +26,26 @@ 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;
import com.x.general.assemble.control.jaxrs.ecnet.ActionCheck;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
@Tag(name = "OfficeAction", description = "office文件转换.")
@Path("office")
@JaxrsDescribe("office文件转换")
@JaxrsDescribe("office文件转换.")
public class OfficeAction extends StandardJaxrsAction {
private static Logger logger = LoggerFactory.getLogger(OfficeAction.class);
private static final Logger LOGGER = LoggerFactory.getLogger(OfficeAction.class);
private static final String OPERATIONID_PREFIX = "OfficeAction::";
@JaxrsMethodDescribe(value = "转换成html.", action = ActionToHtml.class)
@Operation(summary = "word转换html.", operationId = OPERATIONID_PREFIX + "input", responses = {
@ApiResponse(content = { @Content(schema = @Schema(implementation = ActionToHtml.Wo.class)) }) })
@JaxrsMethodDescribe(value = "word转换html.", action = ActionToHtml.class)
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
......@@ -45,13 +57,15 @@ public class OfficeAction extends StandardJaxrsAction {
try {
result = new ActionToHtml().execute(effectivePerson, bytes, disposition);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "html转换成word.", action = ActionHtmlToWord.class)
@Operation(summary = "html转换word.", operationId = OPERATIONID_PREFIX + "htmlToWord", responses = {
@ApiResponse(content = { @Content(schema = @Schema(implementation = ActionHtmlToWord.Wo.class)) }) })
@JaxrsMethodDescribe(value = "html转换word.", action = ActionHtmlToWord.class)
@POST
@Path("html/to/word")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
......@@ -63,12 +77,14 @@ public class OfficeAction extends StandardJaxrsAction {
try {
result = new ActionHtmlToWord().execute(effectivePerson, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
LOGGER.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@Operation(summary = "html转换成word结果流文件.", operationId = OPERATIONID_PREFIX + "htmlToWordResult", responses = {
@ApiResponse(content = { @Content(schema = @Schema(implementation = ActionHtmlToWordResult.Wo.class)) }) })
@JaxrsMethodDescribe(value = "html转换成word结果流文件.", action = ActionHtmlToWordResult.class)
@GET
@Path("html/to/word/result/{flag}")
......@@ -80,7 +96,7 @@ public class OfficeAction extends StandardJaxrsAction {
try {
result = new ActionHtmlToWordResult().execute(effectivePerson, flag);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
......
......@@ -6,13 +6,15 @@ import com.x.base.core.project.jaxrs.WoFile;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import io.swagger.v3.oas.annotations.media.Schema;
public class ActionGetCreate extends BaseAction {
private static final Logger LOGGER = LoggerFactory.getLogger(ActionGetCreate.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, Integer width, Integer height, String text)
throws Exception {
LOGGER.debug("effectivePerson: {}.", effectivePerson.getDistinguishedName());
LOGGER.debug("effectivePerson: {}.", effectivePerson::getDistinguishedName);
ActionResult<Wo> result = new ActionResult<>();
byte[] bytes = this.create(width, height, text);
Wo wo = new Wo(bytes, this.contentType(false, FILENAME), this.contentDisposition(false, FILENAME));
......@@ -20,7 +22,9 @@ public class ActionGetCreate extends BaseAction {
return result;
}
@Schema(name = "com.x.general.assemble.control.jaxrs.qrcode.ActionGetCreate$Wo")
public class Wo extends WoFile {
private static final long serialVersionUID = -6210739068105920249L;
public Wo(byte[] bytes, String contentType, String contentDisposition) {
......
......@@ -11,12 +11,14 @@ import com.x.base.core.project.jaxrs.WoFile;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import io.swagger.v3.oas.annotations.media.Schema;
public class ActionPostCreate extends BaseAction {
private static final Logger LOGGER = LoggerFactory.getLogger(ActionPostCreate.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
LOGGER.debug("effectivePerson: {}.", effectivePerson.getDistinguishedName());
LOGGER.debug("effectivePerson: {}.", effectivePerson::getDistinguishedName);
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
ActionResult<Wo> result = new ActionResult<>();
byte[] bytes = this.create(wi.getWidth(), wi.getHeight(), wi.getText());
......@@ -25,13 +27,17 @@ public class ActionPostCreate extends BaseAction {
return result;
}
@Schema(name = "com.x.general.assemble.control.jaxrs.qrcode.ActionPostCreate$Wi")
public class Wi extends GsonPropertyObject {
private static final long serialVersionUID = -670631145209495465L;
@FieldDescribe("转换文本")
@FieldDescribe("转换文本.")
@Schema(description = "转换文本.")
private String text;
@FieldDescribe("图像宽度,默认200.")
@Schema(description = "图像宽度,默认200.")
private Integer width;
@FieldDescribe("图像高度,默认200.")
@Schema(description = "图像高度,默认200.")
private Integer height;
public String getText() {
......@@ -60,6 +66,7 @@ public class ActionPostCreate extends BaseAction {
}
@Schema(name = "com.x.general.assemble.control.jaxrs.qrcode.ActionPostCreate$Wo")
public class Wo extends WoFile {
private static final long serialVersionUID = -6210739068105920249L;
......
......@@ -22,28 +22,23 @@ import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
@Tag(name = "QrCodeAction", description = "二维码.")
@Path("qrcode")
@JaxrsDescribe("二维码")
public class QrCodeAction extends StandardJaxrsAction {
private static final Logger LOGGER = LoggerFactory.getLogger(QrCodeAction.class);
private static final String OPERATIONID_PREFIX = "QrCodeAction::";
@JaxrsMethodDescribe(value = "POST方法生成二维码图像.", action = ActionPostCreate.class)
@POST
@Consumes(MediaType.APPLICATION_JSON)
public void postCreate(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
JsonElement jsonElement) {
ActionResult<ActionPostCreate.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionPostCreate().execute(effectivePerson, jsonElement);
} catch (Exception e) {
LOGGER.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@Operation(summary = "GET方法生成二维码图像.", operationId = OPERATIONID_PREFIX + "getCreate", responses = {
@ApiResponse(content = { @Content(schema = @Schema(implementation = ActionGetCreate.Wo.class)) }) })
@JaxrsMethodDescribe(value = "GET方法生成二维码图像.", action = ActionGetCreate.class)
@GET
@Path("width/{width}/height/{height}/text/{text}")
......@@ -63,4 +58,24 @@ public class QrCodeAction extends StandardJaxrsAction {
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@Operation(summary = "POST方法生成二维码图像.", operationId = OPERATIONID_PREFIX + "postCreate", responses = {
@ApiResponse(content = {
@Content(schema = @Schema(implementation = ActionPostCreate.Wo.class)) }) }, requestBody = @RequestBody(content = {
@Content(schema = @Schema(implementation = ActionPostCreate.Wi.class)) }))
@JaxrsMethodDescribe(value = "POST方法生成二维码图像.", action = ActionPostCreate.class)
@POST
@Consumes(MediaType.APPLICATION_JSON)
public void postCreate(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
JsonElement jsonElement) {
ActionResult<ActionPostCreate.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionPostCreate().execute(effectivePerson, jsonElement);
} catch (Exception e) {
LOGGER.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
}
\ No newline at end of file
......@@ -37,7 +37,7 @@ public class SearchAction extends StandardJaxrsAction {
@Operation(summary = "搜索.", operationId = OPERATIONID_PREFIX + "search", responses = {
@ApiResponse(content = { @Content(schema = @Schema(implementation = JsonElement.class)) }) })
@JaxrsMethodDescribe(value = "G搜索.", action = ActionSearch.class)
@JaxrsMethodDescribe(value = "搜索.", action = ActionSearch.class)
@POST
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
......
......@@ -22,12 +22,22 @@ import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
@Tag(name = "WorkTimeAction", description = "工作时间.")
@Path("worktime")
@JaxrsDescribe("工作时间")
@JaxrsDescribe("工作时间.")
public class WorkTimeAction extends StandardJaxrsAction {
private static Logger logger = LoggerFactory.getLogger(WorkTimeAction.class);
private static final Logger LOGGER = LoggerFactory.getLogger(WorkTimeAction.class);
private static final String OPERATIONID_PREFIX = "WorkTimeAction::";
@Operation(summary = "计算开始时间和结束时间之间的工作时间间隔(分钟).", operationId = OPERATIONID_PREFIX + "betweenMinutes", responses = {
@ApiResponse(content = { @Content(schema = @Schema(implementation = ActionBetweenMinutes.Wo.class)) }) })
@JaxrsMethodDescribe(value = "计算开始时间和结束时间之间的工作时间间隔(分钟).", action = ActionBetweenMinutes.class)
@GET
@Path("betweenminutes/start/{start}/end/{end}")
......@@ -41,12 +51,14 @@ public class WorkTimeAction extends StandardJaxrsAction {
try {
result = new ActionBetweenMinutes().execute(effectivePerson, start, end);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@Operation(summary = "计算开始时间前进指定分钟数后的工作时间.", operationId = OPERATIONID_PREFIX + "forwardMinutes", responses = {
@ApiResponse(content = { @Content(schema = @Schema(implementation = ActionForwardMinutes.Wo.class)) }) })
@JaxrsMethodDescribe(value = "计算开始时间前进指定分钟数后的工作时间.", action = ActionForwardMinutes.class)
@GET
@Path("forwardminutes/start/{start}/minutes/{minutes}")
......@@ -60,12 +72,14 @@ public class WorkTimeAction extends StandardJaxrsAction {
try {
result = new ActionForwardMinutes().execute(effectivePerson, start, minutes);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@Operation(summary = "计算开始时间前进指定工作天数后的工作时间.", operationId = OPERATIONID_PREFIX + "forwardDays", responses = {
@ApiResponse(content = { @Content(schema = @Schema(implementation = ActionForwardMinutes.Wo.class)) }) })
@JaxrsMethodDescribe(value = "计算开始时间前进指定工作天数后的工作时间.", action = ActionForwardDays.class)
@GET
@Path("forwarddays/start/{start}/days/{days}")
......@@ -79,12 +93,14 @@ public class WorkTimeAction extends StandardJaxrsAction {
try {
result = new ActionForwardDays().execute(effectivePerson, start, days);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@Operation(summary = "返回一个工作日的工作分钟数.", operationId = OPERATIONID_PREFIX + "minutesOfWorkDay", responses = {
@ApiResponse(content = { @Content(schema = @Schema(implementation = ActionMinutesOfWorkDay.Wo.class)) }) })
@JaxrsMethodDescribe(value = "返回一个工作日的工作分钟数.", action = ActionMinutesOfWorkDay.class)
@GET
@Path("minutesofworkday")
......@@ -96,12 +112,14 @@ public class WorkTimeAction extends StandardJaxrsAction {
try {
result = new ActionMinutesOfWorkDay().execute(effectivePerson);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@Operation(summary = "返回指定时间是否是工作时间.", operationId = OPERATIONID_PREFIX + "isWorkTime", responses = {
@ApiResponse(content = { @Content(schema = @Schema(implementation = ActionIsWorkTime.Wo.class)) }) })
@JaxrsMethodDescribe(value = "返回指定时间是否是工作时间.", action = ActionIsWorkTime.class)
@GET
@Path("isworktime/{date}")
......@@ -114,12 +132,14 @@ public class WorkTimeAction extends StandardJaxrsAction {
try {
result = new ActionIsWorkTime().execute(effectivePerson, date);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@Operation(summary = "返回指定时间是否是工作日.", operationId = OPERATIONID_PREFIX + "isWorkDay", responses = {
@ApiResponse(content = { @Content(schema = @Schema(implementation = ActionIsWorkDay.Wo.class)) }) })
@JaxrsMethodDescribe(value = "返回指定时间是否是工作日.", action = ActionIsWorkDay.class)
@GET
@Path("isworkday/{date}")
......@@ -132,12 +152,14 @@ public class WorkTimeAction extends StandardJaxrsAction {
try {
result = new ActionIsWorkDay().execute(effectivePerson, date);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@Operation(summary = "返回指定时间是否是节假日.", operationId = OPERATIONID_PREFIX + "isHoliday", responses = {
@ApiResponse(content = { @Content(schema = @Schema(implementation = ActionIsHoliday.Wo.class)) }) })
@JaxrsMethodDescribe(value = "返回指定时间是否是节假日.", action = ActionIsHoliday.class)
@GET
@Path("isholiday/{date}")
......@@ -150,12 +172,14 @@ public class WorkTimeAction extends StandardJaxrsAction {
try {
result = new ActionIsHoliday().execute(effectivePerson, date);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@Operation(summary = "返回指定时间是否定义为节假日.", operationId = OPERATIONID_PREFIX + "inDefinedHoliday", responses = {
@ApiResponse(content = { @Content(schema = @Schema(implementation = ActionInDefinedHoliday.Wo.class)) }) })
@JaxrsMethodDescribe(value = "返回指定时间是否定义为节假日.", action = ActionInDefinedHoliday.class)
@GET
@Path("indefinedholiday/{date}")
......@@ -168,12 +192,14 @@ public class WorkTimeAction extends StandardJaxrsAction {
try {
result = new ActionInDefinedHoliday().execute(effectivePerson, date);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@Operation(summary = "返回指定时间是否定义为工作日.", operationId = OPERATIONID_PREFIX + "inDefinedWorkDay", responses = {
@ApiResponse(content = { @Content(schema = @Schema(implementation = ActionInDefinedWorkDay.Wo.class)) }) })
@JaxrsMethodDescribe(value = "返回指定时间是否定义为工作日.", action = ActionInDefinedWorkDay.class)
@GET
@Path("indefinedworkday/{date}")
......@@ -186,26 +212,28 @@ public class WorkTimeAction extends StandardJaxrsAction {
try {
result = new ActionInDefinedWorkDay().execute(effectivePerson, date);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@Operation(summary = "根据2个日期计算出节假天数.", operationId = OPERATIONID_PREFIX + "betweenHolidayCount", responses = {
@ApiResponse(content = { @Content(schema = @Schema(implementation = ActionHolidayCount.Wo.class)) }) })
@JaxrsMethodDescribe(value = "根据2个日期计算出节假天数.", action = ActionHolidayCount.class)
@GET
@Path("betweenholidaycount/start/{startDate}/end/{endDate}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void betweenHolidayCount(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("开始日期") @PathParam("startDate") String start,
@JaxrsParameterDescribe("结束日期") @PathParam("endDate") String end) {
@JaxrsParameterDescribe("开始日期") @PathParam("startDate") String start,
@JaxrsParameterDescribe("结束日期") @PathParam("endDate") String end) {
ActionResult<ActionHolidayCount.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionHolidayCount().execute(effectivePerson, start, end);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
LOGGER.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
......
......@@ -14,6 +14,7 @@ import org.quartz.JobExecutionException;
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.config.StorageMapping;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
......@@ -23,22 +24,20 @@ import com.x.base.core.project.tools.ListTools;
import com.x.base.core.project.utils.time.TimeStamp;
import com.x.general.assemble.control.ThisApplication;
import com.x.general.core.entity.GeneralFile;
import com.x.general.core.entity.GeneralFile_;
public class Clean extends AbstractJob {
private static Logger logger = LoggerFactory.getLogger(Clean.class);
private static final Logger LOGGER = LoggerFactory.getLogger(Clean.class);
@Override
public void schedule(JobExecutionContext jobExecutionContext) throws Exception {
try{
logger.print("开始定时清理过期的缓存附件!");
try {
LOGGER.print("开始定时清理过期的缓存附件!");
TimeStamp stamp = new TimeStamp();
Long instantCount = this.clearGeneralFile();
logger.print("清理过期的缓存附件:{} 条, 耗时: {}.", instantCount,
stamp.consumingMilliseconds());
LOGGER.print("清理过期的缓存附件:{} 条, 耗时: {}.", instantCount, stamp.consumingMilliseconds());
} catch (Exception e) {
logger.error(e);
LOGGER.error(e);
throw new JobExecutionException(e);
}
}
......@@ -52,14 +51,20 @@ public class Clean extends AbstractJob {
if (!os.isEmpty()) {
emc.beginTransaction(GeneralFile.class);
for (GeneralFile o : os) {
StorageMapping gfMapping = ThisApplication.context().storageMappings().get(GeneralFile.class,
StorageMapping mapping = ThisApplication.context().storageMappings().get(GeneralFile.class,
o.getStorage());
o.deleteContent(gfMapping);
if (null != mapping) {
o.deleteContent(mapping);
} else {
LOGGER.warn("storage mapping not exist:{}.", o.getStorage());
}
emc.remove(o);
}
emc.commit();
count += os.size();
}
} catch (Exception e) {
LOGGER.error(e);
}
} while (ListTools.isNotEmpty(os));
return count;
......@@ -71,7 +76,7 @@ public class Clean extends AbstractJob {
CriteriaQuery<GeneralFile> cq = cb.createQuery(GeneralFile.class);
Root<GeneralFile> root = cq.from(GeneralFile.class);
Date limit = DateTools.floorDate(new Date(), 0);
Predicate p = cb.lessThan(root.get(GeneralFile_.createTime), limit);
Predicate p = cb.lessThan(root.get(JpaObject_.createTime), limit);
return em.createQuery(cq.select(root).where(p)).setMaxResults(100).getResultList();
}
......
......@@ -18,7 +18,7 @@ public class ActionDo extends ProxyServlet {
private static final long serialVersionUID = -2607395779516788482L;
private static Logger logger = LoggerFactory.getLogger(ActionDo.class);
private static final Logger LOGGER = LoggerFactory.getLogger(ActionDo.class);
@Override
protected String rewriteTarget(HttpServletRequest clientRequest) {
......@@ -38,7 +38,7 @@ public class ActionDo extends ProxyServlet {
return URLDecoder.decode(url, StandardCharsets.UTF_8.name());
}
} catch (UnsupportedEncodingException e) {
logger.error(e);
LOGGER.error(e);
}
return null;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册