care.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /**
  2. * 调理方案模块 API
  3. */
  4. import http from '@/utils/http'
  5. /**
  6. * 获取调理方案列表(分页)
  7. * @param {Object} params - { modeType, page, size }
  8. * @param {string} params.modeType - 模式标识: PROFESSIONAL / CUSTOM / EXPERT
  9. * @param {number} [params.page=0] - 页码
  10. * @param {number} [params.size=100] - 每页数量
  11. * @returns {Promise<{records, total}>}
  12. */
  13. export function getCareList(params = {}) {
  14. return http.post('/userCare/careList', {
  15. page: params.page || 0,
  16. size: params.size || 100,
  17. modeType: params.modeType || ''
  18. })
  19. }
  20. /**
  21. * 获取当前用户的自定义方案列表
  22. * 通过 Token 获取当前 APP 账号下创作人属于自己的自定义模式方案
  23. * @returns {Promise<Array<{id, planCode, name, modeType, symptoms, applicableGender, ageMin, ageMax, description, authorId, authorName, authorType, useCount, avgRating, lastUseTime, status, createTime, updateTime}>>}
  24. */
  25. export function getCustomPlanList() {
  26. return http.get('/app/custom-plan/list')
  27. }
  28. /**
  29. * 获取用户自定义方案详情
  30. * @param {string|number} id - 方案ID
  31. * @returns {Promise<Object>} 方案详情含steps
  32. */
  33. export function getCustomPlanDetail(id) {
  34. return http.get(`/app/custom-plan/${id}`)
  35. }
  36. /**
  37. * 获取调理方案详情
  38. * @param {string|number} id - 方案ID
  39. * @returns {Promise<{steps: Array}>}
  40. */
  41. export function getCareDetail(id) {
  42. return http.get('/userCare/careDetail', { data: { id } })
  43. }
  44. /**
  45. * 新增用户自定义方案
  46. * @param {Object} data - 方案数据 { name, symptoms, applicableGender, ageMin, ageMax, description, status, steps }
  47. * @returns {Promise<number>} 新方案ID
  48. */
  49. export function createCustomPlan(data) {
  50. return http.post('/app/custom-plan', data)
  51. }
  52. /**
  53. * 修改用户自定义方案
  54. * @param {Object} data - 方案数据 { id, name, symptoms, applicableGender, ageMin, ageMax, description, status, steps }
  55. * @returns {Promise}
  56. */
  57. export function updateCustomPlan(data) {
  58. return http.put('/app/custom-plan', data)
  59. }
  60. /**
  61. * 删除用户自定义方案
  62. * @param {string|number} id - 方案ID
  63. * @returns {Promise}
  64. */
  65. export function deleteCustomPlan(id) {
  66. return http.delete(`/app/custom-plan/${id}`)
  67. }