egress.ts 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. import e, { Request, Response } from 'express';
  2. /**
  3. * @author bianlanzhou
  4. * @since 2024-09-20
  5. * @desc 接出网关API-MOCK
  6. */
  7. /** 等待时间 */
  8. const waitTime = (time: number = 100) => {
  9. return new Promise((resolve) => {
  10. setTimeout(() => {
  11. resolve(true);
  12. }, time);
  13. });
  14. };
  15. /** 分页查询接出API响应数据 */
  16. const pageQueryEgressApiRespData = {
  17. "success": true,
  18. "errCode": null,
  19. "errMessage": null,
  20. "total": 1,
  21. "pageSize": 10,
  22. "pageIndex": 1,
  23. "data": [
  24. {
  25. "id": 1,
  26. "apiName": "xxxxx-助贷",
  27. "apiCode": "zd-00001",
  28. "apiType": "loan",
  29. "createUsername": "张元英",
  30. "gmtCreate": "2024-10-21T09:33:51.000+00:00",
  31. "modifyUsername": "张元英",
  32. "gmtModify": "2024-10-21T09:33:51.000+00:00",
  33. "techOwnerUsername": "张元英",
  34. "techOwnerUserid": "10000",
  35. "memo": null,
  36. "status": "ok"
  37. }
  38. ],
  39. "totalPages": 1,
  40. "notEmpty": true,
  41. "empty": false
  42. }
  43. /** 创建接出API通道响应数据 */
  44. const upsertEgressApiRespData = {
  45. "success": true,
  46. "errCode": null,
  47. "errMessage": null,
  48. "data": 1848565642249170945
  49. }
  50. /** 查询接出API响应数据 */
  51. const queryEgressApiRespData = {
  52. "success": true,
  53. "errCode": null,
  54. "errMessage": null,
  55. "data": [
  56. {
  57. "id": '1848565642249170945',
  58. "apiName": "xxxxx-xx",
  59. "apiCode": "product-xxx",
  60. "apiType": "product",
  61. "createUsername": "admin",
  62. "gmtCreate": "2024-10-22 03:22:51",
  63. "modifyUsername": "admin",
  64. "gmtModify": "2024-10-22 03:22:51",
  65. "techOwnerUsername": "admin",
  66. "memo": "xxxxxxyyyyyy",
  67. "status": "draft"
  68. }, {
  69. "id": '1848565642249170946',
  70. "apiName": "yyyyy-yy",
  71. "apiCode": "loan-xxx",
  72. "apiType": "loan",
  73. "createUsername": "admin",
  74. "gmtCreate": "2024-10-22 03:22:51",
  75. "modifyUsername": "admin",
  76. "gmtModify": "2024-10-22 03:22:51",
  77. "techOwnerUsername": "admin",
  78. "memo": "xxxxxxyyyyyy",
  79. "status": "draft"
  80. }
  81. ]
  82. }
  83. /** 助贷API对接响应数据 */
  84. const loanApiIntegrationRespData = {
  85. "success": true,
  86. "errCode": null,
  87. "errMessage": null,
  88. }
  89. /** 分页查询接出API通道响应数据 */
  90. const pageQueryEgressApiChannelRespData = {
  91. "success": true,
  92. "errCode": null,
  93. "errMessage": null,
  94. "data": [
  95. {
  96. "id": '1848565642249170945',
  97. "apiName": "xxxxx-xx",
  98. "channelName": "xxxxx-xx-撞库",
  99. "integrationMode": "customize",
  100. "apiType": "product",
  101. "createUsername": "admin",
  102. "gmtCreate": "2024-10-22T03:22:51.000+00:00",
  103. "modifyUsername": "admin",
  104. "gmtModify": "2024-10-22T03:22:51.000+00:00",
  105. }, {
  106. "id": '1848565642249170946',
  107. "apiName": "yyyyy-yy",
  108. "channelName": "xxxxx-xx-申请",
  109. "integrationMode": "guide",
  110. "apiType": "loan",
  111. "createUsername": "admin",
  112. "gmtCreate": "2024-10-22T03:22:51.000+00:00",
  113. "modifyUsername": "admin",
  114. "gmtModify": "2024-10-22T03:22:51.000+00:00",
  115. }
  116. ]
  117. }
  118. /** 查询撞库API通道响应数据 */
  119. const queryCiApiChannelRespData = {
  120. "success": true,
  121. "data": [
  122. {
  123. "id": "1853335011944685569",
  124. "apiId": "1853241164564557825",
  125. "apiType": "loan",
  126. "apiName": "测试001",
  127. "channelName": "测试001-撞库",
  128. "integrationMode": "customize",
  129. "gmtCreate": "2024-11-04 16:48:33",
  130. "gmtModify": "2024-11-04 16:48:33",
  131. "requestConfig": "{req-checkinto}",
  132. "responseConfig": "{req-checkinto}"
  133. }
  134. ]
  135. }
  136. /** 查询API通道响应数据 */
  137. const queryApiChannelRespData = {
  138. "success": true,
  139. "errCode": null,
  140. "errMessage": null,
  141. "data": [
  142. {
  143. "id": '1848565642249170945',
  144. "apiName": "xxxxx-xx",
  145. "channelName": "xxxxx-xx-撞库",
  146. "integrationMode": "guide",
  147. "apiType": "product",
  148. "createUsername": "admin",
  149. "gmtCreate": "2024-10-22T03:22:51.000+00:00",
  150. "modifyUsername": "admin",
  151. "gmtModify": "2024-10-22T03:22:51.000+00:00",
  152. "requestConfig": "{}",
  153. }
  154. ]
  155. }
  156. /** 查询申请API通道响应数据 */
  157. const queryApiApplyChannelRespData = {
  158. "success": true,
  159. "data": [
  160. {
  161. "id": "1853335012297007105",
  162. "apiId": "1853241164564557825",
  163. "apiType": "loan",
  164. "apiName": "测试001",
  165. "channelName": "测试001-注册",
  166. "integrationMode": "guide",
  167. "gmtCreate": "2024-11-04 16:48:33",
  168. "gmtModify": "2024-11-04 16:48:33",
  169. "requestConfig": "{\"url\":\"http://biying.com/apply\",\"method\":\"POST\"}",
  170. "responseConfig": "{\"integrationMode\":\"guide\",\"responseConfig\":\"{resp-apply}\",\"method\":\"GET\",\"url\":\"http://baidu.com/apply\"xxxx"
  171. }
  172. ]
  173. }
  174. /** 查询助贷API响应数据 */
  175. const queryApiLoanRespData = {
  176. "success": true,
  177. "errCode": null,
  178. "errMessage": null,
  179. "data": {
  180. "id": '1848565642249170945',
  181. "merchantId": '1848565642249170945',
  182. "checkinto": "yes",
  183. "integrationSystem": "2",
  184. "gmtCreate": "2024-10-22T03:22:51.000+00:00",
  185. "modifyUsername": "admin",
  186. "gmtModify": "2024-10-22T03:22:51.000+00:00",
  187. }
  188. }
  189. /** 删除接出API响应数据 */
  190. const deleteEgressApiRespData = {
  191. "success": true,
  192. "errCode": null,
  193. "errMessage": null,
  194. }
  195. /** 分页查询接出API */
  196. const pageQueryEgressApi = async (req: Request, res: Response) => {
  197. await waitTime(2000);
  198. res.json(pageQueryEgressApiRespData);
  199. }
  200. /** 查询接出API */
  201. const queryEgressApi = async (req: Request, res: Response) => {
  202. await waitTime(2000);
  203. res.json(queryEgressApiRespData);
  204. }
  205. /** 创建更新接出API */
  206. const upsertEgressApi = async (req: Request, res: Response) => {
  207. await waitTime(2000);
  208. res.json(upsertEgressApiRespData);
  209. }
  210. /** 助贷API对接 */
  211. const loanApiIntegration = async (req: Request, res: Response) => {
  212. await waitTime(2000);
  213. res.json(loanApiIntegrationRespData);
  214. }
  215. /** 分页查询接出API通道 */
  216. const pageQueryEgressApiChannel = async (req: Request, res: Response) => {
  217. await waitTime(2000);
  218. res.json(pageQueryEgressApiChannelRespData);
  219. }
  220. /** 查询API通道 */
  221. const queryApiChannel = async (req: Request, res: Response) => {
  222. await waitTime(2000);
  223. if (req.query.channelCode === 'checkinto') {
  224. res.json(queryCiApiChannelRespData);
  225. } else if (req.query.channelCode === 'apply') {
  226. res.json(queryApiApplyChannelRespData);
  227. } else {
  228. res.json(queryApiChannelRespData);
  229. }
  230. }
  231. /** 查询助贷API信息 */
  232. const queryApiLoan = async (req: Request, res: Response) => {
  233. await waitTime(2000);
  234. res.json(queryApiLoanRespData);
  235. }
  236. /** 删除接出API */
  237. const deleteEgressApi = async (req: Request, res: Response) => {
  238. await waitTime(2000);
  239. res.json(deleteEgressApiRespData);
  240. }
  241. export default {
  242. 'GET /egress/api/page': pageQueryEgressApi,
  243. 'GET /egress/api/list': queryEgressApi,
  244. 'PUT /egress/api/upsert': upsertEgressApi,
  245. 'PUT /egress/api/loan/integration': loanApiIntegration,
  246. 'GET /egress/api/channel/page': pageQueryEgressApiChannel,
  247. 'GET /egress/api/channel/list': queryApiChannel,
  248. 'GET /egress/api/loan': queryApiLoan,
  249. 'DELETE /egress/api': deleteEgressApi,
  250. };