|
@@ -0,0 +1,35 @@
|
|
|
+package fi.er.webService;
|
|
|
+
|
|
|
+import kd.bos.openapi.api.plugin.ApiSerializerPlugin;
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import kd.bos.openapi.api.plugin.SerializerResult;
|
|
|
+import kd.bos.openapi.common.constant.MediaType;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 查询接口出入参序列化插件,处理枚举字段转换问题
|
|
|
+ * @author wanghaiwu_kd
|
|
|
+ * @date 2025/05/30
|
|
|
+ */
|
|
|
+public class PayQueryApiSerializerPlugin implements ApiSerializerPlugin {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public SerializerResult serialize(Object response, String accept, String contentType) {
|
|
|
+ try {
|
|
|
+ if (contentType.contains(MediaType.APPLICATION_JSON)) {
|
|
|
+ //返回text文本
|
|
|
+ String responseStr = new ObjectMapper().writeValueAsString(response);
|
|
|
+
|
|
|
+ responseStr = responseStr.replace("\"FBillStatus\":\"C\"", "\"FBillStatus\":\"12\"");
|
|
|
+
|
|
|
+ return new SerializerResult(MediaType.APPLICATION_JSON, responseStr);
|
|
|
+ } else {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
+ //处理异常时严禁抛出异常,可以定义自己的错误返回信息
|
|
|
+ String result="...";
|
|
|
+ return new SerializerResult(MediaType.TEXT_PLAIN,result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|