123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 |
- 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 pageQueryEgressApiChannelRespData = {
- "success": true,
- "errCode": null,
- "errMessage": null,
- "data": [
- {
- "id": '1848565642249170945',
- "apiName": "xxxxx-xx",
- "channelName": "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",
- "channelName": "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 queryCiApiChannelRespData = {
- "success": true,
- "data": [
- {
- "id": "1853335011944685569",
- "apiId": "1853241164564557825",
- "apiType": "loan",
- "apiName": "测试001",
- "channelName": "测试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 queryApiChannelRespData = {
- "success": true,
- "errCode": null,
- "errMessage": null,
- "data": [
- {
- "id": '1848565642249170945',
- "apiName": "xxxxx-xx",
- "channelName": "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 queryApiApplyChannelRespData = {
- "success": true,
- "data": [
- {
- "id": "1853335012297007105",
- "apiId": "1853241164564557825",
- "apiType": "loan",
- "apiName": "测试001",
- "channelName": "测试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 pageQueryEgressApiChannel = async (req: Request, res: Response) => {
- await waitTime(2000);
- res.json(pageQueryEgressApiChannelRespData);
- }
- /** 查询API通道 */
- const queryApiChannel = async (req: Request, res: Response) => {
- await waitTime(2000);
- if (req.query.channelCode === 'checkinto') {
- res.json(queryCiApiChannelRespData);
- } else if (req.query.channelCode === 'apply') {
- res.json(queryApiApplyChannelRespData);
- } else {
- res.json(queryApiChannelRespData);
- }
- }
- /** 查询助贷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/channel/page': pageQueryEgressApiChannel,
- 'GET /egress/api/channel/list': queryApiChannel,
- 'GET /egress/api/loan': queryApiLoan,
- 'DELETE /egress/api': deleteEgressApi,
- };
|