/** * Resource Mock Handlers * 资源配置相关的 mock 处理器 */ /** * 获取选项 - 性别选项(sex_full) * * @description 获取性别选项列表,包括完整的性别类型 * @method GET * @url /dr/api/v1/auth/resource/options * @access 需要认证 * * @param {string} group - 选项组(basic/apr_cbo) * @param {string} flag - 选项标志(sex_full/patient_size) * * @returns {Object[]} data.option - 选项列表 * @returns {string} data.option[].text - 显示文本 * @returns {string} data.option[].value - 选项值 * * @example * mockGetOptionsSexFull(); * cy.wait('@getOptionsSexFull'); * * @see docs/DR.md - 章节9 */ export function mockGetOptionsSexFull() { cy.intercept('GET', '/dr/api/v1/auth/resource/options*', (req) => { req.reply({ statusCode: 200, body: { code: "0x000000", description: "Success", solution: "", data: { "@type": "type.googleapis.com/dr.resource.OptionReply", option: [ { text: "Male", value: "M" }, { text: "Female", value: "F" }, { text: "Other", value: "O" }, { text: "CM", value: "CM" }, { text: "SF", value: "SF" } ] } } }); }).as('getOptionsSexFull'); } /** * 获取选项 - 患者体型(patient_size) * * @description 获取患者体型选项列表 * @method GET * @url /dr/api/v1/auth/resource/options * @access 需要认证 * * @param {string} group - 选项组(basic) * @param {string} flag - 选项标志(patient_size) * * @returns {Object[]} data.option - 选项列表 * * @example * mockGetOptionsPatientSize(); * cy.wait('@getOptionsPatientSize'); * * @see docs/DR.md - 章节9 */ export function mockGetOptionsPatientSize() { cy.intercept('GET', '/dr/api/v1/auth/resource/options*patient_size*', { statusCode: 200, body: { code: "0x000000", description: "Success", solution: "", data: { "@type": "type.googleapis.com/dr.resource.OptionReply", option: [ { text: "Small", value: "Small" }, { text: "Medium", value: "Medium" }, { text: "Large", value: "Large" } ] } } }).as('getOptionsPatientSize'); } /** * 获取配置项 - 发生器仿真模式 * * @description 获取发生器仿真模式配置 * @method GET * @url /dr/api/v1/auth/resource/config * @access 需要认证 * * @param {string} uri - 配置URI(System/SimulatorGEN) * * @returns {Object} data - 配置数据 * * @example * mockGetConfigSimulatorGEN(); * cy.wait('@getConfigSimulatorGEN'); * * @see docs/DR.md - 章节11 */ export function mockGetConfigSimulatorGEN() { cy.intercept('GET', '/dr/api/v1/auth/resource/config*SimulatorGEN*', { statusCode: 200, body: { code: "0x000000", description: "Success", solution: "", data: { "@type": "type.googleapis.com/dr.resource.OptionReply", option: [ { text: "Enabled", value: "true" }, { text: "Disabled", value: "false" } ] } } }).as('getConfigSimulatorGEN'); } /** * 获取配置项 - 探测器仿真模式 * * @description 获取探测器仿真模式配置 * @method GET * @url /dr/api/v1/auth/resource/config * @access 需要认证 * * @param {string} uri - 配置URI(System/SimulatorFPD) * * @returns {Object} data - 配置数据 * * @example * mockGetConfigSimulatorFPD(); * cy.wait('@getConfigSimulatorFPD'); * * @see docs/DR.md - 章节11 */ export function mockGetConfigSimulatorFPD() { cy.intercept('GET', '/dr/api/v1/auth/resource/config*SimulatorFPD*', { statusCode: 200, body: { code: "0x000000", description: "Success", solution: "", data: { "@type": "type.googleapis.com/dr.resource.OptionReply", option: [ { text: "Enabled", value: "true" }, { text: "Disabled", value: "false" } ] } } }).as('getConfigSimulatorFPD'); } /** * 获取示意图 - 成功场景 * * @description 获取体位示意图图片 * @method GET * @url /dr/api/v1/pub/Image/{path} * @access 公开接口 * * @returns {File} 图片文件 * * @example * mockGetImageSuccess(); * cy.wait('@getImageSuccess'); * * @see docs/DR.md - 章节6 */ export function mockGetImageSuccess() { cy.intercept('GET', '/dr/api/v1/pub/Image/**', { statusCode: 200, headers: { 'content-type': 'image/gif' }, body: '' // 空图片数据 }).as('getImageSuccess'); } /** * 获取示意图 - 404未找到 * * @description 获取示意图失败,文件不存在 * @method GET * @url /dr/api/v1/pub/Image/{path} * @access 公开接口 * * @returns {Object} 404错误响应 * * @example * mockGetImageNotFound(); * cy.wait('@getImageNotFound'); * * @see docs/DR.md - 章节6 */ export function mockGetImageNotFound() { cy.intercept('GET', '/dr/api/v1/pub/Image/**', { statusCode: 404, body: { code: "0x000001", description: "Image not found", solution: "Please check the image path" } }).as('getImageNotFound'); }