import { defHttp } from '@jeesite/core/utils/http/axios'; import { useGlobSetting } from '@jeesite/core/hooks/setting'; import type { Result } from '@jeesite/types/axios'; const { adminPath } = useGlobSetting(); /** * 案件实体信息 */ export interface CaseInfo { /** * 案件 ID */ id?: number; /** * 案件名称 */ name: string; /** * 案件类型 */ type: string; /** * 案件备注 */ remark?: string; /** * 创建时间 */ createTime?: string; /** * 是否已经初始化 (1 是 0 否) */ init?: number; } /** * 创建案件请求 DTO */ export interface CreateCaseDTO { /** * 案件名称 */ name: string; /** * 案件密码 */ pwd: string; /** * 案件类型 */ type: string; /** * 案件备注 */ remark?: string; } /** * 更新案件请求 DTO(与创建使用同一个接口) */ export interface UpdateCaseDTO { /** * 案件 ID(更新时必填) */ id: number; /** * 案件名称 */ name: string; /** * 案件密码 */ pwd: string; /** * 案件类型 */ type: string; /** * 案件备注 */ remark?: string; } /** * 更新案件密码 DTO */ export interface UpdateCasePwdDTO { /** * 案件 ID */ id: number; /** * 新密码 */ newPwd: string; /** * 旧密码 */ oldPwd: string; } /** * 开启案件 DTO */ export interface OpenCaseDTO { /** * 案件 ID */ id: number; /** * 案件密码 */ pwd: string; } /** * 删除案件参数 */ export interface DeleteCaseParams { /** * 案件 ID */ id: number; /** * 案件密码 */ pwd: string; } /** * 分页查询案件列表 * @returns 案件列表 */ export const list = () => defHttp.get({ url: adminPath + '/case/list' }); /** * 创建新案件 * @param data 创建案件数据 * @returns 创建成功的案件信息 */ export const create = (data: CreateCaseDTO) => defHttp.postJson( { url: adminPath + '/case/create', data }, { isReturnNativeResponse: false, skipSuccessMessage: true }, ); /** * 更新案件(创建或更新使用同一接口,有id则更新) * @param data 更新案件数据 * @returns 更新成功的案件信息 */ export const update = (data: UpdateCaseDTO) => defHttp.postJson({ url: adminPath + '/case/create', data }, { isReturnNativeResponse: false }); /** * 删除案件 * @param id 案件 ID * @param pwd 案件密码 */ export const deleteById = (id: number, pwd: string) => defHttp.delete({ url: adminPath + '/case/delete', params: { id, pwd } }); /** * 更新案件密码 * @param data 更新密码数据 */ export const updatePwd = (data: UpdateCasePwdDTO) => defHttp.postJson({ url: adminPath + '/case/updatePwd', data }); /** * 开启案件 * @param data 开启案件数据(id + 密码) * @returns 案件信息 */ export const openCase = (data: OpenCaseDTO) => defHttp.postJson({ url: adminPath + '/case/open', data }); /** * 退出当前案件 */ export const exitCase = () => defHttp.get({ url: adminPath + '/case/exit' });