浏览代码

增加HttpApi共同业务处理接口

wuxw7 8 年之前
父节点
当前提交
5fb2297fac

+ 17 - 5
CenterService/doc/centerService.docx

@@ -801,13 +801,13 @@ Timeout
 Int
 
 超时时间
-
+ 
 Retry_count
 Int
 
 重试次数
-
+ 
 create_time
 date
@@ -863,7 +863,7 @@ Status_cd
 Varchar
 1
 数据状态
-0表示在用,1表示失效
+ 0表示在用,1表示失效
 create_time
 date
@@ -883,7 +883,7 @@ date
  如果是异步方式,直接发送kafka消息。
  如果是异步方式,kafka 监听修改状态消息,如果,下游处理失败,则作废订单和业务项数据,发送作废所有下游消息(这里传b_id 和o_id)。
  Json协议模板
-
+1、请求模板
 {
 	"orders": {
 		"AppId": "外系统ID,分配得到",
@@ -912,6 +912,18 @@ date
 	}]
 }
 
-
+2、返回模板
+{  "orders": {    "TransactionId": "100000000020180409224736000001",    "ResponseTime": "20180409224736",    "Remark":"备注",    "sign": "这个服务是否要求MD5签名",    "response": {//这个是centerOrder 返回的状态结果      "code": "1999",      "message": "错误信息"    }  },  "business":[{//这个是相应的业务系统返回的结果,(受理为空,查询时不为空)    "response": {      "code": "1999",      "message": "错误消息"    }    //相应内容  }]}
+六、状态码说明
+                                 状态编码
+                                    描述
+                                     0000
+                                    成功
+                                     1999
+                                 未知失败
+                                     1998
+                              系统内部错误
+                                     1997
+                           调用下游系统超时
  
  

+ 27 - 0
CenterService/doc/request_protocol.json

@@ -0,0 +1,27 @@
+{
+  "orders": {
+    "AppId": "外系统ID,分配得到",
+    "TransactionId": "100000000020180409224736000001",
+    "UserId": "用户ID",
+    "OrderTypeCd": "订单类型,查询,受理",
+    "RequestTime": "20180409224736",
+    "Remark":"备注",
+    "sign": "这个服务是否要求MD5签名",
+    "Attrs": [{
+      "SpecCd": "配置的字段ID",
+      "Value": "具体值"
+    }]
+  },
+  "business": [{
+    "ServiceCode": "queryCustInfo",
+    "ServiceName": "查询客户",
+    "Remark": "备注",
+    "datas": [{
+      //这里是具体业务
+    }],
+    "Attrs": [{
+      "SpecCd": "配置的字段ID",
+      "Value": "具体值"
+    }]
+  }]
+}

+ 19 - 0
CenterService/doc/response_protocol.json

@@ -0,0 +1,19 @@
+{
+  "orders": {
+    "TransactionId": "100000000020180409224736000001",
+    "ResponseTime": "20180409224736",
+    "Remark":"备注",
+    "sign": "这个服务是否要求MD5签名",
+    "response": {//这个是centerOrder 返回的状态结果
+      "code": "1999",
+      "message": "具体值"
+    }
+  },
+  "business":[{//这个是相应的业务系统返回的结果,(受理为空,查询时不为空)
+    "response": {
+      "code": "1999",
+      "message": "具体值"
+    }
+    //相应内容
+  }]
+}

+ 0 - 0
CenterService/doc/~$nterService.docx


+ 16 - 1
CenterService/pom.xml

@@ -13,7 +13,7 @@
 
     <name>CenterService</name>
     <!-- FIXME change it to the project's website -->
-    <url>http://www.example.com</url>
+    <url>http://maven.apache.org</url>
 
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -22,6 +22,21 @@
     </properties>
 
     <dependencies>
+        <dependency>
+            <groupId>com.java110</groupId>
+            <artifactId>java110-service</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.java110</groupId>
+            <artifactId>java110-event</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.java110</groupId>
+            <artifactId>java110-config</artifactId>
+            <scope>provided</scope>
+        </dependency>
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>

+ 30 - 0
CenterService/src/main/java/com/java110/center/CenterServiceApplication.java

@@ -0,0 +1,30 @@
+package com.java110.center;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.context.ApplicationContext;
+
+
+/**
+ * spring boot 初始化启动类
+ *
+ * @version v0.1
+ * @auther com.java110.wuxw
+ * @mail 928255095@qq.com
+ * @date 2016年8月6日
+ * @tag
+ */
+@SpringBootApplication(scanBasePackages={"com.java110.service","com.java110.order","com.java110.core","com.java110.event"})
+@EnableDiscoveryClient
+//@EnableConfigurationProperties(EventProperties.class)
+public class CenterServiceApplication {
+
+    public static void main(String[] args) throws Exception{
+        ApplicationContext context = SpringApplication.run(CenterServiceApplication.class, args);
+
+        /*SystemStartUpInit systemStartUpInit = new SystemStartUpInit();
+
+        systemStartUpInit.initSystemConfig(context);*/
+    }
+}

+ 29 - 0
CenterService/src/main/java/com/java110/center/rest/HttpApi.java

@@ -0,0 +1,29 @@
+package com.java110.center.rest;
+
+import com.java110.common.constant.ResponseConstant;
+import com.java110.common.util.ResponseTemplateUtil;
+import com.java110.core.base.controller.BaseController;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 中心http服务 统一服务类
+ *  1、只提供service方法
+ * Created by wuxw on 2018/4/13.
+ */
+@RestController
+public class HttpApi extends BaseController {
+
+    @RequestMapping(path = "/httpApi/service",method= RequestMethod.GET)
+    public String serviceGet(@RequestParam("orderInfo") String orderInfo) {
+        return ResponseTemplateUtil.createOrderResponseJson(ResponseConstant.NO_TRANSACTION_ID,
+                ResponseConstant.NO_NEED_SIGN,ResponseConstant.RESULT_CODE_ERROR,"不支持Get方法请求");
+    }
+
+    @RequestMapping(path = "/httpApi/service",method= RequestMethod.POST)
+    public String servicePost(@RequestParam("orderInfo") String orderInfo) {
+        return "";
+    }
+}

+ 16 - 0
java110-common/src/main/java/com/java110/common/constant/ResponseConstant.java

@@ -16,8 +16,24 @@ public class ResponseConstant {
      */
     public final static String RESULT_CODE_ERROR = "1999";
 
+    /**
+     * 失败,通用失败编码
+     */
+    public final static String RESULT_CODE_INNER_ERROR = "1998";
+
+    /**
+     * 失败,通用失败编码
+     */
+    public final static String RESULT_CODE_TIME_OUT_ERROR = "1997";
+
     /**
      * 失败,入参错误,为空或格式错误
      */
     public final static String RESULT_CODE_PARAM_ERROR = "1001";
+
+    /**
+     * 没有从报文中获取到 请求流水
+     */
+    public final static String NO_TRANSACTION_ID = "-1";
+    public final static String NO_NEED_SIGN = "";
 }

+ 74 - 0
java110-common/src/main/java/com/java110/common/util/ResponseTemplateUtil.java

@@ -0,0 +1,74 @@
+package com.java110.common.util;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.common.constant.ResponseConstant;
+
+import java.util.Date;
+
+/**
+ * 接口返回模板类
+ *
+ * {
+     "orders": {
+         "TransactionId": "100000000020180409224736000001",
+         "ResponseTime": "20180409224736",
+         "sign": "这个服务是否要求MD5签名",
+         "response": {//这个是centerOrder 返回的状态结果
+         "code": "1999",
+         "message": "具体值"
+         }
+     },
+     "business":[{//这个是相应的业务系统返回的结果,(受理为空,查询时不为空)
+         "response": {
+         "code": "1999",
+         "message": "具体值"
+         }
+     //相应内容
+     }]
+ }
+ * Created by wuxw on 2018/4/13.
+ */
+public class ResponseTemplateUtil {
+
+    /**
+     * 创建 通用返回结果模板
+     * @param transactionId 交易流水
+     * @param sign 签名
+     * @param code 错误
+     * @param message 错误信息
+     * @param business 业务信息
+     * @return
+     */
+    public static String createCommonResponseJson(String transactionId,
+                                                  String sign,
+                                                  String code,
+                                                  String message,
+                                                  JSONArray business){
+
+        JSONObject responseInfo = JSONObject.parseObject("{\"orders\":{\"response\":{}}}");
+        JSONObject orderInfo = responseInfo.getJSONObject("orders");
+        orderInfo.put("TransactionId",transactionId);
+        orderInfo.put("ResponseTime",DateUtil.getDefaultFormateTimeString(new Date()));
+        orderInfo.put("sign",sign);
+        JSONObject orderResponseInfo = orderInfo.getJSONObject("response");
+        orderResponseInfo.put("code",code);
+        orderResponseInfo.put("message",message);
+        if (business != null && business.size() > 0){
+            responseInfo.put("business",business);
+        }
+        return responseInfo.toJSONString();
+    }
+
+    /**
+     * 返回模板 只有Order信息
+     * @param transactionId
+     * @param sign
+     * @param code
+     * @param message
+     * @return
+     */
+    public static String createOrderResponseJson(String transactionId, String sign,String code,String message){
+        return createCommonResponseJson(transactionId,sign,code,message,null);
+    }
+}