OpenApi.api.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import {defHttp} from '/@/utils/http/axios';
  2. import { useMessage } from "/@/hooks/web/useMessage";
  3. const { createConfirm } = useMessage();
  4. enum Api {
  5. list = '/openapi/list',
  6. save='/openapi/add',
  7. edit='/openapi/edit',
  8. deleteOne = '/openapi/delete',
  9. deleteBatch = '/openapi/deleteBatch',
  10. genPath = '/openapi/genPath',
  11. importExcel = '/openapi/importExcel',
  12. exportXls = '/openapi/exportXls',
  13. openApiHeaderList = '/openapi/list',
  14. openApiParamList = '/openapi/list',
  15. openApiJson = '/openapi/json',
  16. }
  17. /**
  18. * 子表单查询接口
  19. * @param params
  20. */
  21. export const genPath = Api.genPath
  22. /**
  23. * swagger文档json
  24. * @param params
  25. */
  26. export const openApiJson = Api.openApiJson
  27. /**
  28. * 导出api
  29. * @param params
  30. */
  31. export const getExportUrl = Api.exportXls;
  32. /**
  33. * 导入api
  34. */
  35. export const getImportUrl = Api.importExcel;
  36. /**
  37. * 子表单查询接口
  38. * @param params
  39. */
  40. export const queryOpenApiHeader = Api.openApiHeaderList
  41. /**
  42. * 子表单查询接口
  43. * @param params
  44. */
  45. export const queryOpenApiParam = Api.openApiParamList
  46. /**
  47. * 列表接口
  48. * @param params
  49. */
  50. export const list = (params) =>
  51. defHttp.get({url: Api.list, params});
  52. /**
  53. * 删除单个
  54. */
  55. export const deleteOne = (params,handleSuccess) => {
  56. return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => {
  57. handleSuccess();
  58. });
  59. }
  60. /**
  61. * 批量删除
  62. * @param params
  63. */
  64. export const batchDelete = (params, handleSuccess) => {
  65. createConfirm({
  66. iconType: 'warning',
  67. title: '确认删除',
  68. content: '是否删除选中数据',
  69. okText: '确认',
  70. cancelText: '取消',
  71. onOk: () => {
  72. return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
  73. handleSuccess();
  74. });
  75. }
  76. });
  77. }
  78. /**
  79. * 保存或者更新
  80. * @param params
  81. */
  82. export const saveOrUpdate = (params, isUpdate) => {
  83. if (isUpdate) {
  84. return defHttp.put({url: Api.edit, params});
  85. } else {
  86. return defHttp.post({url: Api.save, params});
  87. }
  88. }
  89. /**
  90. * 获取接口地址
  91. * @param params
  92. */
  93. export const getGenPath = (params) =>
  94. defHttp.get({url: Api.genPath, params},{isTransformResponse:false});
  95. /**
  96. * 子表列表接口
  97. * @param params
  98. */
  99. export const openApiHeaderList = (params) =>
  100. defHttp.get({url: Api.openApiHeaderList, params},{isTransformResponse:false});
  101. /**
  102. * 子表列表接口
  103. * @param params
  104. */
  105. export const openApiParamList = (params) =>
  106. defHttp.get({url: Api.openApiParamList, params},{isTransformResponse:false});
  107. /**
  108. * swagger文档json
  109. * @param params
  110. */
  111. export const getOpenApiJson = (params) =>
  112. defHttp.get({url: Api.openApiJson, params},{isTransformResponse:false});