caseApi.ts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. import { defHttp } from '@jeesite/core/utils/http/axios';
  2. import { useGlobSetting } from '@jeesite/core/hooks/setting';
  3. import type { Result } from '@jeesite/types/axios';
  4. const { adminPath } = useGlobSetting();
  5. /**
  6. * 案件实体信息
  7. */
  8. export interface CaseInfo {
  9. /**
  10. * 案件 ID
  11. */
  12. id?: number;
  13. /**
  14. * 案件名称
  15. */
  16. name: string;
  17. /**
  18. * 案件类型
  19. */
  20. type: string;
  21. /**
  22. * 案件备注
  23. */
  24. remark?: string;
  25. /**
  26. * 创建时间
  27. */
  28. createTime?: string;
  29. /**
  30. * 是否已经初始化 (1 是 0 否)
  31. */
  32. init?: number;
  33. }
  34. /**
  35. * 创建案件请求 DTO
  36. */
  37. export interface CreateCaseDTO {
  38. /**
  39. * 案件名称
  40. */
  41. name: string;
  42. /**
  43. * 案件密码
  44. */
  45. pwd: string;
  46. /**
  47. * 案件类型
  48. */
  49. type: string;
  50. /**
  51. * 案件备注
  52. */
  53. remark?: string;
  54. }
  55. /**
  56. * 更新案件请求 DTO(与创建使用同一个接口)
  57. */
  58. export interface UpdateCaseDTO {
  59. /**
  60. * 案件 ID(更新时必填)
  61. */
  62. id: number;
  63. /**
  64. * 案件名称
  65. */
  66. name: string;
  67. /**
  68. * 案件密码
  69. */
  70. pwd: string;
  71. /**
  72. * 案件类型
  73. */
  74. type: string;
  75. /**
  76. * 案件备注
  77. */
  78. remark?: string;
  79. }
  80. /**
  81. * 更新案件密码 DTO
  82. */
  83. export interface UpdateCasePwdDTO {
  84. /**
  85. * 案件 ID
  86. */
  87. id: number;
  88. /**
  89. * 新密码
  90. */
  91. newPwd: string;
  92. /**
  93. * 旧密码
  94. */
  95. oldPwd: string;
  96. }
  97. /**
  98. * 开启案件 DTO
  99. */
  100. export interface OpenCaseDTO {
  101. /**
  102. * 案件 ID
  103. */
  104. id: number;
  105. /**
  106. * 案件密码
  107. */
  108. pwd: string;
  109. }
  110. /**
  111. * 删除案件参数
  112. */
  113. export interface DeleteCaseParams {
  114. /**
  115. * 案件 ID
  116. */
  117. id: number;
  118. /**
  119. * 案件密码
  120. */
  121. pwd: string;
  122. }
  123. /**
  124. * 分页查询案件列表
  125. * @returns 案件列表
  126. */
  127. export const list = () => defHttp.get<CaseInfo[]>({ url: adminPath + '/case/list' });
  128. /**
  129. * 创建新案件
  130. * @param data 创建案件数据
  131. * @returns 创建成功的案件信息
  132. */
  133. export const create = (data: CreateCaseDTO) =>
  134. defHttp.postJson<Result>(
  135. { url: adminPath + '/case/create', data },
  136. { isReturnNativeResponse: false, skipSuccessMessage: true },
  137. );
  138. /**
  139. * 更新案件(创建或更新使用同一接口,有id则更新)
  140. * @param data 更新案件数据
  141. * @returns 更新成功的案件信息
  142. */
  143. export const update = (data: UpdateCaseDTO) =>
  144. defHttp.postJson<Result>({ url: adminPath + '/case/create', data }, { isReturnNativeResponse: false });
  145. /**
  146. * 删除案件
  147. * @param id 案件 ID
  148. * @param pwd 案件密码
  149. */
  150. export const deleteById = (id: number, pwd: string) =>
  151. defHttp.delete<void>({ url: adminPath + '/case/delete', params: { id, pwd } });
  152. /**
  153. * 更新案件密码
  154. * @param data 更新密码数据
  155. */
  156. export const updatePwd = (data: UpdateCasePwdDTO) =>
  157. defHttp.postJson<void>({ url: adminPath + '/case/updatePwd', data });
  158. /**
  159. * 开启案件
  160. * @param data 开启案件数据(id + 密码)
  161. * @returns 案件信息
  162. */
  163. export const openCase = (data: OpenCaseDTO) => defHttp.postJson<CaseInfo>({ url: adminPath + '/case/open', data });
  164. /**
  165. * 退出当前案件
  166. */
  167. export const exitCase = () => defHttp.get<void>({ url: adminPath + '/case/exit' });