Selaa lähdekoodia

修改 callback 语法泛型

huangbin 4 vuotta sitten
vanhempi
commit
a67afd0dda

+ 16 - 16
src/services/socket/account/index.ts

@@ -1,11 +1,11 @@
-import { Callback } from '@/utils/websocket/index';
 import APP from '@/services';
-import { LastUpdateTime_enum } from './enum';
+import { getLongTypeLoginID } from '@/services/bus/login';
 import { LastUpdateTimeModel } from '@/services/dataCenter/initDataModel/account';
-import * as accountType from './interface/index';
 import { buildProtoReq50, parseProtoRsp50 } from '@/services/socket/protobuf/buildReq';
-import { getLongTypeLoginID } from '@/services/bus/login';
+import { Callback } from '@/utils/websocket/index';
 import { sha256 } from 'js-sha256';
+import { LastUpdateTime_enum } from './enum';
+import * as accountType from './interface/index';
 
 const getAccoutIdList = () => {
     const accountList = APP.get('accountList');
@@ -31,7 +31,7 @@ export const queryAccountInfo = (QueryItem: string | number): Promise<string> =>
             reqParams: { LoginID, QueryItem },
         };
         const package50 = buildProtoReq50(params);
-        APP.sendTradingServer(package50, undefined, <Callback>{
+        APP.sendTradingServer(package50, undefined, {
             onSuccess: (res) => {
                 const { isSuccess, result } = parseProtoRsp50(res, 'LoginQueryRsp');
                 if (isSuccess) {
@@ -63,7 +63,7 @@ export const queryAccountInfo = (QueryItem: string | number): Promise<string> =>
             onFail: (err) => {
                 reject(err.message);
             },
-        });
+        } as Callback);
     });
 };
 
@@ -80,7 +80,7 @@ export const queryAreaRoleMarket = (): Promise<string> => {
             },
         };
         const package50 = buildProtoReq50(params);
-        APP.sendTradingServer(package50, undefined, <Callback>{
+        APP.sendTradingServer(package50, undefined, {
             onSuccess: (res) => {
                 const { isSuccess, result } = parseProtoRsp50(res);
                 if (isSuccess) {
@@ -93,7 +93,7 @@ export const queryAreaRoleMarket = (): Promise<string> => {
             onFail: (err) => {
                 reject(err.message);
             },
-        });
+        } as Callback);
     });
 };
 
@@ -107,7 +107,7 @@ export const queryTaAccountMarket = (): Promise<string> => {
             params: { taAccountIdList: getAccoutIdList() },
         };
         const package50 = buildProtoReq50(params);
-        APP.sendTradingServer(package50, undefined, <Callback>{
+        APP.sendTradingServer(package50, undefined, {
             onSuccess: (res) => {
                 const { isSuccess, result } = parseProtoRsp50(res);
                 if (isSuccess) {
@@ -120,7 +120,7 @@ export const queryTaAccountMarket = (): Promise<string> => {
             onFail: (err) => {
                 reject(err.message);
             },
-        });
+        } as Callback);
     });
 };
 /**
@@ -133,7 +133,7 @@ export const queryAccountTradeRuleAndFeeAndMargin = (): Promise<any> => {
             params: { accountidlist: getAccoutIdList() },
         };
         const package50 = buildProtoReq50(params);
-        APP.sendTradingServer(package50, undefined, <Callback>{
+        APP.sendTradingServer(package50, undefined, {
             onSuccess: (res) => {
                 const { isSuccess, result } = parseProtoRsp50(res);
                 if (isSuccess) {
@@ -145,7 +145,7 @@ export const queryAccountTradeRuleAndFeeAndMargin = (): Promise<any> => {
             onFail: (err) => {
                 reject(err.message);
             },
-        });
+        } as Callback);
     });
 };
 /**
@@ -158,7 +158,7 @@ export const queryTradeDate = (): Promise<string> => {
             params: { marketId: '0' },
         };
         const package50 = buildProtoReq50(params);
-        APP.sendTradingServer(package50, undefined, <Callback>{
+        APP.sendTradingServer(package50, undefined, {
             onSuccess: (res) => {
                 const { isSuccess, result } = parseProtoRsp50(res);
                 if (isSuccess) {
@@ -171,7 +171,7 @@ export const queryTradeDate = (): Promise<string> => {
             onFail: (err) => {
                 reject(err.message);
             },
-        });
+        } as Callback);
     });
 };
 
@@ -191,7 +191,7 @@ export const modifyPwdRequest = (param: accountType.ModifyPwdReq): Promise<any>
             },
         };
         const package50 = buildProtoReq50(params);
-        APP.sendTradingServer(package50, undefined, <Callback>{
+        APP.sendTradingServer(package50, undefined, {
             onSuccess: (res) => {
                 const { isSuccess, result } = parseProtoRsp50(res, 'ModifyPwdRsp');
                 if (isSuccess) {
@@ -201,6 +201,6 @@ export const modifyPwdRequest = (param: accountType.ModifyPwdReq): Promise<any>
                 }
             },
             onFail: (err) => reject(err.message),
-        });
+        } as Callback);
     });
 };

+ 14 - 14
src/services/socket/address/index.ts

@@ -1,10 +1,10 @@
 // 用户相关请求模块
 import APP from '@/services';
-import { Callback } from '@/utils/websocket/index';
 import { getUserId } from '@/services/bus/account';
-import { receiverInfo, queryProvinceAndCityParam, userReceiveInfoReq, userReceiveIsDefaultReq, delUserReceiveInfoReq } from './interface/index';
 import { buildProtoReq50, parseProtoRsp50 } from '@/services/socket/protobuf/buildReq';
 import { getUUID } from '@/utils/tool/common';
+import { Callback } from '@/utils/websocket/index';
+import { delUserReceiveInfoReq, queryProvinceAndCityParam, receiverInfo, userReceiveInfoReq, userReceiveIsDefaultReq } from './interface/index';
 
 /**
  * 查询用户收货信息表
@@ -19,7 +19,7 @@ export const queryAddressInfoList = (): Promise<receiverInfo[]> => {
             },
         };
         const package50 = buildProtoReq50(params);
-        APP.sendTradingServer(package50, undefined, <Callback>{
+        APP.sendTradingServer(package50, undefined, {
             onSuccess: (res) => {
                 const { isSuccess, result } = parseProtoRsp50(res, 'SearchReceiverRsp');
                 if (isSuccess) {
@@ -29,7 +29,7 @@ export const queryAddressInfoList = (): Promise<receiverInfo[]> => {
                 }
             },
             onFail: (err) => reject(err.message),
-        });
+        } as Callback);
     });
 };
 
@@ -45,7 +45,7 @@ export const queryProvinceAndCity = (param: queryProvinceAndCityParam): Promise<
             params: param,
         };
         const package50 = buildProtoReq50(params);
-        APP.sendTradingServer(package50, undefined, <Callback>{
+        APP.sendTradingServer(package50, undefined, {
             onSuccess: (res) => {
                 const { isSuccess, result } = parseProtoRsp50(res);
                 if (isSuccess) {
@@ -55,7 +55,7 @@ export const queryProvinceAndCity = (param: queryProvinceAndCityParam): Promise<
                 }
             },
             onFail: (err) => reject(err.message),
-        });
+        } as Callback);
     });
 };
 
@@ -75,7 +75,7 @@ export const addOrModifyUserReceiveInfo = (param: userReceiveInfoReq): Promise<a
             reqParams: Object.assign(req, param),
         };
         const package50 = buildProtoReq50(params);
-        APP.sendTradingServer(package50, undefined, <Callback>{
+        APP.sendTradingServer(package50, undefined, {
             onSuccess: (res) => {
                 const { isSuccess, result } = parseProtoRsp50(res, 'UserReceiveInfoRsp');
                 if (isSuccess) {
@@ -85,7 +85,7 @@ export const addOrModifyUserReceiveInfo = (param: userReceiveInfoReq): Promise<a
                 }
             },
             onFail: (err) => reject(err.message),
-        });
+        } as Callback);
     });
 };
 
@@ -103,7 +103,7 @@ export const setDefaultAddress = (param: userReceiveIsDefaultReq): Promise<any>
             reqParams: Object.assign(req, param),
         };
         const package50 = buildProtoReq50(params);
-        APP.sendTradingServer(package50, undefined, <Callback>{
+        APP.sendTradingServer(package50, undefined, {
             onSuccess: (res) => {
                 const { isSuccess, result } = parseProtoRsp50(res, 'UserReceiveIsDefaultRsp');
                 if (isSuccess) {
@@ -113,7 +113,7 @@ export const setDefaultAddress = (param: userReceiveIsDefaultReq): Promise<any>
                 }
             },
             onFail: (err) => reject(err.message),
-        });
+        } as Callback);
     });
 };
 
@@ -133,7 +133,7 @@ export const changeAddress = (param: userReceiveInfoReq): Promise<any> => {
             reqParams: Object.assign(req, param),
         };
         const package50 = buildProtoReq50(params);
-        APP.sendTradingServer(package50, undefined, <Callback>{
+        APP.sendTradingServer(package50, undefined, {
             onSuccess: (res) => {
                 const { isSuccess, result } = parseProtoRsp50(res, 'UserReceiveInfoRsp');
                 if (isSuccess) {
@@ -143,7 +143,7 @@ export const changeAddress = (param: userReceiveInfoReq): Promise<any> => {
                 }
             },
             onFail: (err) => reject(err.message),
-        });
+        } as Callback);
     });
 };
 
@@ -158,7 +158,7 @@ export const delAddress = (param: delUserReceiveInfoReq): Promise<any> => {
             reqParams: param,
         };
         const package50 = buildProtoReq50(params);
-        APP.sendTradingServer(package50, undefined, <Callback>{
+        APP.sendTradingServer(package50, undefined, {
             onSuccess: (res) => {
                 const { isSuccess, result } = parseProtoRsp50(res, 'DelUserReceiveInfoRsp');
                 if (isSuccess) {
@@ -168,6 +168,6 @@ export const delAddress = (param: delUserReceiveInfoReq): Promise<any> => {
                 }
             },
             onFail: (err) => reject(err.message),
-        });
+        } as Callback);
     });
 };

+ 18 - 18
src/services/socket/bank/index.ts

@@ -1,10 +1,10 @@
+import APP from '@/services';
+import { getAccoutIdList } from '@/services/bus/account';
 import { buildProtoReq50, parseProtoRsp50 } from '@/services/socket/protobuf/buildReq';
-import { sha256 } from 'js-sha256';
-
 import { Callback } from '@/utils/websocket/index';
+import { sha256 } from 'js-sha256';
 import * as type from './interface/index';
-import APP from '@/services';
-import { getAccoutIdList } from '@/services/bus/account';
+
 
 /**
  * 构建出金请求包的方法
@@ -32,7 +32,7 @@ export function buildOutMoney(param: type.buildOutMoneyReqParam) {
         Object.assign(params.reqParams, param, { OldTaPWD: sha256.hex(param.OldTaPWD) });
         console.log('params', params);
         const package50 = buildProtoReq50(params);
-        APP.sendTradingServer(package50, undefined, <Callback>{
+        APP.sendTradingServer(package50, undefined, {
             onSuccess: (res) => {
                 const { isSuccess, result } = parseProtoRsp50(res, 't2bBankWithdrawRsp');
                 if (isSuccess) {
@@ -44,7 +44,7 @@ export function buildOutMoney(param: type.buildOutMoneyReqParam) {
             onFail: (err) => {
                 reject(err.message)
             },
-        });
+        } as Callback);
     });
 }
 
@@ -65,7 +65,7 @@ export const requestBankSign = (param: type.t2bBankSignReq): Promise<type.t2bBan
             ),
         };
         const package50 = buildProtoReq50(params);
-        APP.sendTradingServer(package50, undefined, <Callback>{
+        APP.sendTradingServer(package50, undefined, {
             onSuccess: (res) => {
                 const { isSuccess, result } = parseProtoRsp50(res, 't2bBankSignRsp');
                 if (isSuccess) {
@@ -75,7 +75,7 @@ export const requestBankSign = (param: type.t2bBankSignReq): Promise<type.t2bBan
                 }
             },
             onFail: (err) => reject(err.message),
-        });
+        } as Callback);
     });
 };
 
@@ -96,7 +96,7 @@ export const requestBankCancelSign = (param: type.t2bBankCancelSignReq): Promise
             ),
         };
         const package50 = buildProtoReq50(params);
-        APP.sendTradingServer(package50, undefined, <Callback>{
+        APP.sendTradingServer(package50, undefined, {
             onSuccess: (res) => {
                 const { isSuccess, result } = parseProtoRsp50(res, 't2bBankCancelSignRsp');
                 if (isSuccess) {
@@ -106,7 +106,7 @@ export const requestBankCancelSign = (param: type.t2bBankCancelSignReq): Promise
                 }
             },
             onFail: (err) => reject(err.message),
-        });
+        } as Callback);
     });
 };
 
@@ -123,7 +123,7 @@ export const queryBankCustomerSign = (): Promise<type.BankAccountSign[]> => {
             },
         };
         const package50 = buildProtoReq50(params);
-        APP.sendTradingServer(package50, undefined, <Callback>{
+        APP.sendTradingServer(package50, undefined, {
             onSuccess: (res) => {
                 const { isSuccess, result } = parseProtoRsp50(res, 'BankSignRsp');
                 if (isSuccess) {
@@ -133,7 +133,7 @@ export const queryBankCustomerSign = (): Promise<type.BankAccountSign[]> => {
                 }
             },
             onFail: (err) => reject(err.message),
-        });
+        } as Callback);
     });
 };
 
@@ -147,7 +147,7 @@ export const queryCusBankInfo = (): Promise<type.CusBankInfoRsp> => {
             params: {},
         };
         const package50 = buildProtoReq50(params);
-        APP.sendTradingServer(package50, undefined, <Callback>{
+        APP.sendTradingServer(package50, undefined, {
             onSuccess: (res) => {
                 const { isSuccess, result } = parseProtoRsp50(res);
                 if (isSuccess) {
@@ -159,7 +159,7 @@ export const queryCusBankInfo = (): Promise<type.CusBankInfoRsp> => {
             onFail: (err) => {
                 reject(err.message);
             },
-        });
+        } as Callback);
     });
 };
 
@@ -173,7 +173,7 @@ export const queryBankInfo = (cusBankId: number): Promise<any> => {
             params: { cusBankId },
         };
         const package50 = buildProtoReq50(params);
-        APP.sendTradingServer(package50, undefined, <Callback>{
+        APP.sendTradingServer(package50, undefined, {
             onSuccess: (res) => {
                 const { isSuccess, result } = parseProtoRsp50(res);
                 if (isSuccess) {
@@ -185,7 +185,7 @@ export const queryBankInfo = (cusBankId: number): Promise<any> => {
             onFail: (err) => {
                 reject(err.message);
             },
-        });
+        } as Callback);
     });
 };
 /**
@@ -205,7 +205,7 @@ export const queryQueryBankInOut = (beginDate: string, endDate: string): Promise
             params: param,
         };
         const package50 = buildProtoReq50(params);
-        APP.sendTradingServer(package50, undefined, <Callback>{
+        APP.sendTradingServer(package50, undefined, {
             onSuccess: (res) => {
                 const { isSuccess, result } = parseProtoRsp50(res);
                 if (isSuccess) {
@@ -217,6 +217,6 @@ export const queryQueryBankInOut = (beginDate: string, endDate: string): Promise
             onFail: (err) => {
                 reject(err.message);
             },
-        });
+        } as Callback);
     });
 };

+ 5 - 5
src/services/socket/error/index.ts

@@ -1,6 +1,6 @@
-import { Callback } from '@/utils/websocket/index';
 import APP from '@/services';
 import { buildProtoReq50, parseProtoRsp50 } from '@/services/socket/protobuf/buildReq';
+import { Callback } from '@/utils/websocket/index';
 
 /**
  * 查询系统参数
@@ -13,7 +13,7 @@ export function querySystemParam(): Promise<string> {
             reqParams: { configUTime: APP.get('lastUpdateTime').configUTime },
         };
         const package50 = buildProtoReq50(params);
-        APP.sendTradingServer(package50, undefined, <Callback>{
+        APP.sendTradingServer(package50, undefined, {
             onSuccess: (res) => {
                 const { isSuccess, result } = parseProtoRsp50(res, 'ConfigQueryRsp');
                 if (isSuccess) {
@@ -24,7 +24,7 @@ export function querySystemParam(): Promise<string> {
                 }
             },
             onFail: (err) => reject(err.message),
-        });
+        } as Callback);
     });
 }
 /**
@@ -38,7 +38,7 @@ export function queryErrorCode(): Promise<string> {
             reqParams: { errorcodeUTime: APP.get('lastUpdateTime').errorcodeUTime },
         };
         const package50 = buildProtoReq50(params);
-        APP.sendTradingServer(package50, undefined, <Callback>{
+        APP.sendTradingServer(package50, undefined, {
             onSuccess: (res) => {
                 const { isSuccess, result } = parseProtoRsp50(res, 'ErrorCodeQueryRsp');
                 if (isSuccess) {
@@ -49,6 +49,6 @@ export function queryErrorCode(): Promise<string> {
                 }
             },
             onFail: (err) => reject(err.message),
-        });
+        } as Callback);
     });
 }

+ 12 - 12
src/services/socket/order/index.ts

@@ -1,13 +1,13 @@
 // 用户相关请求模块
-import { Callback } from '@/utils/websocket/index';
-import * as orderType from './interface/index';
+import { DelistingType, OperateType, OptionType, PriceType } from '@/enums/index';
 import APP from '@/services';
+import { getUserId } from '@/services/bus/account';
+import { getLongTypeLoginID } from '@/services/bus/login';
 import { buildProtoReq50, parseProtoRsp50 } from '@/services/socket/protobuf/buildReq';
-import { v4 as uuidv4 } from 'uuid';
+import { Callback } from '@/utils/websocket/index';
 import moment from 'moment';
-import { getLongTypeLoginID } from '@/services/bus/login';
-import { getUserId } from '@/services/bus/account';
-import { OptionType, OperateType, PriceType, DelistingType } from '@/enums/index';
+import { v4 as uuidv4 } from 'uuid';
+import * as orderType from './interface/index';
 
 /**
  * 交易委托请求
@@ -44,7 +44,7 @@ export const orderReq = (param: orderType.OrderReqType): Promise<string> => {
         };
         Object.assign(params.reqParams, param);
         const package50 = buildProtoReq50(params);
-        APP.sendTradingServer(package50, undefined, <Callback>{
+        APP.sendTradingServer(package50, undefined, {
             onSuccess: (res) => {
                 const { isSuccess, result } = parseProtoRsp50(res, 'OrderRsp');
                 if (isSuccess) {
@@ -55,7 +55,7 @@ export const orderReq = (param: orderType.OrderReqType): Promise<string> => {
                 }
             },
             onFail: (err) => reject(err.message),
-        });
+        } as Callback);
     });
 };
 
@@ -84,7 +84,7 @@ export const cancelOrderReq = (param: orderType.CancelOrderReq): Promise<string>
             },
         };
         const package50 = buildProtoReq50(params);
-        APP.sendTradingServer(package50, undefined, <Callback>{
+        APP.sendTradingServer(package50, undefined, {
             onSuccess: (res) => {
                 const { isSuccess, result } = parseProtoRsp50(res, 'CancelOrderRsp');
                 if (isSuccess) {
@@ -94,7 +94,7 @@ export const cancelOrderReq = (param: orderType.CancelOrderReq): Promise<string>
                 }
             },
             onFail: (err) => reject(err.message),
-        });
+        } as Callback);
     });
 };
 
@@ -119,7 +119,7 @@ export function CancelPaymentReq(param: orderType.CancelPaymentReq): Promise<str
             },
         };
         const package50 = buildProtoReq50(params);
-        APP.sendTradingServer(package50, undefined, <Callback>{
+        APP.sendTradingServer(package50, undefined, {
             onSuccess: (res) => {
                 const { isSuccess, result } = parseProtoRsp50(res, 'CancelPaymentRsp');
                 if (isSuccess) {
@@ -129,6 +129,6 @@ export function CancelPaymentReq(param: orderType.CancelPaymentReq): Promise<str
                 }
             },
             onFail: (err) => reject(err.message),
-        });
+        } as Callback);
     });
 }

+ 5 - 5
src/services/socket/quota/index.ts

@@ -1,7 +1,7 @@
-import { buildSubscribePeq, parseSubscribeRsp } from '@/services/socket/quota/adapter/index';
+import { funCode } from '@/funcode/index';
 import APP from '@/services';
+import { buildSubscribePeq, parseSubscribeRsp } from '@/services/socket/quota/adapter/index';
 import { Callback } from '@/utils/websocket/index';
-import { funCode } from '@/funcode/index';
 import { subscribeInfoType } from './interface';
 
 const subscribeGoodsList = new Map<string, subscribeInfoType[]>(); // 订阅商品数据中心池
@@ -29,7 +29,7 @@ function recombinationSubscribeGoods(): subscribeInfoType[] {
 function actionSubcribe() {
     const arr = recombinationSubscribeGoods();
     const req = buildSubscribePeq(arr);
-    APP.sendQuoteServer(req, funCode.MainClassNumber_Quota_SubscriptRsp, <Callback>{
+    APP.sendQuoteServer(req, funCode.MainClassNumber_Quota_SubscriptRsp, {
         onSuccess: (res: any) => {
             parseSubscribeRsp(res)
                 .then((value) => {
@@ -42,14 +42,14 @@ function actionSubcribe() {
                 });
         },
         onFail: (err) => console.log(err),
-    });
+    } as Callback);
 }
 
 /**
  * 添加行情订阅
  * @param subscribeInfos
  */
-export async function addSubscribeQuotation(uuid: string, subscribeInfos: subscribeInfoType[]) {
+export function addSubscribeQuotation(uuid: string, subscribeInfos: subscribeInfoType[]) {
     APP.connectQuote().then(() => {
         subscribeGoodsList.set(uuid, subscribeInfos);
         actionSubcribe();