mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-11-03 02:57:11 +08:00
refactor: 优化站内信及消息管理
1.新增站内信未读消息轮询 2.优化消息管理 API,移除部分无用 API 3.优化部分代码格式
This commit is contained in:
@@ -3,45 +3,33 @@ import qs from 'query-string';
|
||||
|
||||
const BASE_URL = '/system/message';
|
||||
|
||||
export interface MessageRecord {
|
||||
export interface DataRecord {
|
||||
id: number;
|
||||
title: string;
|
||||
content: string;
|
||||
type: string;
|
||||
createUserString: string;
|
||||
type: number;
|
||||
createUserString?: string;
|
||||
createTime: string;
|
||||
subTitle: string;
|
||||
readStatus: boolean;
|
||||
isRead: boolean;
|
||||
readTime: string;
|
||||
}
|
||||
|
||||
export interface ChatRecord {
|
||||
id: number;
|
||||
username: string;
|
||||
content: string;
|
||||
time: string;
|
||||
isCollect: boolean;
|
||||
}
|
||||
|
||||
export interface ListParam {
|
||||
title?: string;
|
||||
readStatus?: 0 | 1;
|
||||
type?: string;
|
||||
type?: number;
|
||||
isRead?: boolean;
|
||||
page?: number;
|
||||
size?: number;
|
||||
uid?: number;
|
||||
sort?: Array<string>;
|
||||
}
|
||||
|
||||
export interface PageRes {
|
||||
list: MessageRecord[];
|
||||
export interface ListRes {
|
||||
list: DataRecord[];
|
||||
total: number;
|
||||
}
|
||||
|
||||
export type MessageListType = MessageRecord[];
|
||||
|
||||
export function page(params?: ListParam) {
|
||||
return axios.get<PageRes>(`${BASE_URL}`, {
|
||||
export function list(params: ListParam) {
|
||||
return axios.get<ListRes>(`${BASE_URL}`, {
|
||||
params,
|
||||
paramsSerializer: (obj) => {
|
||||
return qs.stringify(obj);
|
||||
@@ -49,27 +37,24 @@ export function page(params?: ListParam) {
|
||||
});
|
||||
}
|
||||
|
||||
export function list(params?: ListParam) {
|
||||
return axios.get<MessageListType>(`${BASE_URL}/list`, {
|
||||
params,
|
||||
paramsSerializer: (obj) => {
|
||||
return qs.stringify(obj);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function get(id: number) {
|
||||
return axios.get<MessageRecord>(`${BASE_URL}/${id}`);
|
||||
}
|
||||
|
||||
export function del(ids: number | Array<number>) {
|
||||
return axios.delete(`${BASE_URL}/${ids}`);
|
||||
}
|
||||
|
||||
export function read(data: Array<number>) {
|
||||
return axios.patch<MessageListType>(`${BASE_URL}/read?ids=${data}`);
|
||||
export function read(ids: Array<number>) {
|
||||
return axios.patch(`${BASE_URL}/read?ids=${ids}`);
|
||||
}
|
||||
|
||||
export function queryChatList() {
|
||||
return axios.get<ChatRecord[]>('/api/chat/list');
|
||||
export interface MessageTypeUnreadRes {
|
||||
type: number;
|
||||
count: number;
|
||||
}
|
||||
|
||||
export interface MessageUnreadRes {
|
||||
total: number;
|
||||
details: MessageTypeUnreadRes[];
|
||||
}
|
||||
|
||||
export function countUnread(detail: boolean) {
|
||||
return axios.get<MessageUnreadRes>(`${BASE_URL}/unread?detail=${detail}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user