- src/api/admin/product.ts、src/api/admin/notice.ts 对齐后端新接口 - ProductManagementView:列表/筛选/新建编辑/上下架/删除,新建默认下架有提示 - NoticeManagementView:列表/筛选/新建编辑/发布下架/删除 - 状态列一律用接口返回的 statusText,不在前端写死中文 - id 按字符串处理(雪花 id 超过 JS 安全整数范围,数字会被四舍五入)
67 lines
1.7 KiB
TypeScript
67 lines
1.7 KiB
TypeScript
// Author: fruit.com.cn
|
|
|
|
import request from '@/axios'
|
|
import type { PageResult } from './types'
|
|
|
|
/** 系统公告:字段与 /admin/notices 的响应一一对应 */
|
|
export interface NoticeItem {
|
|
/** 雪花 id,后端以字符串下发(超过 JS 安全整数范围),原样回传即可 */
|
|
id: string
|
|
title: string
|
|
content: string
|
|
/** ALL / USER / CREATOR */
|
|
target: string
|
|
targetText: string
|
|
/** SYSTEM / AUDIT / PAYMENT / ACTIVITY */
|
|
type: string
|
|
typeText: string
|
|
/** 1 已发布 / 0 已下架 */
|
|
status: number
|
|
statusText: string
|
|
publishAt?: string
|
|
expireAt?: string
|
|
createdAt?: string
|
|
}
|
|
|
|
export interface NoticePageParams {
|
|
pageIndex?: number
|
|
pageSize?: number
|
|
status?: number
|
|
target?: string
|
|
type?: string
|
|
keyword?: string
|
|
}
|
|
|
|
export interface NoticeSaveData {
|
|
title: string
|
|
content: string
|
|
target: string
|
|
type: string
|
|
publishAt?: string | null
|
|
expireAt?: string | null
|
|
}
|
|
|
|
export const pageNoticesApi = (params: NoticePageParams) => {
|
|
return request.get<PageResult<NoticeItem>>({ url: '/admin/notices/page', params })
|
|
}
|
|
|
|
export const getNoticeApi = (id: string | number) => {
|
|
return request.get<NoticeItem>({ url: `/admin/notices/${id}` })
|
|
}
|
|
|
|
export const createNoticeApi = (data: NoticeSaveData) => {
|
|
return request.post<string>({ url: '/admin/notices', data })
|
|
}
|
|
|
|
export const updateNoticeApi = (id: string | number, data: NoticeSaveData) => {
|
|
return request.put<void>({ url: `/admin/notices/${id}`, data })
|
|
}
|
|
|
|
export const updateNoticeStatusApi = (id: string | number, status: number) => {
|
|
return request.put<void>({ url: `/admin/notices/${id}/status`, params: { status } })
|
|
}
|
|
|
|
export const deleteNoticeApi = (id: string | number) => {
|
|
return request.delete<void>({ url: `/admin/notices/${id}` })
|
|
}
|