app_message.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import axiosInstance from '../../utils/axios';
  2. import { PageParam, PageResponse } from '../user';
  3. // 站内信消息类型
  4. export interface NotifyMessageVO {
  5. id: number;
  6. userId: number;
  7. userType: number;
  8. templateId?: number;
  9. templateCode?: string;
  10. templateNickname?: string;
  11. templateContent?: string;
  12. templateParams?: any;
  13. templateType?: number;
  14. title: string;
  15. createTime?: number | string; // 创建时间(时间戳或字符串)
  16. readStatus?: boolean; // 是否已读
  17. readTime?: number | string; // 阅读时间(时间戳或字符串)
  18. }
  19. // App通知查询参数
  20. export interface NotifyMessageQueryParams extends PageParam {
  21. readStatus?: boolean; // 是否已读,示例值(true)
  22. title?: string; // 标题,示例值(true)
  23. 'createTime[0]'?: string; // 开始日期时间:格式 YYYY-MM-DD 00:00:00
  24. 'createTime[1]'?: string; // 结束日期时间:格式 YYYY-MM-DD 23:59:59
  25. type?: number; // 类型(0-站内信 1-app消息),示例值(1)
  26. [key: string]: any; // 允许动态添加其他参数
  27. }
  28. // 发送站内信参数
  29. export interface SendNotifyMessageVO {
  30. title: string; // 消息标题
  31. content: string; // 消息内容
  32. type?: string; // 消息类型
  33. userIds?: number[]; // 接收用户ID列表
  34. deptIds?: number[]; // 接收部门ID列表
  35. roleIds?: number[]; // 接收角色ID列表
  36. }
  37. // App 通知 API
  38. export const app_message = {
  39. // 获取我的 App 通知列表(分页)
  40. getMyPage: (params?: NotifyMessageQueryParams): Promise<PageResponse<NotifyMessageVO>> => {
  41. return axiosInstance.get('/system/app-notify-message/my-page', { params });
  42. },
  43. // 标记消息为已读
  44. updateRead: (ids: number[]): Promise<void> => {
  45. const idsParam = ids.join(',');
  46. return axiosInstance.put(`/system/app-notify-message/update-read?ids=${idsParam}`);
  47. },
  48. // 全部标记为已读
  49. updateAllRead: (): Promise<void> => {
  50. return axiosInstance.put('/system/app-notify-message/update-all-read');
  51. },
  52. };