image.ts 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. /**
  2. * Image Mock Handlers
  3. * 图像相关的 mock 处理器
  4. */
  5. /**
  6. * 批量添加体位和协议 - 成功场景
  7. *
  8. * @description 批量添加体位和协议到检查中
  9. * @method POST
  10. * @url /dr/api/v1/auth/image
  11. * @access 需要认证
  12. *
  13. * @param {Object} requestBody - 请求体
  14. * @param {string} requestBody.study_id - 检查ID
  15. * @param {Object[]} requestBody.views - 体位列表
  16. *
  17. * @returns {Object} data - 创建的序列和图像信息
  18. * @returns {Object[]} data.series - 序列列表
  19. *
  20. * @example
  21. * mockAppendImagesSuccess();
  22. * cy.wait('@appendImagesSuccess');
  23. *
  24. * @see docs/DR.md - 章节20
  25. */
  26. export function mockAppendImagesSuccess() {
  27. cy.intercept('POST', '/dr/api/v1/auth/image', {
  28. statusCode: 200,
  29. body: {
  30. code: "0x000000",
  31. description: "Success",
  32. solution: "",
  33. data: {
  34. "@type": "type.googleapis.com/dr.study.CreateImageReply",
  35. series: []
  36. }
  37. }
  38. }).as('appendImagesSuccess');
  39. }
  40. /**
  41. * 复制体位 - 成功场景
  42. *
  43. * @description 复制选中的体位
  44. * @method POST
  45. * @url /dr/api/v1/auth/image/copy
  46. * @access 需要认证
  47. *
  48. * @param {Object} requestBody - 请求体
  49. * @param {string} requestBody.instance_uid - 图像实例UID
  50. *
  51. * @returns {Object} data - 复制后的序列信息
  52. *
  53. * @example
  54. * mockCopyImageSuccess();
  55. * cy.wait('@copyImageSuccess');
  56. *
  57. * @see docs/DR.md - 章节21
  58. */
  59. export function mockCopyImageSuccess() {
  60. cy.intercept('POST', '/dr/api/v1/auth/image/copy', {
  61. statusCode: 200,
  62. body: {
  63. code: "0x000000",
  64. description: "Success",
  65. solution: "",
  66. data: {
  67. "@type": "type.googleapis.com/dr.study.CreateImageReply",
  68. series: []
  69. }
  70. }
  71. }).as('copyImageSuccess');
  72. }
  73. /**
  74. * 体位重新排序 - 成功场景
  75. *
  76. * @description 重新排序体位顺序
  77. * @method POST
  78. * @url /dr/api/v1/auth/image/sort
  79. * @access 需要认证
  80. *
  81. * @param {Object} requestBody - 请求体
  82. * @param {string} requestBody.study_id - 检查ID
  83. * @param {string[]} requestBody.sop_instance_uids - 排序后的实例UID列表
  84. *
  85. * @returns {Object} 成功响应
  86. *
  87. * @example
  88. * mockSortImagesSuccess();
  89. * cy.wait('@sortImagesSuccess');
  90. *
  91. * @see docs/DR.md - 章节22
  92. */
  93. export function mockSortImagesSuccess() {
  94. cy.intercept('POST', '/dr/api/v1/auth/image/sort', {
  95. statusCode: 200,
  96. body: {
  97. code: "0x000000",
  98. description: "Success",
  99. solution: "",
  100. data: {
  101. "@type": "type.googleapis.com/google.protobuf.Empty",
  102. value: {}
  103. }
  104. }
  105. }).as('sortImagesSuccess');
  106. }
  107. /**
  108. * 删除体位 - 成功场景
  109. *
  110. * @description 删除study中的体位
  111. * @method DELETE
  112. * @url /dr/api/v1/auth/image/{id}
  113. * @access 需要认证
  114. *
  115. * @param {string} id - 图像实例UID(路径参数)
  116. *
  117. * @returns {Object} 成功响应
  118. *
  119. * @example
  120. * mockDeleteImageSuccess();
  121. * cy.wait('@deleteImageSuccess');
  122. *
  123. * @see docs/DR.md - 章节23
  124. */
  125. export function mockDeleteImageSuccess() {
  126. cy.intercept('DELETE', '/dr/api/v1/auth/image/*', {
  127. statusCode: 200,
  128. body: {
  129. code: "0x000000",
  130. description: "Success",
  131. solution: "",
  132. data: {
  133. "@type": "type.googleapis.com/google.protobuf.Empty",
  134. value: {}
  135. }
  136. }
  137. }).as('deleteImageSuccess');
  138. }
  139. /**
  140. * 存储后处理DCM - 成功场景
  141. *
  142. * @description 存储后处理的DICOM图像
  143. * @method POST
  144. * @url /api/v1/auth/image/post_proc
  145. * @access 需要认证
  146. *
  147. * @param {Object} formData - 表单数据
  148. * @param {string} formData.instance_uid - 实例UID
  149. * @param {File} formData.data - 图像文件
  150. * @param {number} formData.window_center - 窗位
  151. * @param {number} formData.window_width - 窗宽
  152. *
  153. * @returns {Object} data - DCM文件路径
  154. *
  155. * @example
  156. * mockStorePostProcSuccess();
  157. * cy.wait('@storePostProcSuccess');
  158. *
  159. * @see docs/DR.md - 章节24
  160. */
  161. export function mockStorePostProcSuccess() {
  162. cy.intercept('POST', '/api/v1/auth/image/post_proc', {
  163. statusCode: 200,
  164. body: {
  165. code: "0x000000",
  166. description: "Success",
  167. solution: "",
  168. data: {
  169. "@type": "type.googleapis.com/dr.task.DcmPath",
  170. path: "1.2.276.0.1000000.5.1.5.701601461.33458.1750830395.482043.dcm"
  171. }
  172. }
  173. }).as('storePostProcSuccess');
  174. }
  175. /**
  176. * 获取DCM文件 - 成功场景
  177. *
  178. * @description 获取DICOM文件
  179. * @method GET
  180. * @url /api/v1/auth/image/dcm/{dcmfilename}
  181. * @access 需要认证
  182. *
  183. * @param {string} dcmfilename - DCM文件名(路径参数)
  184. *
  185. * @returns {File} DICOM文件
  186. *
  187. * @example
  188. * mockGetDcmFileSuccess();
  189. * cy.wait('@getDcmFileSuccess');
  190. *
  191. * @see docs/DR.md - 章节36
  192. */
  193. export function mockGetDcmFileSuccess() {
  194. cy.intercept('GET', '/api/v1/auth/image/dcm/*', {
  195. statusCode: 200,
  196. headers: {
  197. 'content-type': 'application/dicom'
  198. },
  199. body: '' // 空DCM数据
  200. }).as('getDcmFileSuccess');
  201. }
  202. /**
  203. * 获取缩略图文件 - 成功场景
  204. *
  205. * @description 获取图像缩略图
  206. * @method GET
  207. * @url /api/v1/auth/image/thumbnail/{filename}
  208. * @access 需要认证
  209. *
  210. * @param {string} filename - 缩略图文件名(路径参数)
  211. *
  212. * @returns {File} 缩略图文件
  213. *
  214. * @example
  215. * mockGetThumbnailSuccess();
  216. * cy.wait('@getThumbnailSuccess');
  217. *
  218. * @see docs/DR.md - 章节37
  219. */
  220. export function mockGetThumbnailSuccess() {
  221. cy.intercept('GET', '/api/v1/auth/image/thumbnail/*', {
  222. statusCode: 200,
  223. headers: {
  224. 'content-type': 'image/webp'
  225. },
  226. body: '' // 空图像数据
  227. }).as('getThumbnailSuccess');
  228. }