ImmunityApi.ts 885 B

1234567891011121314151617181920212223242526272829303132333435
  1. import FetchRequest from '@/api/FetchRequest'
  2. import type Immunity from '@/mode/Immunity'
  3. // @ts-ignore
  4. import type AjaxResult from '@/mode/AjaxResult'
  5. class ImmunityApi {
  6. static url = '/api/sys/immunity'
  7. /**
  8. * 获取用户免打扰
  9. */
  10. static list(userId: string): Promise<AjaxResult<Immunity[]>> {
  11. return FetchRequest.get(`${this.url}/${userId}`, true)
  12. }
  13. /**
  14. * 保存用户免打扰
  15. */
  16. static save(userId: string, chatId: string): Promise<AjaxResult<Immunity[]>> {
  17. const immunity: Immunity = {
  18. userId: userId,
  19. chatId: chatId
  20. }
  21. return FetchRequest.post(this.url, JSON.stringify(immunity), true)
  22. }
  23. /**
  24. * 删除用户免打扰
  25. */
  26. static delete(userId: string, chatId: string): Promise<AjaxResult<Immunity[]>> {
  27. return FetchRequest.del(`${this.url}/${userId}-${chatId}`, '', true)
  28. }
  29. }
  30. export default ImmunityApi