request.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { Get, Post } from "../../lib/request/method";
  2. export function getDietListMethod(page: number, size: number, query?: { keyword?: string, classify: 'tonic' | 'tea' }) {
  3. return Post(`/dietRecipe/pageDietRecipe`, { page, limit: size, classify: query?.classify, keyWord: query?.keyword }, {
  4. transform({ data }: AnyObject) {
  5. return {
  6. total: data.total, page: data?.current ?? page, size: data?.size ?? size,
  7. data: data.records
  8. };
  9. }
  10. })
  11. }
  12. export function getDietMethod(id: string) {
  13. return Post(`/dietRecipe/dietRecipeDetail`, { id }, {
  14. transform({ data }: AnyObject) {
  15. return data;
  16. }
  17. })
  18. }
  19. export function getScienceListMethod(page: number, size: number, query?: { keyword?: string }) {
  20. return Post(`/psarticle/pagePsarticle?pageNum=${page}&pageSize=${size}&keyword=${query?.keyword}`, void 0, {
  21. transform({ data }: AnyObject) {
  22. return {
  23. total: data.total, page: data?.current ?? page, size: data?.size ?? size,
  24. data: data.data.map((item: AnyObject) => (item.id = item.popularScienceArticleId, item))
  25. };
  26. }
  27. })
  28. }
  29. export function getScienceMethod(id: string) {
  30. return Get(`/psarticle/getPsarticleDetailById`, {
  31. params: { popularScienceArticleId: id },
  32. transform({ data }: AnyObject) {
  33. const { popularScienceArticleId: id, ..._data } = data;
  34. return { id, ..._data };
  35. }
  36. })
  37. }