/** * Front-end API wrapper for this module. * Call guide: import the named API object, then call the matching method from a Vue page or composable. */ import axios, { AxiosError, type AxiosProgressEvent } from 'axios' import { message } from 'ant-design-vue' import { ADMIN_API_BASE_URL } from '../config/api' import type { IdType } from '@/utils/id' import { clearAdminSessionStorage } from '@/utils/admin-session' import { attachRequestSignature } from '@/utils/request-signature' import { isAdminApiAuthFreePath } from './auth-free-paths' let lastErrorTime = 0 let lastErrorMessage = '' const ERROR_DEBOUNCE_TIME = 1000 const adminApi = axios.create({ baseURL: ADMIN_API_BASE_URL, timeout: 10000, headers: { 'Content-Type': 'application/json' } }) 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 getStoredAdminAccessToken = () => { return localStorage.getItem('adminAccessToken') || sessionStorage.getItem('adminAccessToken') } const getRequestToken = (request: any) => { if (request?._authToken) { return request._authToken as string } const authHeader = request?.headers?.Authorization || request?.headers?.authorization if (typeof authHeader !== 'string') { return null } return authHeader.startsWith('Bearer ') ? authHeader.slice('Bearer '.length) : null } const isCurrentStoredAdminToken = (token: string | null) => { return Boolean(token && token === getStoredAdminAccessToken()) } 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 isAdminApiAuthFreePath(url) } const handleAdminTokenExpired = (failedToken: string | null = null) => { if (!isCurrentStoredAdminToken(failedToken)) { return } clearAdminSessionStorage() if (Date.now() - lastErrorTime > ERROR_DEBOUNCE_TIME || lastErrorMessage !== '登录已过期,请重新登录') { showError('登录已过期,请重新登录') } setTimeout(() => { window.location.href = '/admin/login' }, 300) } adminApi.interceptors.request.use( async config => { let token: string | null = null if (!isAuthFreePath(config.url)) { token = getStoredAdminAccessToken() if (token) { config.headers.Authorization = `Bearer ${token}` } } ;(config as any)._authToken = token || null return attachRequestSignature(config, token, { authFree: isAuthFreePath(config.url) }) }, error => Promise.reject(error) ) adminApi.interceptors.response.use( response => { const res = response.data if (res.code !== 200) { const errorMsg = res.message || '请求失败' if (!errorMsg.includes('权限') && !errorMsg.includes('permission')) { showError(errorMsg) } else { console.error('权限不足:', errorMsg) } return Promise.reject(new Error(errorMsg)) } return res.data as any }, async (error: AxiosError) => { const originalRequest = error.config as any if (error.response?.status === 401) { const requestToken = getRequestToken(originalRequest) if (!isCurrentStoredAdminToken(requestToken)) { return Promise.reject(error) } 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) }) } 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(requestToken) return Promise.reject(refreshError) } finally { isRefreshing = false } } handleAdminTokenExpired(requestToken) } else if (error.response?.status !== 403) { const errorMsg = (error.response?.data as any)?.message || error.message || '请求失败' showError(errorMsg) } else { console.error('权限不足:', error) } if (error.response?.status === 403) { const errorMsg = (error.response?.data as any)?.message || '权限不足' console.error('Admin API Permission Error:', errorMsg) return Promise.reject(new Error(errorMsg)) } console.error('Admin API Error:', error) return Promise.reject(error) } ) export interface AdminLoginRequest { account: string password: string shopId?: IdType } export interface AdminLoginResponse { accessToken: string refreshToken: string userInfo: any } export interface LoginShopSelectionResponse { allowShoplessLogin: boolean message: string shops: Array<{ id: IdType shopName: string }> } export interface LegalAgreementAdminVO { id: IdType agreementType: 'USER_TERMS' | 'PRIVACY_POLICY' agreementTypeName?: string title: string version: string content: string status: number statusText?: string effectiveTime?: string createTime?: string updateTime?: string } export interface LegalAgreementAdminRequest { agreementType: 'USER_TERMS' | 'PRIVACY_POLICY' title: string version: string content: string } /** * adminAuthApi groups all API calls for this page domain. * Call guide: pass the typed payload or identifier into the method below, and use the returned Promise in the page script. */ export const adminAuthApi = { /** * `login` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param data: AdminLoginRequest caller-supplied value for `data: AdminLoginRequest` */ login: (data: AdminLoginRequest) => { return adminApi.post('/auth/login', data) }, /** * `getLoginShops` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param account: string caller-supplied value for `account: string` */ getLoginShops: (account: string) => { return adminApi.get(`/auth/login-shops/${encodeURIComponent(account)}`) }, /** * `logout` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. */ logout: () => { return adminApi.post('/auth/logout') }, /** * `switchShop` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param shopId?: IdType caller-supplied value for `shopId?: IdType` */ switchShop: (shopId?: IdType) => { return adminApi.post('/auth/switch-shop', { shopId }) }, /** * `refreshToken` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param refreshToken: string caller-supplied value for `refreshToken: string` */ refreshToken: (refreshToken: string) => { return adminApi.post<{ accessToken: string; refreshToken: string }>('/auth/refresh', { refreshToken }) } } export const adminLegalAgreementApi = { list: () => adminApi.get('/legal-agreement/list'), create: (data: LegalAgreementAdminRequest) => adminApi.post('/legal-agreement/create', data), update: (id: IdType, data: LegalAgreementAdminRequest) => adminApi.put(`/legal-agreement/${id}`, data), publish: (id: IdType) => adminApi.put(`/legal-agreement/${id}/publish`), disable: (id: IdType) => adminApi.put(`/legal-agreement/${id}/disable`) } export interface ObjectStorageFileVO { id: IdType fileName: string fileSize: number contentType: string createTime: string } export interface ChunkUploadInitRequest { fileName: string fileSize: number contentType: string fileFingerprint: string scene: string } export interface ChunkUploadSessionVO { uploadId: string chunkSize: number totalChunks: number uploadedChunks: number[] } /** * adminFileApi groups all API calls for this page domain. * Call guide: pass the typed payload or identifier into the method below, and use the returned Promise in the page script. */ export const adminFileApi = { /** * `uploadFile` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param file: File caller-supplied value for `file: File` */ uploadFile: (file: File) => { const formData = new FormData() formData.append('file', file) return adminApi.post('/object-storage-file/upload', formData, { headers: { 'Content-Type': 'multipart/form-data' } }) as unknown as Promise }, /** * `initChunkUpload` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param data: ChunkUploadInitRequest caller-supplied value for `data: ChunkUploadInitRequest` */ initChunkUpload: (data: ChunkUploadInitRequest) => { return adminApi.post('/object-storage-file/upload/init', data) as unknown as Promise }, uploadChunk: ( data: { uploadId: string; chunkIndex: number; totalChunks: number; chunk: Blob }, config?: { signal?: AbortSignal; onUploadProgress?: (event: AxiosProgressEvent) => void } ) => { const formData = new FormData() formData.append('uploadId', data.uploadId) formData.append('chunkIndex', String(data.chunkIndex)) formData.append('totalChunks', String(data.totalChunks)) formData.append('chunk', data.chunk) return adminApi.post('/object-storage-file/upload/chunk', formData, { headers: { 'Content-Type': 'multipart/form-data' }, signal: config?.signal, onUploadProgress: config?.onUploadProgress }) }, /** * `completeChunkUpload` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param uploadId: string caller-supplied value for `uploadId: string` */ completeChunkUpload: (uploadId: string) => { return adminApi.post('/object-storage-file/upload/complete', { uploadId }) as unknown as Promise }, /** * `cancelChunkUpload` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param uploadId: string caller-supplied value for `uploadId: string` */ cancelChunkUpload: (uploadId: string) => { return adminApi.delete(`/object-storage-file/upload/${uploadId}`) }, /** * `getSignedUrl` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param id: IdType caller-supplied value for `id: IdType` */ getSignedUrl: (id: IdType) => { return adminApi.get(`/object-storage-file/get-signed-url/${id}`) as unknown as Promise } } export interface Tag { id: IdType tagName: string textColor?: string bgColor?: string borderColor?: string shopId?: IdType shopName?: string type?: number typeName?: string createTime: string updateTime: string } /** * adminTagApi groups all API calls for this page domain. * Call guide: pass the typed payload or identifier into the method below, and use the returned Promise in the page script. */ export const adminTagApi = { /** * `listAllTags` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. */ listAllTags: () => { return adminApi.get('/tag/list/all') as unknown as Promise }, /** * `listTagsByShopId` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param shopId: IdType caller-supplied value for `shopId: IdType` */ listTagsByShopId: (shopId: IdType) => { return adminApi.get(`/tag/list/by-shop/${shopId}`) as unknown as Promise }, /** * `createTag` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param data: { tagName: string; textColor?: string; bgColor?: string; borderColor?: string; shopId?: IdType } caller-supplied value for `data: { tagName: string; textColor?: string; bgColor?: string; borderColor?: string; shopId?: IdType }` */ createTag: (data: { tagName: string; textColor?: string; bgColor?: string; borderColor?: string; shopId?: IdType }) => { return adminApi.post('/tag/create', data) }, /** * `updateTag` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param id: IdType caller-supplied value for `id: IdType` * @param data: { tagName: string; textColor?: string; bgColor?: string; borderColor?: string; shopId?: IdType } caller-supplied value for `data: { tagName: string; textColor?: string; bgColor?: string; borderColor?: string; shopId?: IdType }` */ updateTag: (id: IdType, data: { tagName: string; textColor?: string; bgColor?: string; borderColor?: string; shopId?: IdType }) => { return adminApi.put(`/tag/update/${id}`, data) }, /** * `deleteTag` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param id: IdType caller-supplied value for `id: IdType` */ deleteTag: (id: IdType) => { return adminApi.delete(`/tag/delete/${id}`) } } export interface Artist { id: IdType nickname: string account: string avatar?: string shopId?: IdType shopName?: string createTime: string updateTime: string } /** * adminArtistApi groups all API calls for this page domain. * Call guide: pass the typed payload or identifier into the method below, and use the returned Promise in the page script. */ export const adminArtistApi = { /** * `listArtists` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param shopId?: IdType caller-supplied value for `shopId?: IdType` */ listArtists: (shopId?: IdType) => { const params: any = {} if (shopId) { params.shopId = shopId } return adminApi.get('/user/list/artists', { params }) } } export interface Coupon { id: IdType couponCode?: string couponName: string couponType: number couponTypeName?: string discountValue?: string minAmount?: number reduceAmount?: string totalCount?: number usedCount?: number remainingCount?: number startTime: string endTime: string status?: number statusName?: string shopId?: IdType shopName?: string couponScene?: string requiredVipLevel?: string autoMatch?: number availableTags?: Tag[] unavailableTags?: Tag[] createTime: string updateTime: string } /** * adminCouponApi groups all API calls for this page domain. * Call guide: pass the typed payload or identifier into the method below, and use the returned Promise in the page script. */ export const adminCouponApi = { /** * `listAllCoupons` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param shopId?: IdType caller-supplied value for `shopId?: IdType` */ listAllCoupons: (shopId?: IdType) => { const params = shopId ? { shopId } : {} return adminApi.get('/coupon/list/all', { params }) as unknown as Promise }, /** * `createCoupon` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param data: any caller-supplied value for `data: any` */ createCoupon: (data: any) => { return adminApi.post('/coupon/create', data) }, /** * `updateCoupon` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param id: IdType caller-supplied value for `id: IdType` * @param data: any caller-supplied value for `data: any` */ updateCoupon: (id: IdType, data: any) => { return adminApi.put(`/coupon/update/${id}`, data) }, /** * `deleteCoupon` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param id: IdType caller-supplied value for `id: IdType` */ deleteCoupon: (id: IdType) => { return adminApi.delete(`/coupon/delete/${id}`) }, /** * `distributeCoupon` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param data: any caller-supplied value for `data: any` */ distributeCoupon: (data: any) => { return adminApi.post('/coupon/distribute', null, { params: data }) } } export interface AdminCommentVO { id: IdType userId: IdType userNickname?: string shopId?: IdType shopName?: string productId?: IdType productTitle?: string commentContent: string parentCommentId?: IdType parentCommentContent?: string createTime?: string } /** * adminCommentApi groups all API calls for this page domain. * Call guide: pass the typed payload or identifier into the method below, and use the returned Promise in the page script. */ export const adminCommentApi = { /** * `listComments` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param params: { productId?: IdType; userId?: IdType; shopId?: IdType; keyword?: string } caller-supplied value for `params: { productId?: IdType; userId?: IdType; shopId?: IdType; keyword?: string }` */ listComments: (params: { productId?: IdType; userId?: IdType; shopId?: IdType; keyword?: string }) => { return adminApi.get('/comment/list', { params }) as unknown as Promise }, /** * `deleteComment` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param id: IdType caller-supplied value for `id: IdType` */ deleteComment: (id: IdType) => { return adminApi.delete(`/comment/delete/${id}`) as unknown as Promise } } export interface Product { id: IdType shopId: IdType shopName?: string title: string description: string price: number approximateDuration?: string tags?: string tagList?: string[] tagInfos?: any[] imageFileIds?: string imageUrls?: string[] bookableArtists?: string availableCoupons?: string likeCount?: number collectCount?: number createTime: string updateTime: string } /** * adminProductApi groups all API calls for this page domain. * Call guide: pass the typed payload or identifier into the method below, and use the returned Promise in the page script. */ export const adminProductApi = { /** * `listProducts` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param params: { page: number; size: number; keyword?: string; shopId?: IdType } caller-supplied value for `params: { page: number; size: number; keyword?: string; shopId?: IdType }` */ listProducts: (params: { page: number; size: number; keyword?: string; shopId?: IdType; tagId?: IdType; minPrice?: number; maxPrice?: number; createdFrom?: string; createdTo?: string }) => { return adminApi.get<{ list: Product[]; total: number; page: number; size: number }>('/product/list', { params }) }, /** * `listAllProducts` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. */ listAllProducts: () => { return adminApi.get('/product/list/all') }, /** * `createProduct` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param data: any caller-supplied value for `data: any` */ createProduct: (data: any) => { return adminApi.post('/product/create', data) }, /** * `updateProduct` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param id: IdType caller-supplied value for `id: IdType` * @param data: any caller-supplied value for `data: any` */ updateProduct: (id: IdType, data: any) => { return adminApi.put(`/product/update/${id}`, data) }, /** * `deleteProduct` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param id: IdType caller-supplied value for `id: IdType` */ deleteProduct: (id: IdType) => { return adminApi.delete(`/product/delete/${id}`) } } export interface Shop { id: IdType shopName: string description: string address: string mapProvider?: string longitude?: number | string latitude?: number | string businessHours: string status?: number coverImageFileId?: string coverImageUrls?: string[] imageFileIds?: string imageUrls?: string[] themePrimaryColor?: string themeSecondaryColor?: string themeAccentColor?: string themePageBgColor?: string themeCardBgColor?: string themeBackgroundImageFileId?: string authorizationStartDate?: string authorizationDays?: number authorizationExpireTime?: string authorizationExpired?: boolean authorizationStatusText?: string createTime: string updateTime: string } export interface ShopListResponse { list: Shop[] total: number page: number size: number } export interface CreateShopRequest { shopName: string description: string address: string mapProvider?: string longitude?: number | string latitude?: number | string businessHours: string coverImageFileId?: string imageFileIds?: string themePrimaryColor?: string themeSecondaryColor?: string themeAccentColor?: string themePageBgColor?: string themeCardBgColor?: string themeBackgroundImageFileId?: string status?: number authorizationStartDate?: string authorizationDays?: number authorizationExpireTime?: string } /** * adminShopApi groups all API calls for this page domain. * Call guide: pass the typed payload or identifier into the method below, and use the returned Promise in the page script. */ export const adminShopApi = { /** * `listShops` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param params: { page: number; size: number; keyword?: string; shopId?: IdType } caller-supplied value for `params: { page: number; size: number; keyword?: string; shopId?: IdType }` */ listShops: (params: { page: number; size: number; keyword?: string; shopId?: IdType }) => { return adminApi.get('/shops/list', { params }) as unknown as Promise }, /** * `listAllShops` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. */ listAllShops: () => { return adminApi.get('/shops/list/all') as unknown as Promise }, /** * `createShop` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param data: CreateShopRequest caller-supplied value for `data: CreateShopRequest` */ createShop: (data: CreateShopRequest) => { return adminApi.post('/shops/create', data) }, /** * `updateShop` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param id: IdType caller-supplied value for `id: IdType` * @param data: CreateShopRequest caller-supplied value for `data: CreateShopRequest` */ updateShop: (id: IdType, data: CreateShopRequest) => { return adminApi.put(`/shops/update/${id}`, data) }, /** * `updateShopStatus` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param id: IdType caller-supplied value for `id: IdType` * @param status: number caller-supplied value for `status: number` */ updateShopStatus: (id: IdType, status: number) => { return adminApi.put(`/shops/status/${id}`, { status }) } } export interface UserVO { id: IdType shopId?: IdType shopName?: string shopAuthorizationExpireTime?: string shopAuthorizationExpired?: boolean shopIds?: IdType[] shopNames?: string[] nickname: string account: string avatar: string phone?: string signature?: string level?: string type: number vipId?: IdType createTime: string updateTime: string status?: number } export interface UserRelationVO { userId: IdType shopId?: IdType shopName?: string parentUserId?: IdType parentUserName?: string parentRoleType?: number parentRoleTypeName?: string sourceType?: string sourceTypeName?: string } export interface UserStatisticsVO { totalUserCount: number normalUserCount: number employeeCount: number managerCount: number artistCount: number vipUserCount: number newUserCount: number byShop?: Record byRole?: Record byParent?: Record } export interface PageResult { list: T[] total: number page: number size: number } /** * adminUserApi groups all API calls for this page domain. * Call guide: pass the typed payload or identifier into the method below, and use the returned Promise in the page script. */ export const adminUserApi = { // 后台用户列表支持多维筛选;页面侧应优先展示 maskedPhone/maskedEmail, // 避免在列表中直接暴露完整手机号或邮箱。 /** * `listUsers` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param params: { page: number; size: number; keyword?: string; type?: number; shopId?: IdType; roleId?: IdType; parentUserId?: IdType; sourceType?: string; status?: number; vipLevel?: string; createdFrom?: string; createdTo?: string; hasPhone?: boolean; hasOrder?: boolean } caller-supplied value for `params: { page: number; size: number; keyword?: string; type?: number; shopId?: IdType; roleId?: IdType; parentUserId?: IdType; sourceType?: string; status?: number; vipLevel?: string; createdFrom?: string; createdTo?: string; hasPhone?: boolean; hasOrder?: boolean }` */ listUsers: (params: { page: number; size: number; keyword?: string; type?: number; shopId?: IdType; roleId?: IdType; parentUserId?: IdType; sourceType?: string; status?: number; vipLevel?: string; createdFrom?: string; createdTo?: string; hasPhone?: boolean; hasOrder?: boolean }) => { return adminApi.get>('/user/list', { params }) as unknown as Promise> }, /** * `getUserStatistics` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param params: { keyword?: string; type?: number; shopId?: IdType; roleId?: IdType; parentUserId?: IdType; sourceType?: string; status?: number; vipLevel?: string; createdFrom?: string; createdTo?: string; hasPhone?: boolean; hasOrder?: boolean } caller-supplied value for `params: { keyword?: string; type?: number; shopId?: IdType; roleId?: IdType; parentUserId?: IdType; sourceType?: string; status?: number; vipLevel?: string; createdFrom?: string; createdTo?: string; hasPhone?: boolean; hasOrder?: boolean }` */ getUserStatistics: (params: { keyword?: string; type?: number; shopId?: IdType; roleId?: IdType; parentUserId?: IdType; sourceType?: string; status?: number; vipLevel?: string; createdFrom?: string; createdTo?: string; hasPhone?: boolean; hasOrder?: boolean }) => { return adminApi.get('/user/statistics', { params }) as unknown as Promise }, /** * `listAllUsers` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. */ listAllUsers: () => { return adminApi.get('/user/list/all') as unknown as Promise }, /** * `createUser` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param data: any caller-supplied value for `data: any` */ createUser: (data: any) => { return adminApi.post('/user/create', data) }, /** * `updateUser` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param id: IdType caller-supplied value for `id: IdType` * @param data: any caller-supplied value for `data: any` */ updateUser: (id: IdType, data: any) => { return adminApi.put(`/user/update/${id}`, data) }, /** * `deleteUser` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param id: IdType caller-supplied value for `id: IdType` */ deleteUser: (id: IdType) => { return adminApi.delete(`/user/delete/${id}`) }, /** * `unbindUser` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param id: IdType caller-supplied value for `id: IdType` */ unbindUser: (id: IdType) => { return adminApi.put(`/user/unbind/${id}`, {}) }, /** * `updateUserStatus` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param id: IdType caller-supplied value for `id: IdType` * @param status: number caller-supplied value for `status: number` */ updateUserStatus: (id: IdType, status: number) => { return adminApi.put(`/user/status/${id}`, { status }) }, /** * `getRelationOptions` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param shopId?: IdType caller-supplied value for `shopId?: IdType` */ getRelationOptions: (shopId?: IdType) => { return adminApi.get(`/user/relation/options`, { params: { shopId } }) as unknown as Promise }, /** * `updateUserRelation` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param id: IdType caller-supplied value for `id: IdType` * @param data: { shopId?: IdType; parentUserId?: IdType; parentRoleType?: number; sourceType?: string } caller-supplied value for `data: { shopId?: IdType; parentUserId?: IdType; parentRoleType?: number; sourceType?: string }` */ updateUserRelation: (id: IdType, data: { shopId?: IdType; parentUserId?: IdType; parentRoleType?: number; sourceType?: string }) => { return adminApi.put(`/user/${id}/relation`, data) as unknown as Promise }, /** * `resetPassword` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param id: IdType caller-supplied value for `id: IdType` */ resetPassword: (id: IdType) => { return adminApi.post(`/user/reset-password/${id}`) }, /** * `getUserInfo` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. */ getUserInfo: () => { return adminApi.get('/user/info') as unknown as Promise }, /** * `getUserAsset` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param id: IdType caller-supplied value for `id: IdType` */ getUserAsset: (id: IdType) => { return adminApi.get(`/user/${id}/asset`) as unknown as Promise }, /** * `getUserBalanceHistory` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param id: IdType caller-supplied value for `id: IdType` */ getUserBalanceHistory: (id: IdType) => { return adminApi.get(`/user/${id}/balance/history`) as unknown as Promise }, /** * `changeUserBalance` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param id: IdType caller-supplied value for `id: IdType` * @param data: AdminUserBalanceChangeRequest caller-supplied value for `data: AdminUserBalanceChangeRequest` */ changeUserBalance: (id: IdType, data: AdminUserBalanceChangeRequest) => { return adminApi.post(`/user/${id}/balance/change`, data) as unknown as Promise }, /** * `overrideUserVip` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param id: IdType caller-supplied value for `id: IdType` * @param data: AdminUserVipOverrideRequest caller-supplied value for `data: AdminUserVipOverrideRequest` */ overrideUserVip: (id: IdType, data: AdminUserVipOverrideRequest) => { return adminApi.post(`/user/${id}/vip/override`, data) as unknown as Promise }, /** * `recalculateUserVip` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param id: IdType caller-supplied value for `id: IdType` */ recalculateUserVip: (id: IdType) => { return adminApi.post(`/user/${id}/vip/recalculate`) as unknown as Promise } } export interface UserAssetVO { userId: IdType nickname: string balance: number totalRechargeAmount: number lastRechargeTime?: string vipInfoId?: IdType vipLevel: string benefitId?: IdType benefitInfo?: string manualOverride: boolean vipStartTime?: string vipExpireTime?: string } export interface UserBalanceHistoryItem { id: IdType userId: IdType userNickname?: string amount: number type?: string currentBalance?: number beforeBalance?: number afterBalance?: number changeScene?: string relatedOrderId?: IdType relatedOrderNo?: string externalOrderNo?: string operatorId?: IdType remark?: string changeTime: string } export interface AdminUserBalanceChangeRequest { amount: number changeScene: string relatedOrderId?: IdType externalOrderNo?: string remark?: string } export interface AdminUserVipOverrideRequest { vipLevel: string remark?: string } export const userApi = adminUserApi export interface OrderVO { id: IdType orderNo: string userId: IdType userNickname?: string shopId: IdType shopName?: string artistId?: IdType artistName?: string totalAmount: number actualAmount?: number discountAmount: number payAmount: number couponName?: string customerName?: string customerPhone?: string customerNickname?: string customerPhoneMasked?: string items?: Array<{ id: IdType productId: IdType productTitle?: string artistId?: IdType artistName?: string appointmentTime?: string price: number quantity: number }> status: number statusText?: string remark?: string createTime: string updateTime: string } /** * adminOrderApi groups all API calls for this page domain. * Call guide: pass the typed payload or identifier into the method below, and use the returned Promise in the page script. */ export const adminOrderApi = { /** * `listOrders` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param params: { page: number; size: number; keyword?: string; status?: number; shopId?: IdType } caller-supplied value for `params: { page: number; size: number; keyword?: string; status?: number; shopId?: IdType }` */ listOrders: (params: { page: number; size: number; keyword?: string; status?: number; shopId?: IdType }) => { return adminApi.get>('/order/list', { params }) }, /** * `updateOrderStatus` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param id: IdType caller-supplied value for `id: IdType` * @param status: number caller-supplied value for `status: number` */ updateOrderStatus: (id: IdType, status: number) => { return adminApi.put(`/order/update-status/${id}`, {}, { params: { status } }) } } export interface HotProductVO { id: IdType title: string price: number likeCount: number collectCount: number } export interface RecentActivityVO { id: IdType type: string title?: string description: string time: string color?: string } export interface DashboardStats { totalUsers: number totalProducts: number totalShops: number todayOrders: number totalOrderAmount?: number todayOrderAmount?: number weekOrderAmount?: number totalCustomers?: number totalArtists?: number newCustomersToday?: number newCustomers7Days?: number newOrders7Days?: number pendingOrders?: number completedOrders?: number hotProducts: HotProductVO[] recentActivities: RecentActivityVO[] } /** * adminDashboardApi groups all API calls for this page domain. * Call guide: pass the typed payload or identifier into the method below, and use the returned Promise in the page script. */ export const adminDashboardApi = { /** * `getStats` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. */ getStats: () => { return adminApi.get('/dashboard/stats') } } export interface NailArtistInfoVO { id: IdType userId: IdType identity: string experience: number skills: string rating: number status: number portfolio: string nickname: string shopId: IdType shopName: string userType?: number userTypeName?: string participateProduction?: number workStartTime?: string workEndTime?: string } /** * adminNailArtistApi groups all API calls for this page domain. * Call guide: pass the typed payload or identifier into the method below, and use the returned Promise in the page script. */ export const adminNailArtistApi = { /** * `listNailArtists` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. */ listNailArtists: () => { return adminApi.get('/nail-artist/list') }, /** * `getNailArtistInfo` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param userId: IdType caller-supplied value for `userId: IdType` */ getNailArtistInfo: (userId: IdType) => { return adminApi.get(`/nail-artist/get/${userId}`) }, /** * `saveNailArtistInfo` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param data: any caller-supplied value for `data: any` */ saveNailArtistInfo: (data: any) => { return adminApi.post('/nail-artist/save', data) } } export interface SystemMessageVO { id: IdType title: string content: string imageFileId?: IdType imageUrl?: string publisherId: IdType publisherName?: string publisherType: number targetType: string targetTypeName?: string targetIds?: IdType[] popupEnabled: number status: number publishTime?: string createTime?: string popupShown?: number readStatus?: number } export interface MessageTargetOptionsVO { shops: Array<{ id: IdType; shopName: string }> users: Array<{ id: IdType; nickname: string; account: string; shopId?: IdType; shopName?: string; type?: number }> } export interface SystemMessageCreateRequest { title: string content: string imageFileId?: IdType targetType: string shopIds?: IdType[] userIds?: IdType[] popupEnabled?: number } /** * adminSystemMessageApi groups all API calls for this page domain. * Call guide: pass the typed payload or identifier into the method below, and use the returned Promise in the page script. */ export const adminSystemMessageApi = { // 消息通知会进入用户“消息通知”列表;如果 popupEnabled=1, // 前端展示弹窗后必须调用 mark popup-shown,保证每人每条只弹一次。 /** * `listMessages` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. */ listMessages: () => { return adminApi.get('/system-message/admin/list') as unknown as Promise }, /** * `createMessage` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param data: SystemMessageCreateRequest caller-supplied value for `data: SystemMessageCreateRequest` */ createMessage: (data: SystemMessageCreateRequest) => { return adminApi.post('/system-message/admin/create', data) }, /** * `revokeMessage` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param id: IdType caller-supplied value for `id: IdType` */ revokeMessage: (id: IdType) => { return adminApi.put(`/system-message/admin/${id}/revoke`) }, /** * `getTargetOptions` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. */ getTargetOptions: () => { return adminApi.get('/system-message/admin/target-options') as unknown as Promise } } export interface AnnouncementVO { id: IdType title: string content: string publisherId?: IdType publisherName?: string publisherType?: number targetType: string targetTypeName?: string targetIds?: IdType[] status: number sortOrder?: number publishTime?: string createTime?: string } export interface AnnouncementCreateRequest { title: string content: string targetType: string shopIds?: IdType[] userIds?: IdType[] sortOrder?: number } /** * adminAnnouncementApi groups all API calls for this page domain. * Call guide: pass the typed payload or identifier into the method below, and use the returned Promise in the page script. */ export const adminAnnouncementApi = { // 公告只在首页顶部滚动显示,不写入消息已读/未读状态。 /** * `listAnnouncements` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. */ listAnnouncements: () => { return adminApi.get('/announcement/admin/list') as unknown as Promise }, /** * `createAnnouncement` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param data: AnnouncementCreateRequest caller-supplied value for `data: AnnouncementCreateRequest` */ createAnnouncement: (data: AnnouncementCreateRequest) => { return adminApi.post('/announcement/admin/create', data) }, /** * `revokeAnnouncement` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param id: IdType caller-supplied value for `id: IdType` */ revokeAnnouncement: (id: IdType) => { return adminApi.put(`/announcement/admin/${id}/revoke`) }, /** * `getTargetOptions` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. */ getTargetOptions: () => { return adminApi.get('/announcement/admin/target-options') as unknown as Promise } } export interface VipRechargePlanVO { id: IdType shopId: IdType shopName?: string title: string rechargeAmount: number giftAmount: number vipLevel: string description?: string sortOrder?: number status: number createTime?: string updateTime?: string } export interface VipRechargePlanRequest { shopId?: IdType title: string rechargeAmount: number giftAmount: number vipLevel: string description?: string sortOrder?: number status?: number } /** * adminVipRechargePlanApi groups all API calls for this page domain. * Call guide: pass the typed payload or identifier into the method below, and use the returned Promise in the page script. */ export const adminVipRechargePlanApi = { /** * `listPlans` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param shopId?: IdType caller-supplied value for `shopId?: IdType` */ listPlans: (shopId?: IdType) => { const params = shopId ? { shopId } : {} return adminApi.get('/vip-recharge-plan/admin/list', { params }) as unknown as Promise }, /** * `createPlan` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param data: VipRechargePlanRequest caller-supplied value for `data: VipRechargePlanRequest` */ createPlan: (data: VipRechargePlanRequest) => { return adminApi.post('/vip-recharge-plan/admin/create', data) }, /** * `updatePlan` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param id: IdType caller-supplied value for `id: IdType` * @param data: VipRechargePlanRequest caller-supplied value for `data: VipRechargePlanRequest` */ updatePlan: (id: IdType, data: VipRechargePlanRequest) => { return adminApi.put(`/vip-recharge-plan/admin/${id}`, data) }, /** * `updateStatus` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param id: IdType caller-supplied value for `id: IdType` * @param status: number caller-supplied value for `status: number` */ updateStatus: (id: IdType, status: number) => { return adminApi.put(`/vip-recharge-plan/admin/${id}/status`, null, { params: { status } }) }, /** * `listVipLevelOptions` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param shopId?: IdType caller-supplied value for `shopId?: IdType` */ listVipLevelOptions: (shopId?: IdType) => { const params = shopId ? { shopId } : {} return adminApi.get('/vip-recharge-plan/admin/vip-level-options', { params }) as unknown as Promise } } export interface MessageHubPushConfigVO { id: IdType sceneCode: string sceneName: string platform: string msgType: string queueName: string sourceSystem: string templateCode: string channelId?: IdType sendMethod?: string enabled: number remark?: string createTime?: string updateTime?: string } export interface MessageHubPushConfigRequest { sceneCode: string sceneName: string platform: string msgType: string queueName: string sourceSystem: string templateCode: string channelId?: IdType sendMethod?: string enabled?: number remark?: string } /** * adminMessageHubPushConfigApi groups all API calls for this page domain. * Call guide: pass the typed payload or identifier into the method below, and use the returned Promise in the page script. */ export const adminMessageHubPushConfigApi = { /** * `listConfigs` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. */ listConfigs: () => { return adminApi.get('/messagehub-push-config/admin/list') as unknown as Promise }, /** * `createConfig` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param data: MessageHubPushConfigRequest caller-supplied value for `data: MessageHubPushConfigRequest` */ createConfig: (data: MessageHubPushConfigRequest) => { return adminApi.post('/messagehub-push-config/admin/create', data) }, /** * `updateConfig` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param id: IdType caller-supplied value for `id: IdType` * @param data: MessageHubPushConfigRequest caller-supplied value for `data: MessageHubPushConfigRequest` */ updateConfig: (id: IdType, data: MessageHubPushConfigRequest) => { return adminApi.put(`/messagehub-push-config/admin/${id}`, data) }, /** * `updateStatus` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param id: IdType caller-supplied value for `id: IdType` * @param enabled: number caller-supplied value for `enabled: number` */ updateStatus: (id: IdType, enabled: number) => { return adminApi.put(`/messagehub-push-config/admin/${id}/status`, null, { params: { enabled } }) }, /** * `testConfig` API call. Use this method from the page script to invoke the backend endpoint tied to this feature. * Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller. * @param id: IdType caller-supplied value for `id: IdType` * @param phone: string caller-supplied value for `phone: string` */ testConfig: (id: IdType, phone: string) => { return adminApi.post(`/messagehub-push-config/admin/${id}/test`, { phone }) } } export interface SystemParameterConfigVO { id?: IdType configGroup: string configKey: string configName: string configValue: string enabled: number remark?: string createTime?: string updateTime?: string } export const adminSystemParameterConfigApi = { listConfigs: (configGroup?: string) => { return adminApi.get('/system-parameter-config/admin/list', { params: { configGroup } }) as unknown as Promise }, saveConfig: (data: SystemParameterConfigVO) => { return adminApi.post('/system-parameter-config/admin/save', data) }, getTencentMapKey: () => { return adminApi.get<{ key: string }>('/system-parameter-config/admin/tencent-map') as unknown as Promise<{ key: string }> }, getMapConfig: () => { return adminApi.get<{ provider: 'TENCENT' | 'AMAP'; tencentWebKey?: string; amapWebKey?: string; amapMiniKey?: string }>('/system-parameter-config/admin/map-config') as unknown as Promise<{ provider: 'TENCENT' | 'AMAP'; tencentWebKey?: string; amapWebKey?: string; amapMiniKey?: string }> } } export { adminApi } export default adminApi