import e, { Request, Response } from 'express'; /** * @author bianlanzhou * @since 2024-09-20 * @desc 接出网关API-MOCK */ /** 等待时间 */ const waitTime = (time: number = 100) => { return new Promise((resolve) => { setTimeout(() => { resolve(true); }, time); }); }; /** 分页查询接出API响应数据 */ const pageQueryEgressApiRespData = { "success": true, "errCode": null, "errMessage": null, "total": 1, "pageSize": 10, "pageIndex": 1, "data": [ { "id": 1, "apiName": "xxxxx-助贷", "apiCode": "zd-00001", "apiType": "loan", "createUsername": "张元英", "gmtCreate": "2024-10-21T09:33:51.000+00:00", "modifyUsername": "张元英", "gmtModify": "2024-10-21T09:33:51.000+00:00", "techOwnerUsername": "张元英", "techOwnerUserid": "10000", "memo": null, "status": "ok" } ], "totalPages": 1, "notEmpty": true, "empty": false } /** 创建接出API通道响应数据 */ const upsertEgressApiRespData = { "success": true, "errCode": null, "errMessage": null, "data": 1848565642249170945 } /** 查询接出API响应数据 */ const queryEgressApiRespData = { "success": true, "errCode": null, "errMessage": null, "data": [ { "id": '1848565642249170945', "apiName": "xxxxx-xx", "apiCode": "product-xxx", "apiType": "product", "createUsername": "admin", "gmtCreate": "2024-10-22 03:22:51", "modifyUsername": "admin", "gmtModify": "2024-10-22 03:22:51", "techOwnerUsername": "admin", "memo": "xxxxxxyyyyyy", "status": "draft" }, { "id": '1848565642249170946', "apiName": "yyyyy-yy", "apiCode": "loan-xxx", "apiType": "loan", "createUsername": "admin", "gmtCreate": "2024-10-22 03:22:51", "modifyUsername": "admin", "gmtModify": "2024-10-22 03:22:51", "techOwnerUsername": "admin", "memo": "xxxxxxyyyyyy", "status": "draft" } ] } /** 助贷API对接响应数据 */ const loanApiIntegrationRespData = { "success": true, "errCode": null, "errMessage": null, } /** 分页查询接出API通道响应数据 */ const pageQueryEgressApiEndpointRespData = { "success": true, "errCode": null, "errMessage": null, "data": [ { "id": '1848565642249170945', "apiName": "xxxxx-xx", "endpointName": "xxxxx-xx-撞库", "integrationMode": "customize", "apiType": "product", "createUsername": "admin", "gmtCreate": "2024-10-22T03:22:51.000+00:00", "modifyUsername": "admin", "gmtModify": "2024-10-22T03:22:51.000+00:00", }, { "id": '1848565642249170946', "apiName": "yyyyy-yy", "endpointName": "xxxxx-xx-申请", "integrationMode": "guide", "apiType": "loan", "createUsername": "admin", "gmtCreate": "2024-10-22T03:22:51.000+00:00", "modifyUsername": "admin", "gmtModify": "2024-10-22T03:22:51.000+00:00", } ] } /** 查询撞库API通道响应数据 */ const queryCiApiEndpointRespData = { "success": true, "data": [ { "id": "1853335011944685569", "apiId": "1853241164564557825", "apiType": "loan", "apiName": "测试001", "endpointName": "测试001-撞库", "integrationMode": "customize", "gmtCreate": "2024-11-04 16:48:33", "gmtModify": "2024-11-04 16:48:33", "requestConfig": "{req-checkinto}", "responseConfig": "{req-checkinto}" } ] } /** 查询API通道响应数据 */ const queryApiEndpointRespData = { "success": true, "errCode": null, "errMessage": null, "data": [ { "id": '1848565642249170945', "apiName": "xxxxx-xx", "endpointName": "xxxxx-xx-撞库", "integrationMode": "guide", "apiType": "product", "createUsername": "admin", "gmtCreate": "2024-10-22T03:22:51.000+00:00", "modifyUsername": "admin", "gmtModify": "2024-10-22T03:22:51.000+00:00", "requestConfig": "{}", } ] } /** 查询申请API通道响应数据 */ const queryApiApplyEndpointRespData = { "success": true, "data": [ { "id": "1853335012297007105", "apiId": "1853241164564557825", "apiType": "loan", "apiName": "测试001", "endpointName": "测试001-注册", "integrationMode": "guide", "gmtCreate": "2024-11-04 16:48:33", "gmtModify": "2024-11-04 16:48:33", "requestConfig": "{\"url\":\"http://biying.com/apply\",\"method\":\"POST\"}", "responseConfig": "{\"integrationMode\":\"guide\",\"responseConfig\":\"{resp-apply}\",\"method\":\"GET\",\"url\":\"http://baidu.com/apply\"xxxx" } ] } /** 查询助贷API响应数据 */ const queryApiLoanRespData = { "success": true, "errCode": null, "errMessage": null, "data": { "id": '1848565642249170945', "merchantId": '1848565642249170945', "checkinto": "yes", "integrationSystem": "2", "gmtCreate": "2024-10-22T03:22:51.000+00:00", "modifyUsername": "admin", "gmtModify": "2024-10-22T03:22:51.000+00:00", } } /** 删除接出API响应数据 */ const deleteEgressApiRespData = { "success": true, "errCode": null, "errMessage": null, } /** 分页查询接出API */ const pageQueryEgressApi = async (req: Request, res: Response) => { await waitTime(2000); res.json(pageQueryEgressApiRespData); } /** 查询接出API */ const queryEgressApi = async (req: Request, res: Response) => { await waitTime(2000); res.json(queryEgressApiRespData); } /** 创建更新接出API */ const upsertEgressApi = async (req: Request, res: Response) => { await waitTime(2000); res.json(upsertEgressApiRespData); } /** 助贷API对接 */ const loanApiIntegration = async (req: Request, res: Response) => { await waitTime(2000); res.json(loanApiIntegrationRespData); } /** 分页查询接出API通道 */ const pageQueryEgressApiEndpoint = async (req: Request, res: Response) => { await waitTime(2000); res.json(pageQueryEgressApiEndpointRespData); } /** 查询API通道 */ const queryApiEndpoint = async (req: Request, res: Response) => { await waitTime(2000); if (req.query.endpointCode === 'checkinto') { res.json(queryCiApiEndpointRespData); } else if (req.query.endpointCode === 'apply') { res.json(queryApiApplyEndpointRespData); } else { res.json(queryApiEndpointRespData); } } /** 查询助贷API信息 */ const queryApiLoan = async (req: Request, res: Response) => { await waitTime(2000); res.json(queryApiLoanRespData); } /** 删除接出API */ const deleteEgressApi = async (req: Request, res: Response) => { await waitTime(2000); res.json(deleteEgressApiRespData); } export default { 'GET /egress/api/page': pageQueryEgressApi, 'GET /egress/api/list': queryEgressApi, 'PUT /egress/api/upsert': upsertEgressApi, 'PUT /egress/api/loan/integration': loanApiIntegration, 'GET /egress/api/endpoint/page': pageQueryEgressApiEndpoint, 'GET /egress/api/endpoint/list': queryApiEndpoint, 'GET /egress/api/loan': queryApiLoan, 'DELETE /egress/api': deleteEgressApi, };