handlers.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import { http } from 'msw';
  2. export const handlers = [
  3. // Handler 1: 获取患者类型
  4. http.get('/dr/api/v1/auth/protocol/patient_type', async () => {
  5. // 忽略eslint
  6. // eslint-disable-next-line
  7. return new Response(
  8. JSON.stringify({
  9. code: '0x000000',
  10. description: 'Success',
  11. solution: '',
  12. data: {
  13. patient_type_list: [
  14. {
  15. id: '1',
  16. patient_type_id: 'Human',
  17. patient_type_name: 'Human',
  18. patient_type_local: 'Human',
  19. patient_type_description: 'Human',
  20. sort: 1,
  21. is_enabled: true,
  22. product: 'DROC',
  23. is_pre_install: true,
  24. },
  25. {
  26. id: '2',
  27. patient_type_id: 'SpecialType',
  28. patient_type_name: 'SpecialType',
  29. patient_type_local: 'SpecialType',
  30. patient_type_description: 'SpecialType',
  31. sort: 2,
  32. is_enabled: false,
  33. product: 'DROC',
  34. is_pre_install: true,
  35. },
  36. ],
  37. },
  38. }),
  39. {
  40. status: 200,
  41. headers: { 'Content-Type': 'application/json' },
  42. // Simulate 500ms delay
  43. delay: 500,
  44. }
  45. );
  46. }),
  47. // Handler 2: 获取body part
  48. http.get('/dr/api/v1/auth/protocol/body_part', async () => {
  49. // eslint-disable-next-line
  50. return new Response(
  51. JSON.stringify({
  52. code: '0x000000',
  53. description: 'Success',
  54. solution: '',
  55. data: {
  56. body_part_list: [
  57. {
  58. id: '1',
  59. body_part_id: 'Human_SKULL',
  60. body_part_name: '颅骨',
  61. body_part_local: '颅骨',
  62. body_part_description: 'Skull',
  63. patient_type: 'Human',
  64. category: 'DX',
  65. sort: 1,
  66. is_enabled: true,
  67. product: 'DROC',
  68. is_pre_install: true,
  69. },
  70. {
  71. id: '2',
  72. body_part_id: 'Human_NECK',
  73. body_part_name: '颈部',
  74. body_part_local: '颈部',
  75. body_part_description: 'Neck',
  76. patient_type: 'Human',
  77. category: 'DX',
  78. sort: 2,
  79. is_enabled: true,
  80. product: 'DROC',
  81. is_pre_install: true,
  82. },
  83. ],
  84. },
  85. }),
  86. {
  87. status: 200,
  88. headers: { 'Content-Type': 'application/json' },
  89. }
  90. );
  91. }),
  92. ];