105 lines
2.2 KiB
TypeScript
105 lines
2.2 KiB
TypeScript
import type { Recordable } from '@vben/types';
|
|
|
|
import { requestClient } from '#/api/request';
|
|
|
|
export namespace SystemNoticeApi {
|
|
export interface NoticeItem {
|
|
[key: string]: any;
|
|
content: string;
|
|
createTime?: string;
|
|
createdBy?: string;
|
|
id: string;
|
|
isDeleted: boolean;
|
|
isTop: boolean;
|
|
level: number;
|
|
notifyUsers?: string;
|
|
status: 0 | 1;
|
|
summary?: string;
|
|
title: string;
|
|
updateTime?: string;
|
|
}
|
|
|
|
export interface NoticeInput {
|
|
content: string;
|
|
id?: string;
|
|
isTop?: boolean;
|
|
level?: number;
|
|
notifyUsers?: string;
|
|
status?: 0 | 1;
|
|
summary?: string;
|
|
title: string;
|
|
}
|
|
|
|
export interface NoticeQuery {
|
|
[key: string]: any;
|
|
isTop?: boolean | number | string;
|
|
keyword?: string;
|
|
level?: number | string;
|
|
notifyUsers?: string;
|
|
page?: number;
|
|
pageNo?: number;
|
|
pageSize?: number;
|
|
status?: 0 | 1 | number | string;
|
|
}
|
|
|
|
export interface PageResult<T> {
|
|
items: T[];
|
|
total: number;
|
|
}
|
|
}
|
|
|
|
async function getNoticeList(params: Recordable<any>) {
|
|
return requestClient.get<SystemNoticeApi.PageResult<SystemNoticeApi.NoticeItem>>(
|
|
'/system/notice/list',
|
|
{ params },
|
|
);
|
|
}
|
|
|
|
async function getNoticeDetail(id: string) {
|
|
return requestClient.get<SystemNoticeApi.NoticeItem>(`/system/notice/detail/${id}`);
|
|
}
|
|
|
|
async function createNotice(data: SystemNoticeApi.NoticeInput) {
|
|
return requestClient.post<string>('/system/notice/save', data);
|
|
}
|
|
|
|
async function updateNotice(id: string, data: SystemNoticeApi.NoticeInput) {
|
|
return requestClient.post('/system/notice/update', {
|
|
...data,
|
|
id,
|
|
});
|
|
}
|
|
|
|
async function deleteNotice(id: string) {
|
|
return requestClient.delete(`/system/notice/${id}`);
|
|
}
|
|
|
|
async function toggleNoticeStatus(id: string, status: SystemNoticeApi.NoticeItem['status']) {
|
|
return requestClient.post('/system/notice/toggle', undefined, {
|
|
params: {
|
|
id,
|
|
status,
|
|
},
|
|
});
|
|
}
|
|
|
|
async function toggleNoticeTop(id: string, isTop: boolean) {
|
|
return requestClient.post('/system/notice/top', undefined, {
|
|
params: {
|
|
id,
|
|
isTop: isTop ? 1 : 0,
|
|
},
|
|
});
|
|
}
|
|
|
|
export {
|
|
createNotice,
|
|
deleteNotice,
|
|
getNoticeDetail,
|
|
getNoticeList,
|
|
toggleNoticeStatus,
|
|
toggleNoticeTop,
|
|
updateNotice,
|
|
};
|
|
|