2026-02-25 10:37:16 +08:00
|
|
|
import axios, { AxiosError } from 'axios'
|
|
|
|
|
import router from '../router'
|
|
|
|
|
import { message } from 'ant-design-vue'
|
2026-03-10 23:23:15 +08:00
|
|
|
import { ADMIN_API_BASE_URL } from '../config/api'
|
2026-02-25 10:37:16 +08:00
|
|
|
|
2026-02-26 23:28:24 +08:00
|
|
|
let lastErrorTime = 0
|
|
|
|
|
let lastErrorMessage = ''
|
2026-03-26 10:28:28 +08:00
|
|
|
const ERROR_DEBOUNCE_TIME = 1000
|
2026-02-26 23:28:24 +08:00
|
|
|
|
2026-02-25 10:37:16 +08:00
|
|
|
const adminApi = axios.create({
|
2026-03-10 23:23:15 +08:00
|
|
|
baseURL: ADMIN_API_BASE_URL,
|
2026-02-25 10:37:16 +08:00
|
|
|
timeout: 10000,
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
let isRefreshing = false
|
|
|
|
|
let failedQueue: Array<{
|
|
|
|
|
resolve: (value?: any) => void
|
|
|
|
|
reject: (reason?: any) => void
|
|
|
|
|
}> = []
|
|
|
|
|
|
|
|
|
|
const processQueue = (error: any, token: string | null = null) => {
|
|
|
|
|
failedQueue.forEach(prom => {
|
|
|
|
|
if (error) {
|
|
|
|
|
prom.reject(error)
|
|
|
|
|
} else {
|
|
|
|
|
prom.resolve(token)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
failedQueue = []
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const showError = (msg: string) => {
|
|
|
|
|
const now = Date.now()
|
|
|
|
|
if (now - lastErrorTime > ERROR_DEBOUNCE_TIME || msg !== lastErrorMessage) {
|
|
|
|
|
lastErrorTime = now
|
|
|
|
|
lastErrorMessage = msg
|
|
|
|
|
message.error(msg)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const isAuthFreePath = (url?: string) => {
|
|
|
|
|
return Boolean(url?.includes('/auth/login') || url?.includes('/auth/refresh'))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleAdminTokenExpired = () => {
|
|
|
|
|
localStorage.removeItem('adminAccessToken')
|
|
|
|
|
localStorage.removeItem('adminRefreshToken')
|
|
|
|
|
localStorage.removeItem('adminUserInfo')
|
|
|
|
|
localStorage.removeItem('userPermissions')
|
|
|
|
|
sessionStorage.removeItem('adminAccessToken')
|
|
|
|
|
sessionStorage.removeItem('adminRefreshToken')
|
|
|
|
|
|
|
|
|
|
if (Date.now() - lastErrorTime > ERROR_DEBOUNCE_TIME || lastErrorMessage !== '登录已过期,请重新登录') {
|
|
|
|
|
showError('登录已过期,请重新登录')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
try {
|
|
|
|
|
router.push('/admin/login').catch(() => {
|
|
|
|
|
window.location.href = '/admin/login'
|
|
|
|
|
})
|
|
|
|
|
} catch {
|
|
|
|
|
window.location.href = '/admin/login'
|
|
|
|
|
}
|
|
|
|
|
}, 300)
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-25 10:37:16 +08:00
|
|
|
adminApi.interceptors.request.use(
|
|
|
|
|
config => {
|
2026-03-26 10:28:28 +08:00
|
|
|
if (!isAuthFreePath(config.url)) {
|
2026-02-27 16:44:41 +08:00
|
|
|
let token = localStorage.getItem('adminAccessToken')
|
|
|
|
|
if (!token) {
|
|
|
|
|
token = sessionStorage.getItem('adminAccessToken')
|
|
|
|
|
}
|
|
|
|
|
if (token) {
|
|
|
|
|
config.headers.Authorization = `Bearer ${token}`
|
|
|
|
|
}
|
2026-02-25 10:37:16 +08:00
|
|
|
}
|
|
|
|
|
return config
|
|
|
|
|
},
|
2026-03-26 10:28:28 +08:00
|
|
|
error => Promise.reject(error)
|
2026-02-25 10:37:16 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
adminApi.interceptors.response.use(
|
|
|
|
|
response => {
|
2026-02-25 19:07:39 +08:00
|
|
|
const res = response.data
|
|
|
|
|
if (res.code !== 200) {
|
2026-02-26 23:28:24 +08:00
|
|
|
const errorMsg = res.message || '请求失败'
|
|
|
|
|
if (!errorMsg.includes('权限') && !errorMsg.includes('permission')) {
|
2026-03-26 10:28:28 +08:00
|
|
|
showError(errorMsg)
|
2026-02-26 23:28:24 +08:00
|
|
|
} else {
|
|
|
|
|
console.error('权限不足:', errorMsg)
|
|
|
|
|
}
|
|
|
|
|
return Promise.reject(new Error(errorMsg))
|
2026-02-25 19:07:39 +08:00
|
|
|
}
|
2026-03-02 10:13:20 +08:00
|
|
|
return res.data as any
|
2026-02-25 10:37:16 +08:00
|
|
|
},
|
|
|
|
|
async (error: AxiosError) => {
|
2026-03-26 10:28:28 +08:00
|
|
|
const originalRequest = error.config as any
|
2026-02-26 23:28:24 +08:00
|
|
|
|
|
|
|
|
if (error.response?.status === 401) {
|
2026-03-26 10:28:28 +08:00
|
|
|
if (!originalRequest?._retry && !isAuthFreePath(originalRequest?.url)) {
|
|
|
|
|
if (isRefreshing) {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
failedQueue.push({ resolve, reject })
|
|
|
|
|
}).then(token => {
|
|
|
|
|
if (token) {
|
|
|
|
|
originalRequest.headers.Authorization = `Bearer ${token}`
|
|
|
|
|
}
|
|
|
|
|
return adminApi(originalRequest)
|
2026-02-26 23:28:24 +08:00
|
|
|
})
|
2026-03-26 10:28:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
originalRequest._retry = true
|
|
|
|
|
isRefreshing = true
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
let refreshToken = localStorage.getItem('adminRefreshToken')
|
|
|
|
|
if (!refreshToken) {
|
|
|
|
|
refreshToken = sessionStorage.getItem('adminRefreshToken')
|
|
|
|
|
}
|
|
|
|
|
if (!refreshToken) {
|
|
|
|
|
throw new Error('No refresh token available')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const response = await adminAuthApi.refreshToken(refreshToken)
|
|
|
|
|
const newToken = (response as any).accessToken
|
|
|
|
|
const newRefreshToken = (response as any).refreshToken
|
|
|
|
|
|
|
|
|
|
localStorage.setItem('adminAccessToken', newToken)
|
|
|
|
|
localStorage.setItem('adminRefreshToken', newRefreshToken)
|
|
|
|
|
sessionStorage.setItem('adminAccessToken', newToken)
|
|
|
|
|
sessionStorage.setItem('adminRefreshToken', newRefreshToken)
|
|
|
|
|
|
|
|
|
|
processQueue(null, newToken)
|
|
|
|
|
originalRequest.headers.Authorization = `Bearer ${newToken}`
|
|
|
|
|
return adminApi(originalRequest)
|
|
|
|
|
} catch (refreshError) {
|
|
|
|
|
processQueue(refreshError, null)
|
|
|
|
|
handleAdminTokenExpired()
|
|
|
|
|
return Promise.reject(refreshError)
|
|
|
|
|
} finally {
|
|
|
|
|
isRefreshing = false
|
2026-02-26 23:28:24 +08:00
|
|
|
}
|
|
|
|
|
}
|
2026-03-26 10:28:28 +08:00
|
|
|
|
|
|
|
|
handleAdminTokenExpired()
|
|
|
|
|
} else if (error.response?.status !== 403) {
|
2026-02-25 19:07:39 +08:00
|
|
|
const errorMsg = (error.response?.data as any)?.message || error.message || '请求失败'
|
2026-02-26 23:28:24 +08:00
|
|
|
showError(errorMsg)
|
|
|
|
|
} else {
|
|
|
|
|
console.error('权限不足:', error)
|
2026-02-25 10:37:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.error('Admin API Error:', error)
|
|
|
|
|
return Promise.reject(error)
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
export interface AdminLoginRequest {
|
2026-02-25 11:08:02 +08:00
|
|
|
account: string
|
2026-02-25 10:37:16 +08:00
|
|
|
password: string
|
2026-03-21 14:33:33 +08:00
|
|
|
shopId?: string | number
|
2026-02-25 10:37:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface AdminLoginResponse {
|
|
|
|
|
accessToken: string
|
|
|
|
|
refreshToken: string
|
|
|
|
|
userInfo: any
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
export interface LoginShopSelectionResponse {
|
|
|
|
|
allowShoplessLogin: boolean
|
|
|
|
|
message: string
|
|
|
|
|
shops: Array<{
|
|
|
|
|
id: number | string
|
|
|
|
|
shopName: string
|
|
|
|
|
}>
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-25 10:37:16 +08:00
|
|
|
export const adminAuthApi = {
|
|
|
|
|
login: (data: AdminLoginRequest) => {
|
2026-02-27 14:20:20 +08:00
|
|
|
return adminApi.post<AdminLoginResponse>('/auth/login', data)
|
2026-02-25 10:37:16 +08:00
|
|
|
},
|
2026-03-26 10:28:28 +08:00
|
|
|
getLoginShops: (account: string) => {
|
|
|
|
|
return adminApi.get<LoginShopSelectionResponse>(`/auth/login-shops/${encodeURIComponent(account)}`)
|
|
|
|
|
},
|
|
|
|
|
logout: () => {
|
|
|
|
|
return adminApi.post<boolean>('/auth/logout')
|
|
|
|
|
},
|
|
|
|
|
switchShop: (shopId?: string | number) => {
|
|
|
|
|
return adminApi.post<AdminLoginResponse>('/auth/switch-shop', { shopId })
|
|
|
|
|
},
|
2026-03-04 10:14:45 +08:00
|
|
|
refreshToken: (refreshToken: string) => {
|
|
|
|
|
return adminApi.post<{ accessToken: string; refreshToken: string }>('/auth/refresh', { refreshToken })
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-02-25 10:37:16 +08:00
|
|
|
|
2026-03-04 10:14:45 +08:00
|
|
|
export interface ObjectStorageFileVO {
|
|
|
|
|
id: number
|
|
|
|
|
fileName: string
|
|
|
|
|
fileSize: number
|
|
|
|
|
contentType: string
|
|
|
|
|
createTime: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const adminFileApi = {
|
|
|
|
|
uploadFile: (file: File) => {
|
|
|
|
|
const formData = new FormData()
|
|
|
|
|
formData.append('file', file)
|
|
|
|
|
return adminApi.post<ObjectStorageFileVO>('/object-storage-file/upload', formData, {
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'multipart/form-data'
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
getSignedUrl: (id: number) => {
|
|
|
|
|
return adminApi.get<string>(`/object-storage-file/get-signed-url/${id}`)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface Tag {
|
|
|
|
|
id: number
|
|
|
|
|
tagName: string
|
|
|
|
|
textColor?: string
|
|
|
|
|
bgColor?: string
|
|
|
|
|
borderColor?: string
|
|
|
|
|
shopId?: number
|
|
|
|
|
createTime: string
|
|
|
|
|
updateTime: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const adminTagApi = {
|
|
|
|
|
listAllTags: () => {
|
2026-03-20 12:24:56 +08:00
|
|
|
return adminApi.get<Tag[]>('/tag/list/all') as unknown as Promise<Tag[]>
|
2026-03-04 10:14:45 +08:00
|
|
|
},
|
|
|
|
|
listTagsByShopId: (shopId: number) => {
|
2026-03-20 12:24:56 +08:00
|
|
|
return adminApi.get<Tag[]>(`/tag/list/by-shop/${shopId}`) as unknown as Promise<Tag[]>
|
2026-03-04 10:14:45 +08:00
|
|
|
},
|
|
|
|
|
createTag: (data: { tagName: string; textColor?: string; bgColor?: string; borderColor?: string; shopId?: number }) => {
|
|
|
|
|
return adminApi.post<number>('/tag/create', data)
|
|
|
|
|
},
|
|
|
|
|
updateTag: (id: number, data: { tagName: string; textColor?: string; bgColor?: string; borderColor?: string; shopId?: number }) => {
|
|
|
|
|
return adminApi.put<boolean>(`/tag/update/${id}`, data)
|
|
|
|
|
},
|
|
|
|
|
deleteTag: (id: number) => {
|
|
|
|
|
return adminApi.delete<boolean>(`/tag/delete/${id}`)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface Artist {
|
|
|
|
|
id: number
|
|
|
|
|
nickname: string
|
|
|
|
|
account: string
|
|
|
|
|
avatar?: string
|
|
|
|
|
shopId?: number
|
|
|
|
|
shopName?: string
|
|
|
|
|
createTime: string
|
|
|
|
|
updateTime: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const adminArtistApi = {
|
|
|
|
|
listArtists: (shopId?: number) => {
|
|
|
|
|
const params: any = {}
|
|
|
|
|
if (shopId) {
|
|
|
|
|
params.shopId = shopId
|
|
|
|
|
}
|
|
|
|
|
return adminApi.get<Artist[]>('/user/list/artists', { params })
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface Coupon {
|
|
|
|
|
id: number
|
2026-03-20 12:24:56 +08:00
|
|
|
couponCode?: string
|
2026-03-04 10:14:45 +08:00
|
|
|
couponName: string
|
|
|
|
|
couponType: number
|
2026-03-20 12:24:56 +08:00
|
|
|
couponTypeName?: string
|
2026-03-04 10:14:45 +08:00
|
|
|
discountValue?: string
|
|
|
|
|
minAmount?: number
|
|
|
|
|
reduceAmount?: string
|
2026-03-20 12:24:56 +08:00
|
|
|
totalCount?: number
|
|
|
|
|
usedCount?: number
|
|
|
|
|
remainingCount?: number
|
2026-03-04 10:14:45 +08:00
|
|
|
startTime: string
|
|
|
|
|
endTime: string
|
2026-03-20 12:24:56 +08:00
|
|
|
status?: number
|
|
|
|
|
statusName?: string
|
2026-03-04 10:14:45 +08:00
|
|
|
shopId?: number
|
|
|
|
|
shopName?: string
|
2026-03-20 12:24:56 +08:00
|
|
|
couponScene?: string
|
|
|
|
|
requiredVipLevel?: string
|
|
|
|
|
autoMatch?: number
|
|
|
|
|
availableTags?: Tag[]
|
|
|
|
|
unavailableTags?: Tag[]
|
2026-03-04 10:14:45 +08:00
|
|
|
createTime: string
|
|
|
|
|
updateTime: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const adminCouponApi = {
|
|
|
|
|
listAllCoupons: (shopId?: number) => {
|
|
|
|
|
const params = shopId ? { shopId } : {}
|
2026-03-20 12:24:56 +08:00
|
|
|
return adminApi.get<Coupon[]>('/coupon/list/all', { params }) as unknown as Promise<Coupon[]>
|
2026-03-04 10:14:45 +08:00
|
|
|
},
|
|
|
|
|
createCoupon: (data: any) => {
|
|
|
|
|
return adminApi.post<number>('/coupon/create', data)
|
|
|
|
|
},
|
|
|
|
|
updateCoupon: (id: number, data: any) => {
|
|
|
|
|
return adminApi.put<boolean>(`/coupon/update/${id}`, data)
|
|
|
|
|
},
|
|
|
|
|
deleteCoupon: (id: number) => {
|
|
|
|
|
return adminApi.delete<boolean>(`/coupon/delete/${id}`)
|
2026-03-10 23:23:15 +08:00
|
|
|
},
|
|
|
|
|
distributeCoupon: (data: any) => {
|
2026-03-20 12:24:56 +08:00
|
|
|
return adminApi.post<boolean>('/coupon/distribute', null, { params: data })
|
2026-02-25 10:37:16 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-25 14:32:34 +08:00
|
|
|
export interface Product {
|
|
|
|
|
id: number
|
|
|
|
|
shopId: number
|
2026-03-04 10:14:45 +08:00
|
|
|
shopName?: string
|
2026-02-25 14:32:34 +08:00
|
|
|
title: string
|
|
|
|
|
description: string
|
|
|
|
|
price: number
|
2026-03-04 10:14:45 +08:00
|
|
|
approximateDuration?: string
|
|
|
|
|
tags?: string
|
2026-02-25 14:32:34 +08:00
|
|
|
tagList?: string[]
|
|
|
|
|
tagInfos?: any[]
|
2026-03-04 10:14:45 +08:00
|
|
|
imageFileIds?: string
|
|
|
|
|
imageUrls?: string[]
|
|
|
|
|
bookableArtists?: string
|
|
|
|
|
availableCoupons?: string
|
|
|
|
|
likeCount?: number
|
|
|
|
|
collectCount?: number
|
2026-02-25 14:32:34 +08:00
|
|
|
createTime: string
|
|
|
|
|
updateTime: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const adminProductApi = {
|
2026-02-25 16:50:32 +08:00
|
|
|
listProducts: (params: { page: number; size: number; keyword?: string; shopId?: number }) => {
|
2026-03-04 10:14:45 +08:00
|
|
|
return adminApi.get<{ list: Product[]; total: number; page: number; size: number }>('/product/list', { params })
|
2026-02-25 14:32:34 +08:00
|
|
|
},
|
2026-03-04 10:14:45 +08:00
|
|
|
listAllProducts: () => {
|
|
|
|
|
return adminApi.get<Product[]>('/product/list/all')
|
|
|
|
|
},
|
|
|
|
|
createProduct: (data: any) => {
|
2026-02-27 14:20:20 +08:00
|
|
|
return adminApi.post<number>('/product/create', data)
|
2026-02-25 14:32:34 +08:00
|
|
|
},
|
2026-03-04 10:14:45 +08:00
|
|
|
updateProduct: (id: number, data: any) => {
|
2026-02-27 14:20:20 +08:00
|
|
|
return adminApi.put<boolean>(`/product/update/${id}`, data)
|
2026-02-25 14:32:34 +08:00
|
|
|
},
|
|
|
|
|
deleteProduct: (id: number) => {
|
2026-02-27 14:20:20 +08:00
|
|
|
return adminApi.delete<boolean>(`/product/delete/${id}`)
|
2026-02-25 14:32:34 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-25 14:44:50 +08:00
|
|
|
export interface Shop {
|
|
|
|
|
id: number
|
|
|
|
|
shopName: string
|
|
|
|
|
description: string
|
|
|
|
|
address: string
|
|
|
|
|
businessHours: string
|
2026-03-26 10:28:28 +08:00
|
|
|
status?: number
|
2026-03-04 10:14:45 +08:00
|
|
|
coverImageFileId?: string
|
|
|
|
|
coverImageUrls?: string[]
|
|
|
|
|
imageFileIds?: string
|
2026-02-26 14:20:35 +08:00
|
|
|
imageUrls?: string[]
|
2026-02-25 14:44:50 +08:00
|
|
|
createTime: string
|
|
|
|
|
updateTime: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ShopListResponse {
|
|
|
|
|
list: Shop[]
|
|
|
|
|
total: number
|
|
|
|
|
page: number
|
|
|
|
|
size: number
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface CreateShopRequest {
|
|
|
|
|
shopName: string
|
|
|
|
|
description: string
|
|
|
|
|
address: string
|
|
|
|
|
businessHours: string
|
2026-03-04 10:14:45 +08:00
|
|
|
coverImageFileId?: string
|
|
|
|
|
imageFileIds?: string
|
2026-03-26 10:28:28 +08:00
|
|
|
status?: number
|
2026-02-25 14:44:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const adminShopApi = {
|
2026-02-25 16:50:32 +08:00
|
|
|
listShops: (params: { page: number; size: number; keyword?: string; shopId?: number }) => {
|
2026-03-20 12:24:56 +08:00
|
|
|
return adminApi.get<ShopListResponse>('/shops/list', { params }) as unknown as Promise<ShopListResponse>
|
2026-02-25 14:44:50 +08:00
|
|
|
},
|
2026-02-25 17:27:52 +08:00
|
|
|
listAllShops: () => {
|
2026-03-20 12:24:56 +08:00
|
|
|
return adminApi.get<Shop[]>('/shops/list/all') as unknown as Promise<Shop[]>
|
2026-02-25 17:27:52 +08:00
|
|
|
},
|
2026-02-25 14:44:50 +08:00
|
|
|
createShop: (data: CreateShopRequest) => {
|
2026-02-27 14:20:20 +08:00
|
|
|
return adminApi.post<number>('/shops/create', data)
|
2026-02-25 14:44:50 +08:00
|
|
|
},
|
|
|
|
|
updateShop: (id: number, data: CreateShopRequest) => {
|
2026-02-27 14:20:20 +08:00
|
|
|
return adminApi.put<boolean>(`/shops/update/${id}`, data)
|
2026-02-25 14:44:50 +08:00
|
|
|
},
|
2026-03-26 10:28:28 +08:00
|
|
|
updateShopStatus: (id: number, status: number) => {
|
|
|
|
|
return adminApi.put<boolean>(`/shops/status/${id}`, { status })
|
|
|
|
|
},
|
2026-02-25 14:44:50 +08:00
|
|
|
deleteShop: (id: number) => {
|
2026-02-27 14:20:20 +08:00
|
|
|
return adminApi.delete<boolean>(`/shops/delete/${id}`)
|
2026-02-25 14:44:50 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-25 19:07:39 +08:00
|
|
|
export interface UserVO {
|
|
|
|
|
id: number
|
|
|
|
|
shopId?: number
|
|
|
|
|
shopName?: string
|
2026-03-26 10:28:28 +08:00
|
|
|
shopIds?: Array<number | string>
|
|
|
|
|
shopNames?: string[]
|
2026-02-25 19:07:39 +08:00
|
|
|
nickname: string
|
|
|
|
|
account: string
|
|
|
|
|
avatar: string
|
2026-03-20 12:24:56 +08:00
|
|
|
phone?: string
|
2026-02-25 19:07:39 +08:00
|
|
|
signature?: string
|
|
|
|
|
level?: string
|
|
|
|
|
type: number
|
|
|
|
|
vipId?: number
|
|
|
|
|
createTime: string
|
|
|
|
|
updateTime: string
|
2026-03-20 12:24:56 +08:00
|
|
|
status?: number
|
2026-02-25 19:07:39 +08:00
|
|
|
}
|
|
|
|
|
|
2026-03-04 10:14:45 +08:00
|
|
|
export interface PageResult<T> {
|
|
|
|
|
list: T[]
|
2026-02-25 19:07:39 +08:00
|
|
|
total: number
|
|
|
|
|
page: number
|
|
|
|
|
size: number
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-04 10:14:45 +08:00
|
|
|
export const adminUserApi = {
|
2026-03-10 23:23:15 +08:00
|
|
|
listUsers: (params: { page: number; size: number; keyword?: string; type?: number; shopId?: number; status?: number }) => {
|
2026-03-20 12:24:56 +08:00
|
|
|
return adminApi.get<PageResult<UserVO>>('/user/list', { params }) as unknown as Promise<PageResult<UserVO>>
|
2026-02-25 19:38:13 +08:00
|
|
|
},
|
2026-03-04 10:14:45 +08:00
|
|
|
listAllUsers: () => {
|
2026-03-20 12:24:56 +08:00
|
|
|
return adminApi.get<UserVO[]>('/user/list/all') as unknown as Promise<UserVO[]>
|
2026-02-25 19:07:39 +08:00
|
|
|
},
|
2026-03-04 10:14:45 +08:00
|
|
|
createUser: (data: any) => {
|
2026-02-27 14:20:20 +08:00
|
|
|
return adminApi.post<number>('/user/create', data)
|
2026-02-25 19:07:39 +08:00
|
|
|
},
|
2026-03-04 10:14:45 +08:00
|
|
|
updateUser: (id: number, data: any) => {
|
2026-02-27 14:20:20 +08:00
|
|
|
return adminApi.put<boolean>(`/user/update/${id}`, data)
|
2026-02-25 19:07:39 +08:00
|
|
|
},
|
|
|
|
|
deleteUser: (id: number) => {
|
2026-02-27 14:20:20 +08:00
|
|
|
return adminApi.delete<boolean>(`/user/delete/${id}`)
|
2026-02-25 19:07:39 +08:00
|
|
|
},
|
2026-03-04 10:14:45 +08:00
|
|
|
updateUserStatus: (id: number, status: number) => {
|
|
|
|
|
return adminApi.put<boolean>(`/user/status/${id}`, { status })
|
|
|
|
|
},
|
2026-02-25 19:07:39 +08:00
|
|
|
resetPassword: (id: number) => {
|
2026-03-04 10:14:45 +08:00
|
|
|
return adminApi.post<string>(`/user/reset-password/${id}`)
|
|
|
|
|
},
|
|
|
|
|
getUserInfo: () => {
|
2026-03-20 12:24:56 +08:00
|
|
|
return adminApi.get<UserVO>('/user/info') as unknown as Promise<UserVO>
|
|
|
|
|
},
|
|
|
|
|
getUserAsset: (id: number) => {
|
|
|
|
|
return adminApi.get<UserAssetVO>(`/user/${id}/asset`) as unknown as Promise<UserAssetVO>
|
|
|
|
|
},
|
|
|
|
|
getUserBalanceHistory: (id: number) => {
|
|
|
|
|
return adminApi.get<UserBalanceHistoryItem[]>(`/user/${id}/balance/history`) as unknown as Promise<UserBalanceHistoryItem[]>
|
|
|
|
|
},
|
|
|
|
|
changeUserBalance: (id: number, data: AdminUserBalanceChangeRequest) => {
|
|
|
|
|
return adminApi.post<UserAssetVO>(`/user/${id}/balance/change`, data) as unknown as Promise<UserAssetVO>
|
|
|
|
|
},
|
|
|
|
|
overrideUserVip: (id: number, data: AdminUserVipOverrideRequest) => {
|
|
|
|
|
return adminApi.post<UserAssetVO>(`/user/${id}/vip/override`, data) as unknown as Promise<UserAssetVO>
|
|
|
|
|
},
|
|
|
|
|
recalculateUserVip: (id: number) => {
|
|
|
|
|
return adminApi.post<UserAssetVO>(`/user/${id}/vip/recalculate`) as unknown as Promise<UserAssetVO>
|
2026-02-25 19:07:39 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-20 12:24:56 +08:00
|
|
|
export interface UserAssetVO {
|
|
|
|
|
userId: number
|
|
|
|
|
nickname: string
|
|
|
|
|
balance: number
|
|
|
|
|
totalRechargeAmount: number
|
|
|
|
|
lastRechargeTime?: string
|
|
|
|
|
vipInfoId?: number
|
|
|
|
|
vipLevel: string
|
|
|
|
|
benefitId?: number
|
|
|
|
|
benefitInfo?: string
|
|
|
|
|
manualOverride: boolean
|
|
|
|
|
vipStartTime?: string
|
|
|
|
|
vipExpireTime?: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface UserBalanceHistoryItem {
|
|
|
|
|
id: number
|
|
|
|
|
userId: number
|
|
|
|
|
userNickname?: string
|
|
|
|
|
amount: number
|
|
|
|
|
type?: string
|
|
|
|
|
currentBalance?: number
|
|
|
|
|
beforeBalance?: number
|
|
|
|
|
afterBalance?: number
|
|
|
|
|
changeScene?: string
|
|
|
|
|
relatedOrderId?: number
|
|
|
|
|
relatedOrderNo?: string
|
|
|
|
|
externalOrderNo?: string
|
|
|
|
|
operatorId?: number
|
|
|
|
|
remark?: string
|
|
|
|
|
changeTime: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface AdminUserBalanceChangeRequest {
|
|
|
|
|
amount: number
|
|
|
|
|
changeScene: string
|
|
|
|
|
relatedOrderId?: number
|
|
|
|
|
externalOrderNo?: string
|
|
|
|
|
remark?: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface AdminUserVipOverrideRequest {
|
|
|
|
|
vipLevel: string
|
|
|
|
|
remark?: string
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-04 10:14:45 +08:00
|
|
|
export const userApi = adminUserApi
|
2026-02-25 19:07:39 +08:00
|
|
|
|
2026-03-04 10:14:45 +08:00
|
|
|
export interface OrderVO {
|
2026-02-26 10:21:02 +08:00
|
|
|
id: number
|
2026-03-04 10:14:45 +08:00
|
|
|
orderNo: string
|
|
|
|
|
userId: number
|
|
|
|
|
userNickname?: string
|
|
|
|
|
shopId: number
|
|
|
|
|
shopName?: string
|
|
|
|
|
artistId?: number
|
|
|
|
|
artistName?: string
|
|
|
|
|
totalAmount: number
|
|
|
|
|
discountAmount: number
|
|
|
|
|
payAmount: number
|
2026-02-26 10:21:02 +08:00
|
|
|
status: number
|
2026-03-04 10:14:45 +08:00
|
|
|
statusText?: string
|
|
|
|
|
remark?: string
|
2026-02-26 10:21:02 +08:00
|
|
|
createTime: string
|
|
|
|
|
updateTime: string
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-04 10:14:45 +08:00
|
|
|
export const adminOrderApi = {
|
|
|
|
|
listOrders: (params: { page: number; size: number; keyword?: string; status?: number; shopId?: number }) => {
|
|
|
|
|
return adminApi.get<PageResult<OrderVO>>('/order/list', { params })
|
2026-02-26 10:21:02 +08:00
|
|
|
},
|
2026-03-04 10:14:45 +08:00
|
|
|
updateOrderStatus: (id: number, status: number) => {
|
|
|
|
|
return adminApi.put<boolean>(`/order/update-status/${id}`, { status })
|
2026-02-26 10:21:02 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-04 10:14:45 +08:00
|
|
|
export interface HotProductVO {
|
2026-03-26 10:28:28 +08:00
|
|
|
id: number
|
|
|
|
|
title: string
|
|
|
|
|
price: number
|
|
|
|
|
likeCount: number
|
|
|
|
|
collectCount: number
|
2026-03-04 10:14:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface RecentActivityVO {
|
2026-02-26 17:54:18 +08:00
|
|
|
id: number
|
2026-03-04 10:14:45 +08:00
|
|
|
type: string
|
2026-03-26 10:28:28 +08:00
|
|
|
title?: string
|
2026-02-26 17:54:18 +08:00
|
|
|
description: string
|
2026-03-04 10:14:45 +08:00
|
|
|
time: string
|
2026-03-10 23:23:15 +08:00
|
|
|
color?: string
|
2026-02-26 17:54:18 +08:00
|
|
|
}
|
|
|
|
|
|
2026-03-04 10:14:45 +08:00
|
|
|
export interface DashboardStats {
|
|
|
|
|
totalUsers: number
|
|
|
|
|
totalProducts: number
|
|
|
|
|
totalShops: number
|
|
|
|
|
todayOrders: number
|
|
|
|
|
hotProducts: HotProductVO[]
|
|
|
|
|
recentActivities: RecentActivityVO[]
|
2026-02-25 19:07:39 +08:00
|
|
|
}
|
|
|
|
|
|
2026-03-04 10:14:45 +08:00
|
|
|
export const adminDashboardApi = {
|
|
|
|
|
getStats: () => {
|
|
|
|
|
return adminApi.get<DashboardStats>('/dashboard/stats')
|
2026-02-26 15:39:39 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-04 15:42:43 +08:00
|
|
|
export interface NailArtistInfoVO {
|
|
|
|
|
id: number
|
|
|
|
|
userId: number
|
|
|
|
|
identity: string
|
|
|
|
|
experience: number
|
|
|
|
|
skills: string
|
|
|
|
|
rating: number
|
|
|
|
|
status: number
|
|
|
|
|
portfolio: string
|
|
|
|
|
nickname: string
|
|
|
|
|
shopId: number
|
|
|
|
|
shopName: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const adminNailArtistApi = {
|
|
|
|
|
listNailArtists: () => {
|
|
|
|
|
return adminApi.get<NailArtistInfoVO[]>('/nail-artist/list')
|
|
|
|
|
},
|
|
|
|
|
getNailArtistInfo: (userId: number) => {
|
|
|
|
|
return adminApi.get<NailArtistInfoVO>(`/nail-artist/get/${userId}`)
|
|
|
|
|
},
|
|
|
|
|
saveNailArtistInfo: (data: any) => {
|
|
|
|
|
return adminApi.post<NailArtistInfoVO>('/nail-artist/save', data)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-04 10:14:45 +08:00
|
|
|
export { adminApi }
|
2026-02-27 11:05:15 +08:00
|
|
|
export default adminApi
|