resource.ts 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /**
  2. * Resource Mock Handlers
  3. * 资源配置相关的 mock 处理器
  4. */
  5. /**
  6. * 获取选项 - 性别选项(sex_full)
  7. *
  8. * @description 获取性别选项列表,包括完整的性别类型
  9. * @method GET
  10. * @url /dr/api/v1/auth/resource/options
  11. * @access 需要认证
  12. *
  13. * @param {string} group - 选项组(basic/apr_cbo)
  14. * @param {string} flag - 选项标志(sex_full/patient_size)
  15. *
  16. * @returns {Object[]} data.option - 选项列表
  17. * @returns {string} data.option[].text - 显示文本
  18. * @returns {string} data.option[].value - 选项值
  19. *
  20. * @example
  21. * mockGetOptionsSexFull();
  22. * cy.wait('@getOptionsSexFull');
  23. *
  24. * @see docs/DR.md - 章节9
  25. */
  26. export function mockGetOptionsSexFull() {
  27. cy.intercept('GET', '/dr/api/v1/auth/resource/options*', (req) => {
  28. req.reply({
  29. statusCode: 200,
  30. body: {
  31. code: "0x000000",
  32. description: "Success",
  33. solution: "",
  34. data: {
  35. "@type": "type.googleapis.com/dr.resource.OptionReply",
  36. option: [
  37. { text: "Male", value: "M" },
  38. { text: "Female", value: "F" },
  39. { text: "Other", value: "O" },
  40. { text: "CM", value: "CM" },
  41. { text: "SF", value: "SF" }
  42. ]
  43. }
  44. }
  45. });
  46. }).as('getOptionsSexFull');
  47. }
  48. /**
  49. * 获取选项 - 患者体型(patient_size)
  50. *
  51. * @description 获取患者体型选项列表
  52. * @method GET
  53. * @url /dr/api/v1/auth/resource/options
  54. * @access 需要认证
  55. *
  56. * @param {string} group - 选项组(basic)
  57. * @param {string} flag - 选项标志(patient_size)
  58. *
  59. * @returns {Object[]} data.option - 选项列表
  60. *
  61. * @example
  62. * mockGetOptionsPatientSize();
  63. * cy.wait('@getOptionsPatientSize');
  64. *
  65. * @see docs/DR.md - 章节9
  66. */
  67. export function mockGetOptionsPatientSize() {
  68. cy.intercept('GET', '/dr/api/v1/auth/resource/options*patient_size*', {
  69. statusCode: 200,
  70. body: {
  71. code: "0x000000",
  72. description: "Success",
  73. solution: "",
  74. data: {
  75. "@type": "type.googleapis.com/dr.resource.OptionReply",
  76. option: [
  77. { text: "Small", value: "Small" },
  78. { text: "Medium", value: "Medium" },
  79. { text: "Large", value: "Large" }
  80. ]
  81. }
  82. }
  83. }).as('getOptionsPatientSize');
  84. }
  85. /**
  86. * 获取配置项 - 发生器仿真模式
  87. *
  88. * @description 获取发生器仿真模式配置
  89. * @method GET
  90. * @url /dr/api/v1/auth/resource/config
  91. * @access 需要认证
  92. *
  93. * @param {string} uri - 配置URI(System/SimulatorGEN)
  94. *
  95. * @returns {Object} data - 配置数据
  96. *
  97. * @example
  98. * mockGetConfigSimulatorGEN();
  99. * cy.wait('@getConfigSimulatorGEN');
  100. *
  101. * @see docs/DR.md - 章节11
  102. */
  103. export function mockGetConfigSimulatorGEN() {
  104. cy.intercept('GET', '/dr/api/v1/auth/resource/config*SimulatorGEN*', {
  105. statusCode: 200,
  106. body: {
  107. code: "0x000000",
  108. description: "Success",
  109. solution: "",
  110. data: {
  111. "@type": "type.googleapis.com/dr.resource.OptionReply",
  112. option: [
  113. { text: "Enabled", value: "true" },
  114. { text: "Disabled", value: "false" }
  115. ]
  116. }
  117. }
  118. }).as('getConfigSimulatorGEN');
  119. }
  120. /**
  121. * 获取配置项 - 探测器仿真模式
  122. *
  123. * @description 获取探测器仿真模式配置
  124. * @method GET
  125. * @url /dr/api/v1/auth/resource/config
  126. * @access 需要认证
  127. *
  128. * @param {string} uri - 配置URI(System/SimulatorFPD)
  129. *
  130. * @returns {Object} data - 配置数据
  131. *
  132. * @example
  133. * mockGetConfigSimulatorFPD();
  134. * cy.wait('@getConfigSimulatorFPD');
  135. *
  136. * @see docs/DR.md - 章节11
  137. */
  138. export function mockGetConfigSimulatorFPD() {
  139. cy.intercept('GET', '/dr/api/v1/auth/resource/config*SimulatorFPD*', {
  140. statusCode: 200,
  141. body: {
  142. code: "0x000000",
  143. description: "Success",
  144. solution: "",
  145. data: {
  146. "@type": "type.googleapis.com/dr.resource.OptionReply",
  147. option: [
  148. { text: "Enabled", value: "true" },
  149. { text: "Disabled", value: "false" }
  150. ]
  151. }
  152. }
  153. }).as('getConfigSimulatorFPD');
  154. }
  155. /**
  156. * 获取示意图 - 成功场景
  157. *
  158. * @description 获取体位示意图图片
  159. * @method GET
  160. * @url /dr/api/v1/pub/Image/{path}
  161. * @access 公开接口
  162. *
  163. * @returns {File} 图片文件
  164. *
  165. * @example
  166. * mockGetImageSuccess();
  167. * cy.wait('@getImageSuccess');
  168. *
  169. * @see docs/DR.md - 章节6
  170. */
  171. export function mockGetImageSuccess() {
  172. cy.intercept('GET', '/dr/api/v1/pub/Image/**', {
  173. statusCode: 200,
  174. headers: {
  175. 'content-type': 'image/gif'
  176. },
  177. body: '' // 空图片数据
  178. }).as('getImageSuccess');
  179. }
  180. /**
  181. * 获取示意图 - 404未找到
  182. *
  183. * @description 获取示意图失败,文件不存在
  184. * @method GET
  185. * @url /dr/api/v1/pub/Image/{path}
  186. * @access 公开接口
  187. *
  188. * @returns {Object} 404错误响应
  189. *
  190. * @example
  191. * mockGetImageNotFound();
  192. * cy.wait('@getImageNotFound');
  193. *
  194. * @see docs/DR.md - 章节6
  195. */
  196. export function mockGetImageNotFound() {
  197. cy.intercept('GET', '/dr/api/v1/pub/Image/**', {
  198. statusCode: 404,
  199. body: {
  200. code: "0x000001",
  201. description: "Image not found",
  202. solution: "Please check the image path"
  203. }
  204. }).as('getImageNotFound');
  205. }