|
|
@@ -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);
|
|
|
- });
|
|
|
-}
|