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);
|
}
|