liu
3 天以前 2b695bfabdceccb0ee19c12c8e655bd7f47a6e2f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
import type { PageParam, PageResult } from '@vben/request';
 
import { requestClient } from '#/api/request';
 
export namespace WxCpNoticeApi {
  /** 通知状态:0草稿 1已发布 2已撤回 */
  export const NOTICE_STATUS = {
    DRAFT: 0,
    PUBLISHED: 1,
    REVOKED: 2,
  } as const;
 
  /** 通知模板类型 */
  export const NOTICE_TYPE = {
    TEXT: 1,
    CARD: 2,
    FILE: 3,
    NEWS: 4,
    IMAGE: 5,
    VIDEO: 6,
    MARKDOWN: 7,
    MULTI_NEWS: 8,
  } as const;
 
  /** 多图文条目 */
  export interface NoticeArticle {
    id?: number;
    title?: string;
    description?: string;
    linkUrl?: string;
    coverBlobId?: number;
    coverAttachment?: NoticeAttachment;
    sortNo?: number;
  }
 
  /** 通知附件(图片/文件/视频通用) */
  export interface NoticeAttachment {
    id?: number;
    name?: string;
    originalFilename?: string;
    contentType?: string;
    byteSize?: number;
    url?: string;
    previewURL?: string;
    downloadURL?: string;
  }
 
  /** 通知 */
  export interface Notice {
    id?: number;
    title?: string;
    content?: string;
    noticeType?: number;
    noticeTypeName?: string;
    summary?: string;
    linkUrl?: string;
    linkBtnText?: string;
    coverUrl?: string;
    /** 旧版单附件字段,兼容历史数据 */
    fileBlobId?: number;
    /** 旧版单附件文件名 */
    fileName?: string;
    /** 图片通知的图片 blobId 列表 */
    imageBlobIds?: number[];
    /** 图片通知的图片附件列表 */
    imageAttachmentList?: NoticeAttachment[];
    /** 附件通知的附件 blobId 列表 */
    fileBlobIds?: number[];
    /** 附件通知的附件列表 */
    fileAttachmentList?: NoticeAttachment[];
    /** 视频通知的视频 blobId 列表 */
    videoBlobIds?: number[];
    /** 视频通知的视频列表 */
    videoAttachmentList?: NoticeAttachment[];
    /** 多图文消息的图文列表 */
    articleList?: NoticeArticle[];
    /** 成员预览页地址 */
    previewUrl?: string;
    status?: number;
    statusName?: string;
    pushScope?: number;
    pushScopeName?: string;
    pushTarget?: string;
    pushStatus?: number;
    pushTime?: string;
    remark?: string;
    createTime?: string;
  }
 
  /** 通知分页查询参数 */
  export interface NoticePageParams extends PageParam {
    title?: string;
    status?: number;
    pushStatus?: number;
  }
}
 
/** 获得通知分页 */
export function getNoticePage(params: WxCpNoticeApi.NoticePageParams) {
  return requestClient.get<PageResult<WxCpNoticeApi.Notice>>(
    '/wxcp/notice/page',
    { params },
  );
}
 
/** 获得通知详情 */
export function getNotice(id: number) {
  return requestClient.get<WxCpNoticeApi.Notice>('/wxcp/notice/get', {
    params: { id },
  });
}
 
/** 创建通知(存为草稿) */
export function createNotice(data: WxCpNoticeApi.Notice) {
  return requestClient.post<number>('/wxcp/notice/create', data);
}
 
/** 修改通知 */
export function updateNotice(data: WxCpNoticeApi.Notice) {
  return requestClient.put<boolean>('/wxcp/notice/update', data);
}
 
/** 删除通知 */
export function deleteNotice(id: number) {
  return requestClient.delete<boolean>('/wxcp/notice/delete', {
    params: { id },
  });
}
 
/** 发布通知 */
export function publishNotice(id: number) {
  return requestClient.put<boolean>('/wxcp/notice/publish', null, {
    params: { id },
  });
}
 
/** 撤回通知 */
export function revokeNotice(id: number) {
  return requestClient.put<boolean>('/wxcp/notice/revoke', null, {
    params: { id },
  });
}
 
/** 推送通知给企业微信成员 */
export function pushNotice(data: {
  id: number;
  pushScope?: number;
  pushTarget?: string;
  noticeType?: number;
  summary?: string;
  linkUrl?: string;
  linkBtnText?: string;
  coverUrl?: string;
  fileBlobId?: number;
  fileName?: string;
  imageBlobIds?: number[];
  fileBlobIds?: number[];
  videoBlobIds?: number[];
  articleList?: WxCpNoticeApi.NoticeArticle[];
}) {
  return requestClient.post<{
    success: boolean;
    errCode?: null | number;
    message?: string;
  }>('/wxcp/notice/push', data);
}