OkkiBlog.api.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import {defHttp} from '/@/utils/http/axios';
  2. import { useMessage } from "/@/hooks/web/useMessage";
  3. const { createConfirm } = useMessage();
  4. enum Api {
  5. list = '/blog/okkiBlog/list',
  6. save='/blog/okkiBlog/add',
  7. edit='/blog/okkiBlog/edit',
  8. deleteOne = '/blog/okkiBlog/delete',
  9. deleteBatch = '/blog/okkiBlog/deleteBatch',
  10. importExcel = '/blog/okkiBlog/importExcel',
  11. exportXls = '/blog/okkiBlog/exportXls',
  12. }
  13. /**
  14. * 导出api
  15. * @param params
  16. */
  17. export const getExportUrl = Api.exportXls;
  18. /**
  19. * 导入api
  20. */
  21. export const getImportUrl = Api.importExcel;
  22. /**
  23. * 列表接口
  24. * @param params
  25. */
  26. export const list = (params) =>
  27. defHttp.get({url: Api.list, params});
  28. /**
  29. * 删除单个
  30. */
  31. export const deleteOne = (params,handleSuccess) => {
  32. return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => {
  33. handleSuccess();
  34. });
  35. }
  36. /**
  37. * 批量删除
  38. * @param params
  39. */
  40. export const batchDelete = (params, handleSuccess) => {
  41. createConfirm({
  42. iconType: 'warning',
  43. title: '确认删除',
  44. content: '是否删除选中数据',
  45. okText: '确认',
  46. cancelText: '取消',
  47. onOk: () => {
  48. return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
  49. handleSuccess();
  50. });
  51. }
  52. });
  53. }
  54. /**
  55. * 保存或者更新
  56. * @param params
  57. */
  58. export const saveOrUpdate = (params, isUpdate) => {
  59. let url = isUpdate ? Api.edit : Api.save;
  60. return defHttp.post({url: url, params});
  61. }