huangbin 4 роки тому
батько
коміт
b94ee05106

+ 1 - 1
public/config/app.config.json

@@ -1,3 +1,3 @@
 {
-    "apiUrl": "http://192.168.31.204:8080/cfg?key=test_204"
+    "apiUrl": "http://192.168.31.139:8080/cfg?key=test_139"
 }

+ 3 - 4
src/services/proto/manager/index.ts

@@ -1,14 +1,13 @@
 /**
  *****************     管理端接口  *******************
  */
-import {protoMiddleware, protoMiddleware_manager} from "@/services/socket/protobuf/buildReq";
 import {
     GoodsPickupConfirmReq, GoodsPickupConfirmRsp,
     GoodsPickupOperateReq, GoodsPickupOperateRsp, QHJAgreementConfigOperateReq, QHJAgreementConfigOperateRsp,
     t2bExchConfirmBusinessReq,
     t2bExchConfirmBusinessRsp
 } from "@/services/proto/manager/interface";
-import {IMessageHead} from "@/services/socket/protobuf/proto";
+import { protoMiddleware } from "@/services/socket/protobuf/buildReq";
 
 /**
  * 交易所审核结果通知请求
@@ -31,9 +30,9 @@ export const goodsPickupOperate = (param: GoodsPickupOperateReq): Promise<GoodsP
  * @param param MarketID市场id
  */
 export const goodsPickupConfirm = (param: GoodsPickupConfirmReq): Promise<GoodsPickupConfirmRsp> => {
-    var marketid = param.MarketID
+    const marketid = param.MarketID
     delete param.MarketID
-    return protoMiddleware_manager<GoodsPickupConfirmReq>(param, 'GoodsPickupConfirmReq', 'GoodsPickupConfirmRsp', {MarketID: marketid})
+    return protoMiddleware<GoodsPickupConfirmReq>(param, 'GoodsPickupConfirmReq', 'GoodsPickupConfirmRsp', { MarketID: marketid })
     // return protoMiddleware<GoodsPickupConfirmReq>(param, 'GoodsPickupConfirmReq', 'GoodsPickupConfirmRsp', 4)
 }
 

+ 9 - 36
src/services/socket/protobuf/buildReq.ts

@@ -110,12 +110,12 @@ function buildMsgHead(funCodeName: string, params: IMessageHead) {
  * @param params SoleSearchParam
  */
 function buildSoleProtoReq50(params: SoleSearchParam): Package50 {
-    const { protobufName, funCodeName, reqParams, headerEnum, headParam } = params;
+    const { protobufName, funCodeName, reqParams, Header } = params;
     // // // 消息头
     // const messageHead = buildMsgHead(funCodeName, headParam);
     // proto头部参数,站在用户角度,参数数据可以通用获取,但站在管理端的角度,则需要不能通用获取,而是需用选中对应数据中传入进来
     // 登录报文
-    const header = headParam ? buildMsgHead(funCodeName, headParam) : getProtoHeadParam(funCodeName, headerEnum);
+    const header = typeof Header == 'object' ? buildMsgHead(funCodeName, Header) : getProtoHeadParam(funCodeName, Header);
     const Req = buildSoleProtoReq(protobufName, reqParams);
     Req.Header = header
     return setPackage50(funCodeName, Req);
@@ -258,21 +258,25 @@ function lower(value: string): string {
     return value.toLowerCase();
 }
 
+// 枚举 proto hader
+export function protoMiddleware<T>(param: T, reqName: string, rspName: string, headerEnum: HeadEnum): Promise<any>
+// 自定义 protp header
+export function protoMiddleware<T>(param: T, reqName: string, rspName: string, headerEnum: IMessageHead): Promise<any>
+
 /**
- * 此方法站在 用户角度
  * @param param proto除去head 剩下参数
  * @param headerEnum 自定义的proto参数枚举值,减小重复抒写 默认0
  * @param reqFuncodeName proto 发送请求定义的头名字,特别需要注意,自已的funCodeName要与这个一致
  * @param rspFuncodeName proto 响应请求定义的头名字
  * @returns
  */
-export function protoMiddleware<T>(param: T, reqName: string, rspName: string, headerEnum: HeadEnum = 0): Promise<any> {
+export function protoMiddleware<T>(param: T, reqName: string, rspName: string, headerEnumOrParam: HeadEnum | IMessageHead = 0): Promise<any> {
     return new Promise((resolve, reject) => {
         const params = {
             protobufName: reqName,
             funCodeName: reqName,
             reqParams: param,
-            headerEnum,
+            Header: headerEnumOrParam,
         };
         const package50 = buildProtoReq50(params);
         const code = rspName ? funCode[rspName] : undefined
@@ -292,34 +296,3 @@ export function protoMiddleware<T>(param: T, reqName: string, rspName: string, h
         } as Callback);
     });
 }
-
-/**
- * 此方法站在 管理端角度
- * @param param proto除去head 剩下参数
- * @param headParam IMessageHead
- * @param reqFuncodeName proto 发送请求定义的头名字,特别需要注意,自已的funCodeName要与这个一致
- * @param rspFuncodeName proto 响应请求定义的头名字
- * @returns
- */
-export function protoMiddleware_manager<T>(param: T, reqName: string, rspName: string, headParam: IMessageHead): Promise<any> {
-    return new Promise((resolve, reject) => {
-        const params = {
-            protobufName: reqName,
-            funCodeName: reqName,
-            reqParams: param,
-            headParam,
-        };
-        const package50 = buildProtoReq50(params);
-        APP.sendTradingServer(package50, undefined, {
-            onSuccess: (res) => {
-                const { isSuccess, result } = parseProtoRsp50(res, rspName);
-                if (isSuccess) {
-                    resolve(result);
-                } else {
-                    reject(result);
-                }
-            },
-            onFail: (err) => reject(err.message),
-        } as Callback);
-    });
-}

+ 1 - 4
src/services/socket/protobuf/interface.ts

@@ -17,10 +17,7 @@ export interface SoleSearchParam {
     protobufName: string; // protobuf名
     funCodeName: string; // funCode名
     reqParams: ReqParams; // 传入后台报文中的各种参数
-    headerEnum?: HeadEnum, // messgeHead 参数枚举
-    headParam?: IMessageHead; // messgeHead 参数
-
-    Header?: IMessageHead; // messgeHead 参数
+    Header?: IMessageHead | HeadEnum; // messgeHead 参数
 }
 
 export interface ParseRsp {