index.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { goCommonSearchUrl, request } from '@/services/request/index';
  2. import { Method } from 'axios';
  3. /**
  4. * go 接口通用查询
  5. * @param url 接口路径
  6. * @param params 请求参数
  7. * @param method 请求方式
  8. * @returns
  9. */
  10. export function commonSearch_go(url: string, params: Object, method: Method = 'get'): Promise<any> {
  11. return request({
  12. method,
  13. url: goCommonSearchUrl(url),
  14. params,
  15. })
  16. .then((value) => value.data.data)
  17. .catch((err) => Promise.reject(err));
  18. }
  19. export interface BaseResponse {
  20. result: boolean;
  21. message: String;
  22. }
  23. /**
  24. * go 申请/修改类型返回 (不关心具体返回的数据, 只关心请求是否成功)
  25. * @param url 接口路径
  26. * @param params 请求参数
  27. * @param method 请求方式
  28. */
  29. export function commonUpdate_go(url: string, data: Object, method: Method = 'post'): Promise<BaseResponse> {
  30. return request({
  31. method,
  32. url: goCommonSearchUrl(url),
  33. data,
  34. })
  35. .then((value) => {
  36. return {
  37. result: value.data.code === 200 ? true : false,
  38. message: value.data.msg,
  39. };
  40. })
  41. .catch((err) => Promise.reject(err));
  42. }