修复:全局治理雪花ID精度问题

This commit is contained in:
xiaowang
2026-03-27 14:55:41 +08:00
parent 824e35366a
commit d2b63e0c71
34 changed files with 459 additions and 255 deletions
+70 -69
View File
@@ -2,6 +2,7 @@ import axios, { AxiosError, type AxiosProgressEvent } from 'axios'
import router from '../router' import router from '../router'
import { message } from 'ant-design-vue' import { message } from 'ant-design-vue'
import { ADMIN_API_BASE_URL } from '../config/api' import { ADMIN_API_BASE_URL } from '../config/api'
import type { IdType } from '@/utils/id'
let lastErrorTime = 0 let lastErrorTime = 0
let lastErrorMessage = '' let lastErrorMessage = ''
@@ -169,7 +170,7 @@ adminApi.interceptors.response.use(
export interface AdminLoginRequest { export interface AdminLoginRequest {
account: string account: string
password: string password: string
shopId?: string | number shopId?: IdType
} }
export interface AdminLoginResponse { export interface AdminLoginResponse {
@@ -182,7 +183,7 @@ export interface LoginShopSelectionResponse {
allowShoplessLogin: boolean allowShoplessLogin: boolean
message: string message: string
shops: Array<{ shops: Array<{
id: number | string id: IdType
shopName: string shopName: string
}> }>
} }
@@ -197,7 +198,7 @@ export const adminAuthApi = {
logout: () => { logout: () => {
return adminApi.post<boolean>('/auth/logout') return adminApi.post<boolean>('/auth/logout')
}, },
switchShop: (shopId?: string | number) => { switchShop: (shopId?: IdType) => {
return adminApi.post<AdminLoginResponse>('/auth/switch-shop', { shopId }) return adminApi.post<AdminLoginResponse>('/auth/switch-shop', { shopId })
}, },
refreshToken: (refreshToken: string) => { refreshToken: (refreshToken: string) => {
@@ -206,7 +207,7 @@ export const adminAuthApi = {
} }
export interface ObjectStorageFileVO { export interface ObjectStorageFileVO {
id: number id: IdType
fileName: string fileName: string
fileSize: number fileSize: number
contentType: string contentType: string
@@ -264,18 +265,18 @@ export const adminFileApi = {
cancelChunkUpload: (uploadId: string) => { cancelChunkUpload: (uploadId: string) => {
return adminApi.delete<boolean>(`/object-storage-file/upload/${uploadId}`) return adminApi.delete<boolean>(`/object-storage-file/upload/${uploadId}`)
}, },
getSignedUrl: (id: number) => { getSignedUrl: (id: IdType) => {
return adminApi.get<string>(`/object-storage-file/get-signed-url/${id}`) return adminApi.get<string>(`/object-storage-file/get-signed-url/${id}`)
} }
} }
export interface Tag { export interface Tag {
id: number id: IdType
tagName: string tagName: string
textColor?: string textColor?: string
bgColor?: string bgColor?: string
borderColor?: string borderColor?: string
shopId?: number shopId?: IdType
shopName?: string shopName?: string
createTime: string createTime: string
updateTime: string updateTime: string
@@ -285,33 +286,33 @@ export const adminTagApi = {
listAllTags: () => { listAllTags: () => {
return adminApi.get<Tag[]>('/tag/list/all') as unknown as Promise<Tag[]> return adminApi.get<Tag[]>('/tag/list/all') as unknown as Promise<Tag[]>
}, },
listTagsByShopId: (shopId: number) => { listTagsByShopId: (shopId: IdType) => {
return adminApi.get<Tag[]>(`/tag/list/by-shop/${shopId}`) as unknown as Promise<Tag[]> return adminApi.get<Tag[]>(`/tag/list/by-shop/${shopId}`) as unknown as Promise<Tag[]>
}, },
createTag: (data: { tagName: string; textColor?: string; bgColor?: string; borderColor?: string; shopId?: number }) => { createTag: (data: { tagName: string; textColor?: string; bgColor?: string; borderColor?: string; shopId?: IdType }) => {
return adminApi.post<number>('/tag/create', data) return adminApi.post<IdType>('/tag/create', data)
}, },
updateTag: (id: number, data: { tagName: string; textColor?: string; bgColor?: string; borderColor?: string; shopId?: number }) => { updateTag: (id: IdType, data: { tagName: string; textColor?: string; bgColor?: string; borderColor?: string; shopId?: IdType }) => {
return adminApi.put<boolean>(`/tag/update/${id}`, data) return adminApi.put<boolean>(`/tag/update/${id}`, data)
}, },
deleteTag: (id: number) => { deleteTag: (id: IdType) => {
return adminApi.delete<boolean>(`/tag/delete/${id}`) return adminApi.delete<boolean>(`/tag/delete/${id}`)
} }
} }
export interface Artist { export interface Artist {
id: number id: IdType
nickname: string nickname: string
account: string account: string
avatar?: string avatar?: string
shopId?: number shopId?: IdType
shopName?: string shopName?: string
createTime: string createTime: string
updateTime: string updateTime: string
} }
export const adminArtistApi = { export const adminArtistApi = {
listArtists: (shopId?: number) => { listArtists: (shopId?: IdType) => {
const params: any = {} const params: any = {}
if (shopId) { if (shopId) {
params.shopId = shopId params.shopId = shopId
@@ -321,7 +322,7 @@ export const adminArtistApi = {
} }
export interface Coupon { export interface Coupon {
id: number id: IdType
couponCode?: string couponCode?: string
couponName: string couponName: string
couponType: number couponType: number
@@ -336,7 +337,7 @@ export interface Coupon {
endTime: string endTime: string
status?: number status?: number
statusName?: string statusName?: string
shopId?: number shopId?: IdType
shopName?: string shopName?: string
couponScene?: string couponScene?: string
requiredVipLevel?: string requiredVipLevel?: string
@@ -348,17 +349,17 @@ export interface Coupon {
} }
export const adminCouponApi = { export const adminCouponApi = {
listAllCoupons: (shopId?: number) => { listAllCoupons: (shopId?: IdType) => {
const params = shopId ? { shopId } : {} const params = shopId ? { shopId } : {}
return adminApi.get<Coupon[]>('/coupon/list/all', { params }) as unknown as Promise<Coupon[]> return adminApi.get<Coupon[]>('/coupon/list/all', { params }) as unknown as Promise<Coupon[]>
}, },
createCoupon: (data: any) => { createCoupon: (data: any) => {
return adminApi.post<number>('/coupon/create', data) return adminApi.post<IdType>('/coupon/create', data)
}, },
updateCoupon: (id: number, data: any) => { updateCoupon: (id: IdType, data: any) => {
return adminApi.put<boolean>(`/coupon/update/${id}`, data) return adminApi.put<boolean>(`/coupon/update/${id}`, data)
}, },
deleteCoupon: (id: number) => { deleteCoupon: (id: IdType) => {
return adminApi.delete<boolean>(`/coupon/delete/${id}`) return adminApi.delete<boolean>(`/coupon/delete/${id}`)
}, },
distributeCoupon: (data: any) => { distributeCoupon: (data: any) => {
@@ -367,8 +368,8 @@ export const adminCouponApi = {
} }
export interface Product { export interface Product {
id: number id: IdType
shopId: number shopId: IdType
shopName?: string shopName?: string
title: string title: string
description: string description: string
@@ -388,25 +389,25 @@ export interface Product {
} }
export const adminProductApi = { export const adminProductApi = {
listProducts: (params: { page: number; size: number; keyword?: string; shopId?: number }) => { listProducts: (params: { page: number; size: number; keyword?: string; shopId?: IdType }) => {
return adminApi.get<{ list: Product[]; total: number; page: number; size: number }>('/product/list', { params }) return adminApi.get<{ list: Product[]; total: number; page: number; size: number }>('/product/list', { params })
}, },
listAllProducts: () => { listAllProducts: () => {
return adminApi.get<Product[]>('/product/list/all') return adminApi.get<Product[]>('/product/list/all')
}, },
createProduct: (data: any) => { createProduct: (data: any) => {
return adminApi.post<number>('/product/create', data) return adminApi.post<IdType>('/product/create', data)
}, },
updateProduct: (id: number, data: any) => { updateProduct: (id: IdType, data: any) => {
return adminApi.put<boolean>(`/product/update/${id}`, data) return adminApi.put<boolean>(`/product/update/${id}`, data)
}, },
deleteProduct: (id: number) => { deleteProduct: (id: IdType) => {
return adminApi.delete<boolean>(`/product/delete/${id}`) return adminApi.delete<boolean>(`/product/delete/${id}`)
} }
} }
export interface Shop { export interface Shop {
id: number id: IdType
shopName: string shopName: string
description: string description: string
address: string address: string
@@ -438,31 +439,31 @@ export interface CreateShopRequest {
} }
export const adminShopApi = { export const adminShopApi = {
listShops: (params: { page: number; size: number; keyword?: string; shopId?: number }) => { listShops: (params: { page: number; size: number; keyword?: string; shopId?: IdType }) => {
return adminApi.get<ShopListResponse>('/shops/list', { params }) as unknown as Promise<ShopListResponse> return adminApi.get<ShopListResponse>('/shops/list', { params }) as unknown as Promise<ShopListResponse>
}, },
listAllShops: () => { listAllShops: () => {
return adminApi.get<Shop[]>('/shops/list/all') as unknown as Promise<Shop[]> return adminApi.get<Shop[]>('/shops/list/all') as unknown as Promise<Shop[]>
}, },
createShop: (data: CreateShopRequest) => { createShop: (data: CreateShopRequest) => {
return adminApi.post<number>('/shops/create', data) return adminApi.post<IdType>('/shops/create', data)
}, },
updateShop: (id: number, data: CreateShopRequest) => { updateShop: (id: IdType, data: CreateShopRequest) => {
return adminApi.put<boolean>(`/shops/update/${id}`, data) return adminApi.put<boolean>(`/shops/update/${id}`, data)
}, },
updateShopStatus: (id: number, status: number) => { updateShopStatus: (id: IdType, status: number) => {
return adminApi.put<boolean>(`/shops/status/${id}`, { status }) return adminApi.put<boolean>(`/shops/status/${id}`, { status })
}, },
deleteShop: (id: number) => { deleteShop: (id: IdType) => {
return adminApi.delete<boolean>(`/shops/delete/${id}`) return adminApi.delete<boolean>(`/shops/delete/${id}`)
} }
} }
export interface UserVO { export interface UserVO {
id: number id: IdType
shopId?: number shopId?: IdType
shopName?: string shopName?: string
shopIds?: Array<number | string> shopIds?: IdType[]
shopNames?: string[] shopNames?: string[]
nickname: string nickname: string
account: string account: string
@@ -471,7 +472,7 @@ export interface UserVO {
signature?: string signature?: string
level?: string level?: string
type: number type: number
vipId?: number vipId?: IdType
createTime: string createTime: string
updateTime: string updateTime: string
status?: number status?: number
@@ -485,59 +486,59 @@ export interface PageResult<T> {
} }
export const adminUserApi = { export const adminUserApi = {
listUsers: (params: { page: number; size: number; keyword?: string; type?: number; shopId?: number; status?: number }) => { listUsers: (params: { page: number; size: number; keyword?: string; type?: number; shopId?: IdType; status?: number }) => {
return adminApi.get<PageResult<UserVO>>('/user/list', { params }) as unknown as Promise<PageResult<UserVO>> return adminApi.get<PageResult<UserVO>>('/user/list', { params }) as unknown as Promise<PageResult<UserVO>>
}, },
listAllUsers: () => { listAllUsers: () => {
return adminApi.get<UserVO[]>('/user/list/all') as unknown as Promise<UserVO[]> return adminApi.get<UserVO[]>('/user/list/all') as unknown as Promise<UserVO[]>
}, },
createUser: (data: any) => { createUser: (data: any) => {
return adminApi.post<number>('/user/create', data) return adminApi.post<IdType>('/user/create', data)
}, },
updateUser: (id: number, data: any) => { updateUser: (id: IdType, data: any) => {
return adminApi.put<boolean>(`/user/update/${id}`, data) return adminApi.put<boolean>(`/user/update/${id}`, data)
}, },
deleteUser: (id: number) => { deleteUser: (id: IdType) => {
return adminApi.delete<boolean>(`/user/delete/${id}`) return adminApi.delete<boolean>(`/user/delete/${id}`)
}, },
unbindUser: (id: number) => { unbindUser: (id: IdType) => {
return adminApi.put<boolean>(`/user/unbind/${id}`, {}) return adminApi.put<boolean>(`/user/unbind/${id}`, {})
}, },
updateUserStatus: (id: number, status: number) => { updateUserStatus: (id: IdType, status: number) => {
return adminApi.put<boolean>(`/user/status/${id}`, { status }) return adminApi.put<boolean>(`/user/status/${id}`, { status })
}, },
resetPassword: (id: number) => { resetPassword: (id: IdType) => {
return adminApi.post<string>(`/user/reset-password/${id}`) return adminApi.post<string>(`/user/reset-password/${id}`)
}, },
getUserInfo: () => { getUserInfo: () => {
return adminApi.get<UserVO>('/user/info') as unknown as Promise<UserVO> return adminApi.get<UserVO>('/user/info') as unknown as Promise<UserVO>
}, },
getUserAsset: (id: number) => { getUserAsset: (id: IdType) => {
return adminApi.get<UserAssetVO>(`/user/${id}/asset`) as unknown as Promise<UserAssetVO> return adminApi.get<UserAssetVO>(`/user/${id}/asset`) as unknown as Promise<UserAssetVO>
}, },
getUserBalanceHistory: (id: number) => { getUserBalanceHistory: (id: IdType) => {
return adminApi.get<UserBalanceHistoryItem[]>(`/user/${id}/balance/history`) as unknown as Promise<UserBalanceHistoryItem[]> return adminApi.get<UserBalanceHistoryItem[]>(`/user/${id}/balance/history`) as unknown as Promise<UserBalanceHistoryItem[]>
}, },
changeUserBalance: (id: number, data: AdminUserBalanceChangeRequest) => { changeUserBalance: (id: IdType, data: AdminUserBalanceChangeRequest) => {
return adminApi.post<UserAssetVO>(`/user/${id}/balance/change`, data) as unknown as Promise<UserAssetVO> return adminApi.post<UserAssetVO>(`/user/${id}/balance/change`, data) as unknown as Promise<UserAssetVO>
}, },
overrideUserVip: (id: number, data: AdminUserVipOverrideRequest) => { overrideUserVip: (id: IdType, data: AdminUserVipOverrideRequest) => {
return adminApi.post<UserAssetVO>(`/user/${id}/vip/override`, data) as unknown as Promise<UserAssetVO> return adminApi.post<UserAssetVO>(`/user/${id}/vip/override`, data) as unknown as Promise<UserAssetVO>
}, },
recalculateUserVip: (id: number) => { recalculateUserVip: (id: IdType) => {
return adminApi.post<UserAssetVO>(`/user/${id}/vip/recalculate`) as unknown as Promise<UserAssetVO> return adminApi.post<UserAssetVO>(`/user/${id}/vip/recalculate`) as unknown as Promise<UserAssetVO>
} }
} }
export interface UserAssetVO { export interface UserAssetVO {
userId: number userId: IdType
nickname: string nickname: string
balance: number balance: number
totalRechargeAmount: number totalRechargeAmount: number
lastRechargeTime?: string lastRechargeTime?: string
vipInfoId?: number vipInfoId?: IdType
vipLevel: string vipLevel: string
benefitId?: number benefitId?: IdType
benefitInfo?: string benefitInfo?: string
manualOverride: boolean manualOverride: boolean
vipStartTime?: string vipStartTime?: string
@@ -545,8 +546,8 @@ export interface UserAssetVO {
} }
export interface UserBalanceHistoryItem { export interface UserBalanceHistoryItem {
id: number id: IdType
userId: number userId: IdType
userNickname?: string userNickname?: string
amount: number amount: number
type?: string type?: string
@@ -554,10 +555,10 @@ export interface UserBalanceHistoryItem {
beforeBalance?: number beforeBalance?: number
afterBalance?: number afterBalance?: number
changeScene?: string changeScene?: string
relatedOrderId?: number relatedOrderId?: IdType
relatedOrderNo?: string relatedOrderNo?: string
externalOrderNo?: string externalOrderNo?: string
operatorId?: number operatorId?: IdType
remark?: string remark?: string
changeTime: string changeTime: string
} }
@@ -565,7 +566,7 @@ export interface UserBalanceHistoryItem {
export interface AdminUserBalanceChangeRequest { export interface AdminUserBalanceChangeRequest {
amount: number amount: number
changeScene: string changeScene: string
relatedOrderId?: number relatedOrderId?: IdType
externalOrderNo?: string externalOrderNo?: string
remark?: string remark?: string
} }
@@ -578,13 +579,13 @@ export interface AdminUserVipOverrideRequest {
export const userApi = adminUserApi export const userApi = adminUserApi
export interface OrderVO { export interface OrderVO {
id: number id: IdType
orderNo: string orderNo: string
userId: number userId: IdType
userNickname?: string userNickname?: string
shopId: number shopId: IdType
shopName?: string shopName?: string
artistId?: number artistId?: IdType
artistName?: string artistName?: string
totalAmount: number totalAmount: number
discountAmount: number discountAmount: number
@@ -597,16 +598,16 @@ export interface OrderVO {
} }
export const adminOrderApi = { export const adminOrderApi = {
listOrders: (params: { page: number; size: number; keyword?: string; status?: number; shopId?: number }) => { listOrders: (params: { page: number; size: number; keyword?: string; status?: number; shopId?: IdType }) => {
return adminApi.get<PageResult<OrderVO>>('/order/list', { params }) return adminApi.get<PageResult<OrderVO>>('/order/list', { params })
}, },
updateOrderStatus: (id: number, status: number) => { updateOrderStatus: (id: IdType, status: number) => {
return adminApi.put<boolean>(`/order/update-status/${id}`, { status }) return adminApi.put<boolean>(`/order/update-status/${id}`, { status })
} }
} }
export interface HotProductVO { export interface HotProductVO {
id: number id: IdType
title: string title: string
price: number price: number
likeCount: number likeCount: number
@@ -614,7 +615,7 @@ export interface HotProductVO {
} }
export interface RecentActivityVO { export interface RecentActivityVO {
id: number id: IdType
type: string type: string
title?: string title?: string
description: string description: string
@@ -638,8 +639,8 @@ export const adminDashboardApi = {
} }
export interface NailArtistInfoVO { export interface NailArtistInfoVO {
id: number | string id: IdType
userId: number | string userId: IdType
identity: string identity: string
experience: number experience: number
skills: string skills: string
@@ -647,7 +648,7 @@ export interface NailArtistInfoVO {
status: number status: number
portfolio: string portfolio: string
nickname: string nickname: string
shopId: number | string shopId: IdType
shopName: string shopName: string
} }
@@ -655,7 +656,7 @@ export const adminNailArtistApi = {
listNailArtists: () => { listNailArtists: () => {
return adminApi.get<NailArtistInfoVO[]>('/nail-artist/list') return adminApi.get<NailArtistInfoVO[]>('/nail-artist/list')
}, },
getNailArtistInfo: (userId: number) => { getNailArtistInfo: (userId: IdType) => {
return adminApi.get<NailArtistInfoVO>(`/nail-artist/get/${userId}`) return adminApi.get<NailArtistInfoVO>(`/nail-artist/get/${userId}`)
}, },
saveNailArtistInfo: (data: any) => { saveNailArtistInfo: (data: any) => {
+4 -3
View File
@@ -1,4 +1,5 @@
import api from './index' import api from './index'
import type { IdType } from '@/utils/id'
export interface SendVerificationCodeRequest { export interface SendVerificationCodeRequest {
phone: string phone: string
@@ -33,15 +34,15 @@ export interface LoginResponse {
} }
export interface UserInfo { export interface UserInfo {
id: number id: IdType
account: string account: string
nickname: string nickname: string
avatar?: string avatar?: string
signature?: string signature?: string
type?: number type?: number
shopId?: number | string shopId?: IdType
shopName?: string shopName?: string
shopIds?: Array<number | string> shopIds?: IdType[]
shopNames?: string[] shopNames?: string[]
createTime: string createTime: string
updateTime?: string updateTime?: string
+4 -3
View File
@@ -1,7 +1,8 @@
import api from './index' import api from './index'
import type { IdType } from '@/utils/id'
interface CartItem { interface CartItem {
productId: number productId: IdType
quantity: number quantity: number
} }
@@ -12,12 +13,12 @@ export const cartApi = {
}, },
// 从购物车移除作品 // 从购物车移除作品
removeFromCart: (productId: number) => { removeFromCart: (productId: IdType) => {
return api.delete(`/cart/remove/${productId}`) return api.delete(`/cart/remove/${productId}`)
}, },
// 批量从购物车移除作品 // 批量从购物车移除作品
batchRemoveFromCart: (cartItemIds: number[]) => { batchRemoveFromCart: (cartItemIds: IdType[]) => {
return api.post('/cart/batch-remove', cartItemIds) return api.post('/cart/batch-remove', cartItemIds)
}, },
+15 -14
View File
@@ -1,7 +1,8 @@
import request from './index' import request from './index'
import type { IdType } from '@/utils/id'
export interface Coupon { export interface Coupon {
id: number id: IdType
couponCode: string couponCode: string
couponName: string couponName: string
couponType: number couponType: number
@@ -16,7 +17,7 @@ export interface Coupon {
endTime: string endTime: string
status: number status: number
statusName: string statusName: string
shopId?: number shopId?: IdType
couponScene?: string couponScene?: string
requiredVipLevel?: string requiredVipLevel?: string
autoMatch?: number autoMatch?: number
@@ -25,13 +26,13 @@ export interface Coupon {
} }
export interface Tag { export interface Tag {
id: number id: IdType
tagName?: string tagName?: string
} }
export interface UserCoupon { export interface UserCoupon {
id: number id: IdType
couponId: number couponId: IdType
couponName: string couponName: string
couponType: number couponType: number
couponTypeName: string couponTypeName: string
@@ -62,8 +63,8 @@ export interface CreateCouponRequest {
couponScene?: string couponScene?: string
requiredVipLevel?: string requiredVipLevel?: string
autoMatch?: number autoMatch?: number
availableTagIds: number[] availableTagIds: IdType[]
unavailableTagIds: number[] unavailableTagIds: IdType[]
} }
export interface CouponListResponse { export interface CouponListResponse {
@@ -84,7 +85,7 @@ export const couponApi = {
}, },
// 更新优惠券 // 更新优惠券
updateCoupon: (id: number, data: CreateCouponRequest) => { updateCoupon: (id: IdType, data: CreateCouponRequest) => {
return request({ return request({
url: `/coupon/update/${id}`, url: `/coupon/update/${id}`,
method: 'put', method: 'put',
@@ -93,7 +94,7 @@ export const couponApi = {
}, },
// 删除优惠券 // 删除优惠券
deleteCoupon: (id: number) => { deleteCoupon: (id: IdType) => {
return request({ return request({
url: `/coupon/delete/${id}`, url: `/coupon/delete/${id}`,
method: 'delete' method: 'delete'
@@ -101,7 +102,7 @@ export const couponApi = {
}, },
// 获取优惠券详情 // 获取优惠券详情
getCouponById: (id: number) => { getCouponById: (id: IdType) => {
return request({ return request({
url: `/coupon/detail/${id}`, url: `/coupon/detail/${id}`,
method: 'get' method: 'get'
@@ -109,7 +110,7 @@ export const couponApi = {
}, },
// 获取优惠券列表 // 获取优惠券列表
listCoupons: (params: { page: number; size: number; shopId?: number }) => { listCoupons: (params: { page: number; size: number; shopId?: IdType }) => {
return request({ return request({
url: '/coupon/list', url: '/coupon/list',
method: 'get', method: 'get',
@@ -118,7 +119,7 @@ export const couponApi = {
}, },
// 为用户分配优惠券 // 为用户分配优惠券
assignCouponToUser: (userId: number, couponId: number) => { assignCouponToUser: (userId: IdType, couponId: IdType) => {
return request({ return request({
url: '/coupon/assign', url: '/coupon/assign',
method: 'post', method: 'post',
@@ -136,7 +137,7 @@ export const couponApi = {
}, },
// 使用优惠券 // 使用优惠券
useCoupon: (userCouponId: number) => { useCoupon: (userCouponId: IdType) => {
return request({ return request({
url: '/coupon/use', url: '/coupon/use',
method: 'post', method: 'post',
@@ -145,7 +146,7 @@ export const couponApi = {
}, },
// 获取作品可用的优惠券 // 获取作品可用的优惠券
getAvailableCoupons: async (productTags: string, productPrice: number, shopId?: number): Promise<UserCoupon[]> => { getAvailableCoupons: async (productTags: string, productPrice: number, shopId?: IdType): Promise<UserCoupon[]> => {
return await request({ return await request({
url: '/coupon/available', url: '/coupon/available',
method: 'get', method: 'get',
+2 -1
View File
@@ -1,5 +1,6 @@
import type { AxiosProgressEvent } from 'axios' import type { AxiosProgressEvent } from 'axios'
import api from './index' import api from './index'
import type { IdType } from '@/utils/id'
export interface ChunkUploadInitRequest { export interface ChunkUploadInitRequest {
fileName: string fileName: string
@@ -53,7 +54,7 @@ export const fileApi = {
return api.delete<boolean>(`/user/upload-avatar/${uploadId}`) return api.delete<boolean>(`/user/upload-avatar/${uploadId}`)
}, },
getSignedUrl: (fileId: number, expiryTimeInMinutes?: number) => { getSignedUrl: (fileId: IdType, expiryTimeInMinutes?: number) => {
return api.get<string>(`/file/get-signed-url/${fileId}`, { return api.get<string>(`/file/get-signed-url/${fileId}`, {
params: { expiryTimeInMinutes } params: { expiryTimeInMinutes }
}) })
+2 -1
View File
@@ -5,6 +5,7 @@ import { wishlistApi } from './wishlist'
import router from '../router' import router from '../router'
import { message } from 'ant-design-vue' import { message } from 'ant-design-vue'
import { API_BASE_URL } from '../config/api' import { API_BASE_URL } from '../config/api'
import type { IdType } from '@/utils/id'
// 防重复提示标志 // 防重复提示标志
let lastErrorTime = 0 let lastErrorTime = 0
@@ -223,7 +224,7 @@ api.interceptors.response.use(
) )
export const fileApi = { export const fileApi = {
getSignedUrl: (fileId: number, expiryTimeInMinutes?: number) => { getSignedUrl: (fileId: IdType, expiryTimeInMinutes?: number) => {
return api.get<string>(`/file/get-signed-url/${fileId}`, { return api.get<string>(`/file/get-signed-url/${fileId}`, {
params: { expiryTimeInMinutes } params: { expiryTimeInMinutes }
}) })
+8 -7
View File
@@ -1,14 +1,15 @@
import api from './index' import api from './index'
import type { IdType } from '@/utils/id'
interface OrderItem { interface OrderItem {
productId: number productId: IdType
quantity: number quantity: number
artistId?: number artistId?: IdType
appointmentTime?: string appointmentTime?: string
} }
interface CreateOrderRequest { interface CreateOrderRequest {
couponId?: number couponId?: IdType
couponSourceType?: string couponSourceType?: string
items: OrderItem[] items: OrderItem[]
} }
@@ -25,12 +26,12 @@ export const orderApi = {
}, },
// 获取订单详情 // 获取订单详情
getOrderDetail: (orderId: number) => { getOrderDetail: (orderId: IdType) => {
return api.get(`/order/detail/${orderId}`) return api.get(`/order/detail/${orderId}`)
}, },
// 取消订单 // 取消订单
cancelOrder: (orderId: number) => { cancelOrder: (orderId: IdType) => {
return api.put(`/order/cancel/${orderId}`) return api.put(`/order/cancel/${orderId}`)
}, },
@@ -40,7 +41,7 @@ export const orderApi = {
}, },
// 后台处理订单 // 后台处理订单
processOrder: (orderId: number, status: number) => { processOrder: (orderId: IdType, status: number) => {
return api.put(`/order/admin/process/${orderId}`, {}, { return api.put(`/order/admin/process/${orderId}`, {}, {
params: { status } params: { status }
}) })
@@ -51,7 +52,7 @@ export const orderApi = {
return api.get('/order/artist/list') return api.get('/order/artist/list')
}, },
completeArtistOrder: (orderId: number) => { completeArtistOrder: (orderId: IdType) => {
return api.put(`/order/artist/complete/${orderId}`) return api.put(`/order/artist/complete/${orderId}`)
} }
} }
+8 -7
View File
@@ -1,7 +1,8 @@
import { adminApi } from './admin' import { adminApi } from './admin'
import type { IdType } from '@/utils/id'
export interface PermissionVO { export interface PermissionVO {
id: number id: IdType
permissionCode: string permissionCode: string
permissionName: string permissionName: string
permissionGroup: string permissionGroup: string
@@ -25,15 +26,15 @@ export interface UpdatePermissionRequest {
} }
export const permissionApi = { export const permissionApi = {
getUserPermissions: (userId?: number) => { getUserPermissions: (userId?: IdType) => {
if (userId) { if (userId) {
return adminApi.get<PermissionVO[]>(`/permission/user/${userId}`) return adminApi.get<PermissionVO[]>(`/permission/user/${userId}`)
} }
return adminApi.get<PermissionVO[]>('/permission/user/current') return adminApi.get<PermissionVO[]>('/permission/user/current')
}, },
getAssignablePermissionIds: (userId: number) => { getAssignablePermissionIds: (userId: IdType) => {
return adminApi.get<number[]>(`/permission/assignable/${userId}`) return adminApi.get<IdType[]>(`/permission/assignable/${userId}`)
}, },
listAllPermissions: () => { listAllPermissions: () => {
@@ -44,15 +45,15 @@ export const permissionApi = {
return adminApi.post('/permission/create', data) return adminApi.post('/permission/create', data)
}, },
updatePermission: (id: number, data: UpdatePermissionRequest) => { updatePermission: (id: IdType, data: UpdatePermissionRequest) => {
return adminApi.put(`/permission/update/${id}`, data) return adminApi.put(`/permission/update/${id}`, data)
}, },
deletePermission: (id: number) => { deletePermission: (id: IdType) => {
return adminApi.delete(`/permission/delete/${id}`) return adminApi.delete(`/permission/delete/${id}`)
}, },
assignUserPermissions: (userId: number, permissionIds: number[]) => { assignUserPermissions: (userId: IdType, permissionIds: IdType[]) => {
return adminApi.post(`/permission/assign/${userId}`, { permissionIds }) return adminApi.post(`/permission/assign/${userId}`, { permissionIds })
} }
} }
+9 -8
View File
@@ -1,8 +1,9 @@
import api from './index' import api from './index'
import type { IdType } from '@/utils/id'
export interface ProductVO { export interface ProductVO {
id: number id: IdType
shopId: number | null shopId: IdType | null
shopName?: string shopName?: string
name: string name: string
title?: string title?: string
@@ -29,7 +30,7 @@ export interface ProductVO {
} }
export interface TagInfo { export interface TagInfo {
id: number id: IdType
tagName: string tagName: string
textColor?: string textColor?: string
bgColor?: string bgColor?: string
@@ -50,7 +51,7 @@ export interface CreateProductRequest {
estimatedTime: number estimatedTime: number
category: string category: string
status: number status: number
shopId: number | null shopId: IdType | null
} }
export interface UpdateProductRequest { export interface UpdateProductRequest {
@@ -61,7 +62,7 @@ export interface UpdateProductRequest {
estimatedTime?: number estimatedTime?: number
category?: string category?: string
status?: number status?: number
shopId?: number | null shopId?: IdType | null
} }
export const productApi = { export const productApi = {
@@ -69,7 +70,7 @@ export const productApi = {
return await api.get<ProductVO[]>('/product/list/all') as unknown as ProductVO[] return await api.get<ProductVO[]>('/product/list/all') as unknown as ProductVO[]
}, },
getProductById: async (id: number): Promise<ProductVO> => { getProductById: async (id: IdType): Promise<ProductVO> => {
return await api.get<ProductVO>(`/product/get/${id}`) as unknown as ProductVO return await api.get<ProductVO>(`/product/get/${id}`) as unknown as ProductVO
}, },
@@ -77,11 +78,11 @@ export const productApi = {
return await api.get<ProductVO[]>(`/product/list/tag/${tag}`) as unknown as ProductVO[] return await api.get<ProductVO[]>(`/product/list/tag/${tag}`) as unknown as ProductVO[]
}, },
likeProduct: async (productId: number): Promise<boolean> => { likeProduct: async (productId: IdType): Promise<boolean> => {
return await api.post<boolean>(`/product/like/${productId}`) as unknown as boolean return await api.post<boolean>(`/product/like/${productId}`) as unknown as boolean
}, },
unlikeProduct: async (productId: number): Promise<boolean> => { unlikeProduct: async (productId: IdType): Promise<boolean> => {
return await api.post<boolean>(`/product/unlike/${productId}`) as unknown as boolean return await api.post<boolean>(`/product/unlike/${productId}`) as unknown as boolean
}, },
+4 -3
View File
@@ -1,11 +1,12 @@
import api from './index' import api from './index'
import type { IdType } from '@/utils/id'
export const productLikeApi = { export const productLikeApi = {
/** /**
* 点赞作品 * 点赞作品
* @param productId 作品ID * @param productId 作品ID
*/ */
likeProduct: (productId: number) => { likeProduct: (productId: IdType) => {
return api.post<boolean>(`/product-like/like/${productId}`) return api.post<boolean>(`/product-like/like/${productId}`)
}, },
@@ -13,7 +14,7 @@ export const productLikeApi = {
* 取消点赞作品 * 取消点赞作品
* @param productId 作品ID * @param productId 作品ID
*/ */
unlikeProduct: (productId: number) => { unlikeProduct: (productId: IdType) => {
return api.post<boolean>(`/product-like/unlike/${productId}`) return api.post<boolean>(`/product-like/unlike/${productId}`)
}, },
@@ -21,7 +22,7 @@ export const productLikeApi = {
* 检查用户是否已点赞作品 * 检查用户是否已点赞作品
* @param productId 作品ID * @param productId 作品ID
*/ */
checkLikeStatus: (productId: number) => { checkLikeStatus: (productId: IdType) => {
return api.get<boolean>(`/product-like/check/${productId}`) return api.get<boolean>(`/product-like/check/${productId}`)
} }
} }
+3 -2
View File
@@ -1,7 +1,8 @@
import api from './index' import api from './index'
import type { IdType } from '@/utils/id'
export interface ShopVO { export interface ShopVO {
id: number id: IdType
shopName: string shopName: string
description: string description: string
address: string address: string
@@ -60,7 +61,7 @@ export const shopApi = {
return await api.get<ShopSimpleVO[]>('/shop/list/simple') as unknown as ShopSimpleVO[] return await api.get<ShopSimpleVO[]>('/shop/list/simple') as unknown as ShopSimpleVO[]
}, },
getShopById: async (id: number): Promise<ShopVO> => { getShopById: async (id: IdType): Promise<ShopVO> => {
return await api.get<ShopVO>(`/shop/get/${id}`) as unknown as ShopVO return await api.get<ShopVO>(`/shop/get/${id}`) as unknown as ShopVO
} }
} }
+5 -4
View File
@@ -1,7 +1,8 @@
import api from './index' import api from './index'
import type { IdType } from '@/utils/id'
export interface TagVO { export interface TagVO {
id: number id: IdType
tagName: string tagName: string
textColor: string textColor: string
bgColor: string bgColor: string
@@ -22,7 +23,7 @@ export const tagApi = {
return api.get<TagVO[]>('/tag/list/all') return api.get<TagVO[]>('/tag/list/all')
}, },
getTagById: (id: number) => { getTagById: (id: IdType) => {
return api.get<TagVO>(`/tag/get/${id}`) return api.get<TagVO>(`/tag/get/${id}`)
}, },
@@ -30,11 +31,11 @@ export const tagApi = {
return api.post<TagVO>('/tag/add', data) return api.post<TagVO>('/tag/add', data)
}, },
updateTag: (id: number, data: TagDTO) => { updateTag: (id: IdType, data: TagDTO) => {
return api.put<TagVO>(`/tag/update/${id}`, data) return api.put<TagVO>(`/tag/update/${id}`, data)
}, },
deleteTag: (id: number) => { deleteTag: (id: IdType) => {
return api.delete(`/tag/delete/${id}`) return api.delete(`/tag/delete/${id}`)
} }
} }
+11 -10
View File
@@ -1,11 +1,12 @@
import api from './index' import api from './index'
import type { UserInfo } from './auth' import type { UserInfo } from './auth'
import type { IdType } from '@/utils/id'
export interface UserVO extends UserInfo { export interface UserVO extends UserInfo {
id: number id: IdType
shopId?: number shopId?: IdType
shopName?: string shopName?: string
shopIds?: Array<number | string> shopIds?: IdType[]
shopNames?: string[] shopNames?: string[]
nickname: string nickname: string
account: string account: string
@@ -13,7 +14,7 @@ export interface UserVO extends UserInfo {
signature?: string signature?: string
level?: string level?: string
type: number type: number
vipId?: number vipId?: IdType
createTime: string createTime: string
updateTime: string updateTime: string
status: number status: number
@@ -30,7 +31,7 @@ export interface ListUsersParams {
page: number page: number
size: number size: number
keyword?: string keyword?: string
shopId?: number shopId?: IdType
status?: number status?: number
} }
@@ -40,8 +41,8 @@ export interface CreateUserRequest {
phone: string phone: string
password: string password: string
type: number type: number
shopId?: number shopId?: IdType
shopIds?: Array<number | string> shopIds?: IdType[]
} }
export interface UpdateUserRequest { export interface UpdateUserRequest {
@@ -49,8 +50,8 @@ export interface UpdateUserRequest {
nickname?: string nickname?: string
phone?: string phone?: string
type?: number type?: number
shopId?: number shopId?: IdType
shopIds?: Array<number | string> shopIds?: IdType[]
} }
export interface UpdatePasswordRequest { export interface UpdatePasswordRequest {
@@ -78,7 +79,7 @@ export interface LoginShopSelectionResponse {
allowShoplessLogin: boolean allowShoplessLogin: boolean
message: string message: string
shops: Array<{ shops: Array<{
id: number | string id: IdType
shopName: string shopName: string
}> }>
} }
+9 -8
View File
@@ -1,12 +1,13 @@
import api from './index' import api from './index'
import type { IdType } from '@/utils/id'
export interface WishlistItem { export interface WishlistItem {
id: number id: IdType
userId: number userId: IdType
productId: number productId: IdType
product: { product: {
id: number id: IdType
shopId: number | null shopId: IdType | null
shopName?: string shopName?: string
title: string title: string
description: string description: string
@@ -27,15 +28,15 @@ export interface WishlistItem {
} }
export const wishlistApi = { export const wishlistApi = {
addToWishlist: async (productId: number): Promise<boolean> => { addToWishlist: async (productId: IdType): Promise<boolean> => {
return await api.post<boolean>('/wishlist/add', { productId }) as unknown as boolean return await api.post<boolean>('/wishlist/add', { productId }) as unknown as boolean
}, },
removeFromWishlist: async (productId: number): Promise<boolean> => { removeFromWishlist: async (productId: IdType): Promise<boolean> => {
return await api.post<boolean>('/wishlist/remove', { productId }) as unknown as boolean return await api.post<boolean>('/wishlist/remove', { productId }) as unknown as boolean
}, },
checkWishlist: async (productId: number): Promise<boolean> => { checkWishlist: async (productId: IdType): Promise<boolean> => {
return await api.get<boolean>(`/wishlist/check?productId=${productId}`) as unknown as boolean return await api.get<boolean>(`/wishlist/check?productId=${productId}`) as unknown as boolean
}, },
+20
View File
@@ -0,0 +1,20 @@
export type IdType = string | number
export const isEmptyId = (value: unknown): value is undefined | null | '' => {
return value === undefined || value === null || `${value}`.trim() === ''
}
export const toIdString = (value: IdType) => String(value)
export const toOptionalIdString = (value: unknown) => {
if (isEmptyId(value)) {
return undefined
}
return String(value).trim()
}
export const sameId = (left: unknown, right: unknown) => {
const leftId = toOptionalIdString(left)
const rightId = toOptionalIdString(right)
return leftId !== undefined && leftId === rightId
}
+3 -2
View File
@@ -49,6 +49,7 @@ import { LeftOutlined } from '@ant-design/icons-vue'
import { message, Modal } from 'ant-design-vue' import { message, Modal } from 'ant-design-vue'
import { fileApi } from '../api/index' import { fileApi } from '../api/index'
import { orderApi } from '../api/order' import { orderApi } from '../api/order'
import type { IdType } from '@/utils/id'
const router = useRouter() const router = useRouter()
const orders = ref<any[]>([]) const orders = ref<any[]>([])
@@ -69,7 +70,7 @@ const loadOrders = async () => {
if (!match?.[1]) continue if (!match?.[1]) continue
const imageId = match[1] const imageId = match[1]
try { try {
if (!imageIdCache.value[imageId]) imageIdCache.value[imageId] = await fileApi.getSignedUrl(Number(imageId)) as any if (!imageIdCache.value[imageId]) imageIdCache.value[imageId] = await fileApi.getSignedUrl(imageId) as any
item.productImage = imageIdCache.value[imageId] item.productImage = imageIdCache.value[imageId]
} catch { } catch {
item.productImage = '' item.productImage = ''
@@ -81,7 +82,7 @@ const loadOrders = async () => {
} }
} }
const completeOrder = (orderId: number) => { const completeOrder = (orderId: IdType) => {
Modal.confirm({ Modal.confirm({
title: '确认完成服务', title: '确认完成服务',
content: '确定要完成这个订单吗?', content: '确定要完成这个订单吗?',
+2 -1
View File
@@ -403,6 +403,7 @@ import {
type LoginAccountCheckResponse, type LoginAccountCheckResponse,
type LoginShopSelectionResponse type LoginShopSelectionResponse
} from '@/api/user' } from '@/api/user'
import type { IdType } from '@/utils/id'
const router = useRouter() const router = useRouter()
@@ -411,7 +412,7 @@ const loginType = ref<'password' | 'phone'>('password')
const loading = ref(false) const loading = ref(false)
const loadingShops = ref(false) const loadingShops = ref(false)
const shops = ref<any[]>([]) const shops = ref<any[]>([])
const loginShops = ref<Array<{ id: number | string; shopName: string }>>([]) const loginShops = ref<Array<{ id: IdType; shopName: string }>>([])
const countdown = ref(0) const countdown = ref(0)
const loginAccountStatus = ref<LoginAccountCheckResponse | null>(null) const loginAccountStatus = ref<LoginAccountCheckResponse | null>(null)
const registerAccountStatus = ref<AvailabilityCheckResponse | null>(null) const registerAccountStatus = ref<AvailabilityCheckResponse | null>(null)
+40 -23
View File
@@ -143,7 +143,7 @@
:key="artist.id" :key="artist.id"
type="button" type="button"
class="artist-option" class="artist-option"
:class="{ active: draftArtistId === artist.id }" :class="{ active: sameId(draftArtistId, artist.id) }"
@click="draftArtistId = artist.id" @click="draftArtistId = artist.id"
> >
<img v-if="artist.avatar" :src="artist.avatar" :alt="artist.name" /> <img v-if="artist.avatar" :src="artist.avatar" :alt="artist.name" />
@@ -183,6 +183,8 @@ import { couponApi, type UserCoupon } from '../api/coupon'
import { fileApi } from '../api/index' import { fileApi } from '../api/index'
import { orderApi } from '../api/order' import { orderApi } from '../api/order'
import { shopApi } from '../api/shop' import { shopApi } from '../api/shop'
import type { IdType } from '@/utils/id'
import { sameId, toOptionalIdString } from '@/utils/id'
const router = useRouter() const router = useRouter()
const updateCartCount = inject<() => Promise<void>>('updateCartCount', async () => {}) const updateCartCount = inject<() => Promise<void>>('updateCartCount', async () => {})
@@ -190,15 +192,15 @@ const updateCartCount = inject<() => Promise<void>>('updateCartCount', async ()
const NO_COUPON_KEY = 'NONE' const NO_COUPON_KEY = 'NONE'
interface ArtistOption { interface ArtistOption {
id: number id: IdType
name: string name: string
avatar?: string avatar?: string
} }
interface CartItem { interface CartItem {
id: number id: IdType
productId: number productId: IdType
shopId?: number shopId?: IdType
productTitle: string productTitle: string
productImage: string productImage: string
originalProductImage?: string originalProductImage?: string
@@ -214,19 +216,19 @@ interface CartItem {
availableArtists?: ArtistOption[] availableArtists?: ArtistOption[]
appointmentTime?: string appointmentTime?: string
selected: boolean selected: boolean
artistId?: number artistId?: IdType
artist?: ArtistOption artist?: ArtistOption
} }
interface CheckoutIssue { interface CheckoutIssue {
key: string key: string
message: string message: string
itemId?: number itemId?: IdType
} }
const cartItems = ref<CartItem[]>([]) const cartItems = ref<CartItem[]>([])
const imageIdCache = ref<Record<string, string>>({}) const imageIdCache = ref<Record<string, string>>({})
const itemRefs = ref<Record<number, HTMLElement>>({}) const itemRefs = ref<Record<string, HTMLElement>>({})
const availableCoupons = ref<UserCoupon[]>([]) const availableCoupons = ref<UserCoupon[]>([])
const selectedCoupon = ref<UserCoupon | null>(null) const selectedCoupon = ref<UserCoupon | null>(null)
const couponSelectionKey = ref(NO_COUPON_KEY) const couponSelectionKey = ref(NO_COUPON_KEY)
@@ -235,7 +237,7 @@ const showCouponModal = ref(false)
const showBookingModal = ref(false) const showBookingModal = ref(false)
const currentItem = ref<CartItem | null>(null) const currentItem = ref<CartItem | null>(null)
const availableArtists = ref<ArtistOption[]>([]) const availableArtists = ref<ArtistOption[]>([])
const draftArtistId = ref<number>() const draftArtistId = ref<IdType>()
const draftAppointmentTime = ref('') const draftAppointmentTime = ref('')
const currentShopHours = ref('') const currentShopHours = ref('')
const editing = ref(false) const editing = ref(false)
@@ -269,16 +271,20 @@ const getDayBoundary = (date: Date) => {
const getCouponKey = (coupon: UserCoupon) => `${coupon.sourceType || 'USER_COUPON'}:${coupon.id}` const getCouponKey = (coupon: UserCoupon) => `${coupon.sourceType || 'USER_COUPON'}:${coupon.id}`
const setItemRef = (itemId: number, element: unknown) => { const setItemRef = (itemId: IdType, element: unknown) => {
const refKey = toOptionalIdString(itemId)
if (!refKey) {
return
}
if (element && (element as any).$el) { if (element && (element as any).$el) {
itemRefs.value[itemId] = (element as any).$el as HTMLElement itemRefs.value[refKey] = (element as any).$el as HTMLElement
return return
} }
if (element instanceof HTMLElement) { if (element instanceof HTMLElement) {
itemRefs.value[itemId] = element itemRefs.value[refKey] = element
return return
} }
delete itemRefs.value[itemId] delete itemRefs.value[refKey]
} }
const formatCouponDisplay = (coupon: UserCoupon) => { const formatCouponDisplay = (coupon: UserCoupon) => {
@@ -332,11 +338,21 @@ const checkoutIssues = computed<CheckoutIssue[]>(() => {
issues.push({ key: 'expired', message: `“${firstExpiredTime.productTitle}”的预约时间已过期,请重新选择`, itemId: firstExpiredTime.id }) issues.push({ key: 'expired', message: `“${firstExpiredTime.productTitle}”的预约时间已过期,请重新选择`, itemId: firstExpiredTime.id })
} }
if (new Set(items.map(item => item.shopId).filter(Boolean)).size > 1) { const selectedShopIds = new Set(
items
.map(item => toOptionalIdString(item.shopId))
.filter((shopId): shopId is string => Boolean(shopId))
)
if (selectedShopIds.size > 1) {
issues.push({ key: 'shop', message: '跨店铺项目请分开结算', itemId: items[0]?.id }) issues.push({ key: 'shop', message: '跨店铺项目请分开结算', itemId: items[0]?.id })
} }
if (new Set(items.map(item => item.artistId).filter(Boolean)).size > 1) { const selectedArtistIds = new Set(
items
.map(item => toOptionalIdString(item.artistId))
.filter((artistId): artistId is string => Boolean(artistId))
)
if (selectedArtistIds.size > 1) {
issues.push({ key: 'artist-mix', message: '不同美甲师的项目请分开结算', itemId: items[0]?.id }) issues.push({ key: 'artist-mix', message: '不同美甲师的项目请分开结算', itemId: items[0]?.id })
} }
@@ -344,10 +360,11 @@ const checkoutIssues = computed<CheckoutIssue[]>(() => {
}) })
const scrollToIssue = (issue?: CheckoutIssue) => { const scrollToIssue = (issue?: CheckoutIssue) => {
if (!issue?.itemId) { const itemId = toOptionalIdString(issue?.itemId)
if (!itemId) {
return return
} }
const target = itemRefs.value[issue.itemId] const target = itemRefs.value[itemId]
if (target) { if (target) {
target.scrollIntoView({ behavior: 'smooth', block: 'center' }) target.scrollIntoView({ behavior: 'smooth', block: 'center' })
} }
@@ -381,7 +398,7 @@ const loadProductImages = async () => {
const imageId = match[1] const imageId = match[1]
try { try {
if (!imageIdCache.value[imageId]) { if (!imageIdCache.value[imageId]) {
imageIdCache.value[imageId] = await fileApi.getSignedUrl(Number(imageId)) as any imageIdCache.value[imageId] = await fileApi.getSignedUrl(imageId) as any
} }
item.productImage = imageIdCache.value[imageId] || '' item.productImage = imageIdCache.value[imageId] || ''
} catch { } catch {
@@ -464,7 +481,7 @@ const changeQuantity = async (item: CartItem, delta: number) => {
const removeItem = async (item: CartItem) => { const removeItem = async (item: CartItem) => {
try { try {
await cartApi.removeFromCart(item.productId) await cartApi.removeFromCart(item.productId)
cartItems.value = cartItems.value.filter(current => current.id !== item.id) cartItems.value = cartItems.value.filter(current => !sameId(current.id, item.id))
await Promise.all([loadAvailableCoupons(), updateCartCount()]) await Promise.all([loadAvailableCoupons(), updateCartCount()])
message.success('作品已删除') message.success('作品已删除')
} catch { } catch {
@@ -505,18 +522,18 @@ const loadArtists = async (item: CartItem) => {
? item.availableArtists ? item.availableArtists
.filter(artist => artist && artist.id !== undefined && artist.id !== null) .filter(artist => artist && artist.id !== undefined && artist.id !== null)
.map(artist => ({ .map(artist => ({
id: Number(artist.id), id: artist.id,
name: artist.name, name: artist.name,
avatar: artist.avatar avatar: artist.avatar
})) }))
: [] : []
if (draftArtistId.value && !availableArtists.value.some(artist => artist.id === draftArtistId.value)) { if (draftArtistId.value && !availableArtists.value.some(artist => sameId(artist.id, draftArtistId.value))) {
draftArtistId.value = undefined draftArtistId.value = undefined
} }
} }
const loadShopHours = async (shopId?: number) => { const loadShopHours = async (shopId?: IdType) => {
currentShopHours.value = '' currentShopHours.value = ''
if (!shopId) return if (!shopId) return
try { try {
@@ -571,7 +588,7 @@ const confirmBooking = () => {
if (!draftAppointmentTime.value) return message.warning('请选择预约时间') if (!draftAppointmentTime.value) return message.warning('请选择预约时间')
if (isPastAppointment(draftAppointmentTime.value)) return message.warning('预约时间至少需要晚于当前 5 分钟') if (isPastAppointment(draftAppointmentTime.value)) return message.warning('预约时间至少需要晚于当前 5 分钟')
currentItem.value.artistId = draftArtistId.value currentItem.value.artistId = draftArtistId.value
currentItem.value.artist = availableArtists.value.find(artist => artist.id === draftArtistId.value) currentItem.value.artist = availableArtists.value.find(artist => sameId(artist.id, draftArtistId.value))
currentItem.value.appointmentTime = draftAppointmentTime.value currentItem.value.appointmentTime = draftAppointmentTime.value
closeBookingModal() closeBookingModal()
} }
+7 -6
View File
@@ -138,17 +138,18 @@ import { productApi, type ProductVO } from '../api/product'
import { shopApi, type ShopVO } from '../api/shop' import { shopApi, type ShopVO } from '../api/shop'
import { fileApi } from '../api/file' import { fileApi } from '../api/file'
import { DEFAULT_AVATAR, DEFAULT_PRODUCT_IMAGE } from '@/constants' import { DEFAULT_AVATAR, DEFAULT_PRODUCT_IMAGE } from '@/constants'
import type { IdType } from '@/utils/id'
interface BannerImage { interface BannerImage {
id: string id: string
shopId: number shopId: IdType
shopName: string shopName: string
businessHours?: string businessHours?: string
url: string url: string
} }
interface ProductCardItem { interface ProductCardItem {
id: number id: IdType
name: string name: string
price: string price: string
meta: string meta: string
@@ -187,7 +188,7 @@ const getProductCoverUrl = async (product: ProductVO): Promise<string> => {
} }
if (!productImageCache.value[firstImageId]) { if (!productImageCache.value[firstImageId]) {
try { try {
productImageCache.value[firstImageId] = await fileApi.getSignedUrl(Number(firstImageId)) as unknown as string productImageCache.value[firstImageId] = await fileApi.getSignedUrl(firstImageId) as unknown as string
} catch (error) { } catch (error) {
console.error('获取首页作品封面失败:', error) console.error('获取首页作品封面失败:', error)
productImageCache.value[firstImageId] = DEFAULT_PRODUCT_IMAGE productImageCache.value[firstImageId] = DEFAULT_PRODUCT_IMAGE
@@ -250,11 +251,11 @@ const loadBannerImages = async () => {
.filter(Boolean) .filter(Boolean)
for (const id of coverIds) { for (const id of coverIds) {
try { try {
const url = await fileApi.getSignedUrl(Number(id)) as unknown as string const url = await fileApi.getSignedUrl(id) as unknown as string
if (url) { if (url) {
banners.push({ banners.push({
id: `${shop.id}-${id}`, id: `${shop.id}-${id}`,
shopId: Number(shop.id), shopId: shop.id,
shopName: shop.shopName, shopName: shop.shopName,
businessHours: shop.businessHours, businessHours: shop.businessHours,
url url
@@ -339,7 +340,7 @@ const handleProductClick = (item: ProductCardItem) => {
router.push(`/product/${item.id}`) router.push(`/product/${item.id}`)
} }
const openShopById = (shopId: number) => { const openShopById = (shopId: IdType) => {
router.push(`/shop/${shopId}`) router.push(`/shop/${shopId}`)
} }
+3 -2
View File
@@ -48,6 +48,7 @@ import { LeftOutlined } from '@ant-design/icons-vue'
import { message, Modal } from 'ant-design-vue' import { message, Modal } from 'ant-design-vue'
import { fileApi } from '../api/index' import { fileApi } from '../api/index'
import { orderApi } from '../api/order' import { orderApi } from '../api/order'
import type { IdType } from '@/utils/id'
const router = useRouter() const router = useRouter()
const orders = ref<any[]>([]) const orders = ref<any[]>([])
@@ -68,7 +69,7 @@ const loadOrders = async () => {
if (!match?.[1]) continue if (!match?.[1]) continue
const imageId = match[1] const imageId = match[1]
try { try {
if (!imageIdCache.value[imageId]) imageIdCache.value[imageId] = await fileApi.getSignedUrl(Number(imageId)) as any if (!imageIdCache.value[imageId]) imageIdCache.value[imageId] = await fileApi.getSignedUrl(imageId) as any
item.productImage = imageIdCache.value[imageId] item.productImage = imageIdCache.value[imageId]
} catch { } catch {
item.productImage = '' item.productImage = ''
@@ -80,7 +81,7 @@ const loadOrders = async () => {
} }
} }
const cancelOrder = (orderId: number) => { const cancelOrder = (orderId: IdType) => {
Modal.confirm({ Modal.confirm({
title: '确认取消订单', title: '确认取消订单',
content: '确定要取消这个订单吗?', content: '确定要取消这个订单吗?',
+11 -6
View File
@@ -148,6 +148,8 @@ import { productLikeApi } from '@/api/productLike'
import { shopApi, type ShopVO } from '@/api/shop' import { shopApi, type ShopVO } from '@/api/shop'
import { wishlistApi } from '@/api/wishlist' import { wishlistApi } from '@/api/wishlist'
import { DEFAULT_PRODUCT_IMAGE } from '@/constants' import { DEFAULT_PRODUCT_IMAGE } from '@/constants'
import type { IdType } from '@/utils/id'
import { toOptionalIdString } from '@/utils/id'
const route = useRoute() const route = useRoute()
const router = useRouter() const router = useRouter()
@@ -169,8 +171,8 @@ const artistCount = computed(() => {
const rawValue = product.value.bookableArtists || '' const rawValue = product.value.bookableArtists || ''
return rawValue return rawValue
.split(',') .split(',')
.map(id => Number(id.trim())) .map(id => id.trim())
.filter(id => Number.isFinite(id) && id > 0).length .filter(Boolean).length
}) })
const artistCountText = computed(() => { const artistCountText = computed(() => {
if (artistCount.value > 0) { if (artistCount.value > 0) {
@@ -264,7 +266,7 @@ const loadProductImages = async () => {
for (const id of fileIds) { for (const id of fileIds) {
try { try {
if (!imageIdCache.value[id]) { if (!imageIdCache.value[id]) {
imageIdCache.value[id] = await fileApi.getSignedUrl(Number(id)) as unknown as string imageIdCache.value[id] = await fileApi.getSignedUrl(id) as unknown as string
} }
if (imageIdCache.value[id]) { if (imageIdCache.value[id]) {
urls.push(imageIdCache.value[id]) urls.push(imageIdCache.value[id])
@@ -277,13 +279,13 @@ const loadProductImages = async () => {
productImages.value = urls.length ? urls : [DEFAULT_PRODUCT_IMAGE] productImages.value = urls.length ? urls : [DEFAULT_PRODUCT_IMAGE]
} }
const loadShopInfo = async (shopId?: number | null) => { const loadShopInfo = async (shopId?: IdType | null) => {
if (!shopId) { if (!shopId) {
shopInfo.value = null shopInfo.value = null
return return
} }
try { try {
const response = await shopApi.getShopById(Number(shopId)) const response = await shopApi.getShopById(shopId)
shopInfo.value = response || null shopInfo.value = response || null
} catch (error) { } catch (error) {
console.error('获取门店信息失败:', error) console.error('获取门店信息失败:', error)
@@ -333,7 +335,10 @@ const resolveLoadError = (error: any) => {
const fetchProductDetail = async () => { const fetchProductDetail = async () => {
loadError.value = '' loadError.value = ''
try { try {
const productId = Number(route.params.id) const productId = toOptionalIdString(route.params.id)
if (!productId) {
throw new Error('作品ID不存在')
}
const response = await productApi.getProductById(productId) const response = await productApi.getProductById(productId)
if (!response?.id) { if (!response?.id) {
throw new Error('未找到对应作品') throw new Error('未找到对应作品')
+5 -5
View File
@@ -143,7 +143,7 @@ const loading = ref(false)
const showSearch = ref(false) const showSearch = ref(false)
const searchKeyword = ref('') const searchKeyword = ref('')
const imageIdCache = ref<Record<string, string>>({}) const imageIdCache = ref<Record<string, string>>({})
const imageUrls = ref<Record<number, string[]>>({}) const imageUrls = ref<Record<string, string[]>>({})
const isLoggedIn = computed(() => Boolean(localStorage.getItem('accessToken') || sessionStorage.getItem('accessToken'))) const isLoggedIn = computed(() => Boolean(localStorage.getItem('accessToken') || sessionStorage.getItem('accessToken')))
const activeBannerText = computed(() => { const activeBannerText = computed(() => {
@@ -170,7 +170,7 @@ const ensureLoginForAction = (actionText: string) => {
const loadImageUrls = async (productList: ProductVO[]) => { const loadImageUrls = async (productList: ProductVO[]) => {
for (const product of productList) { for (const product of productList) {
if (!product.imageFileIds) { if (!product.imageFileIds) {
imageUrls.value[product.id] = [DEFAULT_PRODUCT_IMAGE] imageUrls.value[String(product.id)] = [DEFAULT_PRODUCT_IMAGE]
continue continue
} }
@@ -180,7 +180,7 @@ const loadImageUrls = async (productList: ProductVO[]) => {
for (const id of ids) { for (const id of ids) {
try { try {
if (!imageIdCache.value[id]) { if (!imageIdCache.value[id]) {
imageIdCache.value[id] = await fileApi.getSignedUrl(Number(id)) as unknown as string imageIdCache.value[id] = await fileApi.getSignedUrl(id) as unknown as string
} }
if (imageIdCache.value[id]) { if (imageIdCache.value[id]) {
urls.push(imageIdCache.value[id]) urls.push(imageIdCache.value[id])
@@ -190,11 +190,11 @@ const loadImageUrls = async (productList: ProductVO[]) => {
} }
} }
imageUrls.value[product.id] = urls.length ? urls : [DEFAULT_PRODUCT_IMAGE] imageUrls.value[String(product.id)] = urls.length ? urls : [DEFAULT_PRODUCT_IMAGE]
} }
} }
const getProductImages = (product: ProductVO): string[] => imageUrls.value[product.id] || [DEFAULT_PRODUCT_IMAGE] const getProductImages = (product: ProductVO): string[] => imageUrls.value[String(product.id)] || [DEFAULT_PRODUCT_IMAGE]
const fetchTags = async () => { const fetchTags = async () => {
try { try {
+8 -7
View File
@@ -70,12 +70,13 @@ import { LeftOutlined, ShopOutlined } from '@ant-design/icons-vue'
import { message } from 'ant-design-vue' import { message } from 'ant-design-vue'
import { shopApi, type ShopVO } from '@/api/shop' import { shopApi, type ShopVO } from '@/api/shop'
import { fileApi } from '@/api/file' import { fileApi } from '@/api/file'
import { toOptionalIdString } from '@/utils/id'
const router = useRouter() const router = useRouter()
const route = useRoute() const route = useRoute()
const shopInfo = ref<ShopVO>({ const shopInfo = ref<ShopVO>({
id: 0, id: '',
shopName: '', shopName: '',
description: '', description: '',
address: '', address: '',
@@ -124,13 +125,13 @@ const loadShopImages = async () => {
if (imageFileIds) { if (imageFileIds) {
const fileIds = imageFileIds.split(',').filter(id => id.trim()) const fileIds = imageFileIds.split(',').filter(id => id.trim())
const fileIdPromises = fileIds.map(idStr => { const fileIdPromises = fileIds.map(idStr => {
const fileId = parseInt(idStr) const fileId = idStr.trim()
if (!isNaN(fileId)) { if (!fileId) {
return null
}
return fileApi.getSignedUrl(fileId).catch(() => { return fileApi.getSignedUrl(fileId).catch(() => {
return null return null
}) })
}
return null
}) })
const results = await Promise.all(fileIdPromises) const results = await Promise.all(fileIdPromises)
@@ -149,14 +150,14 @@ const loadShopImages = async () => {
const fetchShopDetail = async () => { const fetchShopDetail = async () => {
try { try {
// 从路由参数或本地存储获取店铺ID // 从路由参数或本地存储获取店铺ID
const shopId = route.params.id || localStorage.getItem('userShopId') const shopId = toOptionalIdString(route.params.id || localStorage.getItem('userShopId'))
if (!shopId) { if (!shopId) {
message.error('店铺ID不存在') message.error('店铺ID不存在')
router.back() router.back()
return return
} }
const response = await shopApi.getShopById(Number(shopId)) as any const response = await shopApi.getShopById(shopId) as any
shopInfo.value = response || {} shopInfo.value = response || {}
// 加载店铺图片 // 加载店铺图片
+11 -9
View File
@@ -53,13 +53,15 @@ import { ElMessage } from 'element-plus'
import { wishlistApi, type WishlistItem } from '@/api/wishlist' import { wishlistApi, type WishlistItem } from '@/api/wishlist'
import { cartApi } from '@/api/cart' import { cartApi } from '@/api/cart'
import { fileApi } from '@/api/file' import { fileApi } from '@/api/file'
import type { IdType } from '@/utils/id'
import { sameId } from '@/utils/id'
const router = useRouter() const router = useRouter()
const updateCartCount = inject<() => Promise<void>>('updateCartCount', async () => {}) const updateCartCount = inject<() => Promise<void>>('updateCartCount', async () => {})
const wishlistItems = ref<WishlistItem[]>([]) const wishlistItems = ref<WishlistItem[]>([])
const imageIdCache = ref<Record<string, string>>({}) const imageIdCache = ref<Record<string, string>>({})
const imageUrls = ref<Record<number, string[]>>({}) const imageUrls = ref<Record<string, string[]>>({})
const DEFAULT_PRODUCT_IMAGE = 'data:image/svg+xml;base64,PHN2ZyB3aW0dPSJodHRwOi8vd3d3Lm9yZy8yMDAwL3N2ZyI+Pjwvc3ZnPg==' const DEFAULT_PRODUCT_IMAGE = 'data:image/svg+xml;base64,PHN2ZyB3aW0dPSJodHRwOi8vd3d3Lm9yZy8yMDAwL3N2ZyI+Pjwvc3ZnPg=='
const handleBackClick = () => { const handleBackClick = () => {
@@ -87,7 +89,7 @@ const loadImageUrls = async (items: WishlistItem[]) => {
if (id) { if (id) {
try { try {
if (!imageIdCache.value[id]) { if (!imageIdCache.value[id]) {
const response = await fileApi.getSignedUrl(Number(id)) as any const response = await fileApi.getSignedUrl(id.trim()) as any
imageIdCache.value[id] = response imageIdCache.value[id] = response
} }
if (imageIdCache.value[id]) { if (imageIdCache.value[id]) {
@@ -100,18 +102,18 @@ const loadImageUrls = async (items: WishlistItem[]) => {
} }
} }
imageUrls.value[item.product.id] = urls imageUrls.value[String(item.product.id)] = urls
} else { } else {
imageUrls.value[item.product.id] = [DEFAULT_PRODUCT_IMAGE] imageUrls.value[String(item.product.id)] = [DEFAULT_PRODUCT_IMAGE]
} }
} }
} }
const getProductImages = (product: any): string[] => { const getProductImages = (product: any): string[] => {
return imageUrls.value[product.id] || [DEFAULT_PRODUCT_IMAGE] return imageUrls.value[String(product.id)] || [DEFAULT_PRODUCT_IMAGE]
} }
const handleAddToCart = async (productId: number) => { const handleAddToCart = async (productId: IdType) => {
try { try {
await cartApi.addToCart({ productId, quantity: 1 }) await cartApi.addToCart({ productId, quantity: 1 })
await updateCartCount() await updateCartCount()
@@ -122,10 +124,10 @@ const handleAddToCart = async (productId: number) => {
} }
} }
const handleRemoveItem = async (productId: number) => { const handleRemoveItem = async (productId: IdType) => {
try { try {
await wishlistApi.removeFromWishlist(productId) await wishlistApi.removeFromWishlist(productId)
wishlistItems.value = wishlistItems.value.filter(item => item.productId !== productId) wishlistItems.value = wishlistItems.value.filter(item => !sameId(item.productId, productId))
ElMessage.success('已从收藏中移除') ElMessage.success('已从收藏中移除')
} catch (error) { } catch (error) {
console.error('移除收藏失败:', error) console.error('移除收藏失败:', error)
@@ -137,7 +139,7 @@ const handleBrowseProducts = () => {
router.push('/products') router.push('/products')
} }
const handleProductClick = (productId: number) => { const handleProductClick = (productId: IdType) => {
router.push(`/product/${productId}`) router.push(`/product/${productId}`)
} }
+4 -3
View File
@@ -84,13 +84,14 @@ import type { FormInstance } from 'ant-design-vue'
import { UserOutlined, LockOutlined } from '@ant-design/icons-vue' import { UserOutlined, LockOutlined } from '@ant-design/icons-vue'
import { adminAuthApi, type LoginShopSelectionResponse } from '@/api/admin' import { adminAuthApi, type LoginShopSelectionResponse } from '@/api/admin'
import { ACCOUNT_REGEX, ACCOUNT_RULE_MESSAGE, sanitizeAccountInput } from '@/utils/account' import { ACCOUNT_REGEX, ACCOUNT_RULE_MESSAGE, sanitizeAccountInput } from '@/utils/account'
import type { IdType } from '@/utils/id'
import { usePermission } from '@/utils/permission' import { usePermission } from '@/utils/permission'
const router = useRouter() const router = useRouter()
const formRef = ref<FormInstance>() const formRef = ref<FormInstance>()
const loading = ref(false) const loading = ref(false)
const shopLoading = ref(false) const shopLoading = ref(false)
const shops = ref<Array<{ id: number | string; shopName: string }>>([]) const shops = ref<Array<{ id: IdType; shopName: string }>>([])
const allowShoplessLogin = ref(false) const allowShoplessLogin = ref(false)
const loginShopMessage = ref('') const loginShopMessage = ref('')
const { loadUserPermissions } = usePermission() const { loadUserPermissions } = usePermission()
@@ -109,8 +110,8 @@ const handleAccountInput = () => {
} }
} }
const getShopIdValue = (shop: { id: number | string; shopName: string }) => String(shop.id ?? '') const getShopIdValue = (shop: { id: IdType; shopName: string }) => String(shop.id ?? '')
const getShopLabel = (shop: { id: number | string; shopName: string }) => String(shop.shopName || `店铺 ${shop.id}`) const getShopLabel = (shop: { id: IdType; shopName: string }) => String(shop.shopName || `店铺 ${shop.id}`)
const shopOptions = computed(() => const shopOptions = computed(() =>
shops.value.map(shop => ({ shops.value.map(shop => ({
+5 -3
View File
@@ -68,6 +68,8 @@ import { computed, onMounted, ref } from 'vue'
import { message } from 'ant-design-vue' import { message } from 'ant-design-vue'
import { orderApi } from '../../api/order' import { orderApi } from '../../api/order'
import { usePermission } from '@/utils/permission' import { usePermission } from '@/utils/permission'
import type { IdType } from '@/utils/id'
import { sameId } from '@/utils/id'
const orders = ref<any[]>([]) const orders = ref<any[]>([])
const loading = ref(false) const loading = ref(false)
@@ -133,13 +135,13 @@ const loadOrders = async () => {
} }
} }
const process = async (orderId: number, status: number) => { const process = async (orderId: IdType, status: number) => {
try { try {
await orderApi.processOrder(orderId, status) await orderApi.processOrder(orderId, status)
message.success('操作成功') message.success('操作成功')
await loadOrders() await loadOrders()
if (currentOrder.value?.id === orderId) { if (sameId(currentOrder.value?.id, orderId)) {
currentOrder.value = orders.value.find(order => order.id === orderId) || null currentOrder.value = orders.value.find(order => sameId(order.id, orderId)) || null
} }
} catch { } catch {
message.error('操作失败') message.error('操作失败')
+13 -11
View File
@@ -80,7 +80,7 @@
> >
<template #renderItem="{ item }"> <template #renderItem="{ item }">
<a-list-item <a-list-item
:class="{ selected: selectedUser?.id === item.id }" :class="{ selected: sameId(selectedUser?.id, item.id) }"
style="cursor: pointer;" style="cursor: pointer;"
@click="selectUser(item)" @click="selectUser(item)"
> >
@@ -220,6 +220,8 @@ import { userApi, type UserVO } from '@/api/admin'
import { permissionApi, type PermissionVO } from '@/api/permission' import { permissionApi, type PermissionVO } from '@/api/permission'
import { buildDraftStorageKey, clearDraftRecord, loadDraftRecord, saveDraftRecord } from '@/utils/form-draft' import { buildDraftStorageKey, clearDraftRecord, loadDraftRecord, saveDraftRecord } from '@/utils/form-draft'
import { usePermission } from '@/utils/permission' import { usePermission } from '@/utils/permission'
import type { IdType } from '@/utils/id'
import { sameId } from '@/utils/id'
const { hasPermission, loadUserPermissions } = usePermission() const { hasPermission, loadUserPermissions } = usePermission()
@@ -304,14 +306,14 @@ const userSearchText = ref('')
const userList = ref<UserVO[]>([]) const userList = ref<UserVO[]>([])
const selectedUser = ref<UserVO | null>(null) const selectedUser = ref<UserVO | null>(null)
const assignLoading = ref(false) const assignLoading = ref(false)
const selectedPermissions = ref<number[]>([]) const selectedPermissions = ref<IdType[]>([])
const assignablePermissionIds = ref<number[]>([]) const assignablePermissionIds = ref<IdType[]>([])
const activeCollapseKeys = ref<string[]>(['作品管理', '店铺管理', '用户管理', '权限管理']) const activeCollapseKeys = ref<string[]>(['作品管理', '店铺管理', '用户管理', '权限管理'])
const currentLoginUser = ref<UserVO | null>(null) const currentLoginUser = ref<UserVO | null>(null)
const assignablePermissionIdSet = computed(() => new Set(assignablePermissionIds.value)) const assignablePermissionIdSet = computed(() => new Set(assignablePermissionIds.value.map(id => String(id))))
const disabledPermissionCount = computed(() => const disabledPermissionCount = computed(() =>
permissionList.value.filter(permission => !assignablePermissionIdSet.value.has(permission.id)).length permissionList.value.filter(permission => !assignablePermissionIdSet.value.has(String(permission.id))).length
) )
const groupedPermissions = computed(() => { const groupedPermissions = computed(() => {
@@ -343,12 +345,12 @@ const filteredUserList = computed(() => {
// 管理员可以看到所有用户(除了普通用户和自己) // 管理员可以看到所有用户(除了普通用户和自己)
if (currentLoginUser.value.type === 4) { if (currentLoginUser.value.type === 4) {
return userList.value.filter(user => user.type !== 0 && user.id !== currentUserId) return userList.value.filter(user => user.type !== 0 && !sameId(user.id, currentUserId))
} }
// 店长只能看到美甲师(除了自己) // 店长只能看到美甲师(除了自己)
if (currentLoginUser.value.type === 2) { if (currentLoginUser.value.type === 2) {
return userList.value.filter(user => user.type === 3 && user.id !== currentUserId) return userList.value.filter(user => user.type === 3 && !sameId(user.id, currentUserId))
} }
// 其他用户类型(如美甲师)不能管理权限 // 其他用户类型(如美甲师)不能管理权限
@@ -359,7 +361,7 @@ const isPermissionDisabled = (permission: PermissionVO) => {
if (!selectedUser.value) { if (!selectedUser.value) {
return true return true
} }
return !assignablePermissionIdSet.value.has(permission.id) return !assignablePermissionIdSet.value.has(String(permission.id))
} }
const resolveRequestErrorMessage = (error: any, fallback: string) => { const resolveRequestErrorMessage = (error: any, fallback: string) => {
@@ -443,12 +445,12 @@ const selectUser = async (user: UserVO) => {
try { try {
const [assignedPermissions, allowedIds] = await Promise.all([ const [assignedPermissions, allowedIds] = await Promise.all([
permissionApi.getUserPermissions(user.id) as unknown as Promise<PermissionVO[]>, permissionApi.getUserPermissions(user.id) as unknown as Promise<PermissionVO[]>,
permissionApi.getAssignablePermissionIds(user.id) as unknown as Promise<number[]> permissionApi.getAssignablePermissionIds(user.id) as unknown as Promise<IdType[]>
]) ])
assignablePermissionIds.value = allowedIds || [] assignablePermissionIds.value = allowedIds || []
const allowedIdSet = new Set(assignablePermissionIds.value) const allowedIdSet = new Set(assignablePermissionIds.value.map(id => String(id)))
const assignedIds = (assignedPermissions || []).map((p: PermissionVO) => p.id) const assignedIds = (assignedPermissions || []).map((p: PermissionVO) => p.id)
selectedPermissions.value = assignedIds.filter(id => allowedIdSet.has(id)) selectedPermissions.value = assignedIds.filter(id => allowedIdSet.has(String(id)))
const trimmedCount = assignedIds.length - selectedPermissions.value.length const trimmedCount = assignedIds.length - selectedPermissions.value.length
if (trimmedCount > 0) { if (trimmedCount > 0) {
message.warning(`已自动排除 ${trimmedCount} 项超出当前角色允许范围的权限`) message.warning(`已自动排除 ${trimmedCount} 项超出当前角色允许范围的权限`)
+17 -15
View File
@@ -410,6 +410,8 @@ import { createChunkUploadTask, type ChunkUploadTask } from '@/utils/chunk-uploa
import { buildDraftStorageKey, clearDraftRecord, loadDraftRecord, saveDraftRecord } from '@/utils/form-draft' import { buildDraftStorageKey, clearDraftRecord, loadDraftRecord, saveDraftRecord } from '@/utils/form-draft'
import { usePermission } from '@/utils/permission' import { usePermission } from '@/utils/permission'
import { MAX_IMAGE_UPLOAD_SIZE, compressImageIfNeeded, formatFileSize } from '@/utils/image-upload' import { MAX_IMAGE_UPLOAD_SIZE, compressImageIfNeeded, formatFileSize } from '@/utils/image-upload'
import type { IdType } from '@/utils/id'
import { sameId } from '@/utils/id'
const { hasPermission, loadUserPermissions } = usePermission() const { hasPermission, loadUserPermissions } = usePermission()
const loading = ref(false) const loading = ref(false)
@@ -432,7 +434,7 @@ const previewVisible = ref(false)
const previewImage = ref('') const previewImage = ref('')
const imageFileList = ref<any[]>([]) const imageFileList = ref<any[]>([])
const uploadedFileIds = ref<string[]>([]) const uploadedFileIds = ref<string[]>([])
const imageUrls = ref<Record<number, string[]>>({}) const imageUrls = ref<Record<string, string[]>>({})
const viewImageUrls = ref<string[]>([]) const viewImageUrls = ref<string[]>([])
const imageIdCache = ref<Record<string, string>>({}) const imageIdCache = ref<Record<string, string>>({})
const isAdmin = ref(false) const isAdmin = ref(false)
@@ -498,7 +500,7 @@ const columns = [
{ title: '操作', key: 'actions', width: 150, fixed: 'right' as const } { title: '操作', key: 'actions', width: 150, fixed: 'right' as const }
] ]
const getShopName = (shopId: number): string => { const getShopName = (shopId: IdType): string => {
const normalizedShopId = normalizeShopIdValue(shopId) const normalizedShopId = normalizeShopIdValue(shopId)
const shop = shops.value.find(s => normalizeShopIdValue(s.id) === normalizedShopId) const shop = shops.value.find(s => normalizeShopIdValue(s.id) === normalizedShopId)
return shop ? shop.shopName : '未知店铺' return shop ? shop.shopName : '未知店铺'
@@ -549,7 +551,7 @@ const fetchShops = async () => {
// 根据用户权限控制店铺列表的显示 // 根据用户权限控制店铺列表的显示
if (currentUser && currentUser.type !== 4 && currentUser.shopId) { if (currentUser && currentUser.type !== 4 && currentUser.shopId) {
// 如果是店长,只显示用户所属的店铺 // 如果是店长,只显示用户所属的店铺
shops.value = res?.filter((shop: any) => shop.id === currentUser.shopId) || [] shops.value = res?.filter((shop: any) => sameId(shop.id, currentUser.shopId)) || []
// 默认选择用户所属的店铺,并且不可修改 // 默认选择用户所属的店铺,并且不可修改
formState.shopId = currentUser.shopId formState.shopId = currentUser.shopId
} else { } else {
@@ -565,7 +567,7 @@ const fetchShops = async () => {
} }
} }
const fetchTags = async (shopId?: number) => { const fetchTags = async (shopId?: IdType) => {
loadingTags.value = true loadingTags.value = true
try { try {
let response let response
@@ -583,7 +585,7 @@ const fetchTags = async (shopId?: number) => {
} }
} }
const fetchArtists = async (shopId?: number) => { const fetchArtists = async (shopId?: IdType) => {
loadingArtists.value = true loadingArtists.value = true
try { try {
const response = await adminArtistApi.listArtists(shopId) as any const response = await adminArtistApi.listArtists(shopId) as any
@@ -600,13 +602,13 @@ const syncAvailableCouponSelection = () => {
const availableCouponIdSet = new Set( const availableCouponIdSet = new Set(
coupons.value coupons.value
.map(coupon => coupon?.id) .map(coupon => coupon?.id)
.filter((id): id is number => id !== undefined && id !== null) .filter((id): id is IdType => id !== undefined && id !== null)
.map(id => String(id)) .map(id => String(id))
) )
formState.availableCoupons = formState.availableCoupons.filter(couponId => availableCouponIdSet.has(String(couponId))) formState.availableCoupons = formState.availableCoupons.filter(couponId => availableCouponIdSet.has(String(couponId)))
} }
const fetchCoupons = async (shopId?: number) => { const fetchCoupons = async (shopId?: IdType) => {
if (!shopId) { if (!shopId) {
coupons.value = [] coupons.value = []
formState.availableCoupons = [] formState.availableCoupons = []
@@ -664,7 +666,7 @@ const loadImageUrls = async (products: Product[]) => {
try { try {
// 检查缓存 // 检查缓存
if (!imageIdCache.value[id]) { if (!imageIdCache.value[id]) {
const response = await adminFileApi.getSignedUrl(Number(id || '0')) as any const response = await adminFileApi.getSignedUrl(id.trim()) as any
imageIdCache.value[id] = response imageIdCache.value[id] = response
} }
urls.push(imageIdCache.value[id]!) urls.push(imageIdCache.value[id]!)
@@ -676,11 +678,11 @@ const loadImageUrls = async (products: Product[]) => {
} }
if (product.id) { if (product.id) {
imageUrls.value[product.id] = urls imageUrls.value[String(product.id)] = urls
} }
} else { } else {
if (product.id) { if (product.id) {
imageUrls.value[product.id] = [DEFAULT_PRODUCT_IMAGE] imageUrls.value[String(product.id)] = [DEFAULT_PRODUCT_IMAGE]
} }
} }
} }
@@ -689,7 +691,7 @@ const loadImageUrls = async (products: Product[]) => {
const getProductImages = (product: Product | Record<string, any>): string[] => { const getProductImages = (product: Product | Record<string, any>): string[] => {
const productId = 'id' in product ? product.id : (product as any).id const productId = 'id' in product ? product.id : (product as any).id
if (productId !== undefined) { if (productId !== undefined) {
return imageUrls.value[productId] || [DEFAULT_PRODUCT_IMAGE] return imageUrls.value[String(productId)] || [DEFAULT_PRODUCT_IMAGE]
} }
return [DEFAULT_PRODUCT_IMAGE] return [DEFAULT_PRODUCT_IMAGE]
} }
@@ -827,7 +829,7 @@ const showViewModal = async (record: Product | Record<string, any>) => {
try { try {
// 检查缓存 // 检查缓存
if (!imageIdCache.value[id]) { if (!imageIdCache.value[id]) {
const response = await adminFileApi.getSignedUrl(Number(id)) as unknown as string const response = await adminFileApi.getSignedUrl(id) as unknown as string
imageIdCache.value[id] = response imageIdCache.value[id] = response
} }
urls.push(imageIdCache.value[id]) urls.push(imageIdCache.value[id])
@@ -881,7 +883,7 @@ const buildImageFileListByIds = async (ids: string[]) => {
for (const [index, id] of ids.entries()) { for (const [index, id] of ids.entries()) {
try { try {
if (!imageIdCache.value[id]) { if (!imageIdCache.value[id]) {
const response = await adminFileApi.getSignedUrl(Number(id)) as any const response = await adminFileApi.getSignedUrl(id) as any
imageIdCache.value[id] = response imageIdCache.value[id] = response
} }
fileList.push({ fileList.push({
@@ -1062,7 +1064,7 @@ const handlePreview = async (file: any) => {
} }
if (!imageIdCache.value[fileId]) { if (!imageIdCache.value[fileId]) {
const response = await adminFileApi.getSignedUrl(Number(fileId)) as any const response = await adminFileApi.getSignedUrl(fileId) as any
imageIdCache.value[fileId] = response imageIdCache.value[fileId] = response
} }
@@ -1163,7 +1165,7 @@ const handleSelectAllCoupons = () => {
} }
formState.availableCoupons = coupons.value formState.availableCoupons = coupons.value
.map(coupon => coupon?.id) .map(coupon => coupon?.id)
.filter((id): id is number => id !== undefined && id !== null) .filter((id): id is IdType => id !== undefined && id !== null)
.map(id => String(id)) .map(id => String(id))
} }
+15 -15
View File
@@ -326,8 +326,8 @@ const bannerPreviewImage = ref('')
const imageFileList = ref<any[]>([]) const imageFileList = ref<any[]>([])
const uploadedFileIds = ref<string[]>([]) const uploadedFileIds = ref<string[]>([])
const imageIdCache = ref<Record<string, string>>({}) const imageIdCache = ref<Record<string, string>>({})
const shopImageUrls = ref<Record<number, string[]>>({}) const shopImageUrls = ref<Record<string, string[]>>({})
const shopBannerUrls = ref<Record<number, string[]>>({}) const shopBannerUrls = ref<Record<string, string[]>>({})
const viewImageUrls = ref<string[]>([]) const viewImageUrls = ref<string[]>([])
const viewBannerUrls = ref<string[]>([]) const viewBannerUrls = ref<string[]>([])
const previewVisible = ref(false) const previewVisible = ref(false)
@@ -426,7 +426,7 @@ const loadImageUrls = async (shops: Shop[]) => {
try { try {
// 检查缓存 // 检查缓存
if (!imageIdCache.value[id]) { if (!imageIdCache.value[id]) {
const response = await adminFileApi.getSignedUrl(Number(id || '0')) as any const response = await adminFileApi.getSignedUrl(id.trim()) as any
imageIdCache.value[id] = response imageIdCache.value[id] = response
} }
urls.push(imageIdCache.value[id]!) urls.push(imageIdCache.value[id]!)
@@ -438,11 +438,11 @@ const loadImageUrls = async (shops: Shop[]) => {
} }
if (shop.id !== undefined) { if (shop.id !== undefined) {
shopImageUrls.value[shop.id] = urls shopImageUrls.value[String(shop.id)] = urls
} }
} else { } else {
if (shop.id !== undefined) { if (shop.id !== undefined) {
shopImageUrls.value[shop.id] = [] shopImageUrls.value[String(shop.id)] = []
} }
} }
@@ -456,7 +456,7 @@ const loadImageUrls = async (shops: Shop[]) => {
try { try {
// 检查缓存 // 检查缓存
if (!imageIdCache.value[id]) { if (!imageIdCache.value[id]) {
const response = await adminFileApi.getSignedUrl(Number(id || '0')) as any const response = await adminFileApi.getSignedUrl(id.trim()) as any
imageIdCache.value[id] = response imageIdCache.value[id] = response
} }
urls.push(imageIdCache.value[id]!) urls.push(imageIdCache.value[id]!)
@@ -468,11 +468,11 @@ const loadImageUrls = async (shops: Shop[]) => {
} }
if (shop.id !== undefined) { if (shop.id !== undefined) {
shopBannerUrls.value[shop.id] = urls shopBannerUrls.value[String(shop.id)] = urls
} }
} else { } else {
if (shop.id !== undefined) { if (shop.id !== undefined) {
shopBannerUrls.value[shop.id] = [] shopBannerUrls.value[String(shop.id)] = []
} }
} }
} }
@@ -481,7 +481,7 @@ const loadImageUrls = async (shops: Shop[]) => {
const getShopImages = (shop: Shop | Record<string, any>): string[] => { const getShopImages = (shop: Shop | Record<string, any>): string[] => {
const shopId = 'id' in shop ? shop.id : (shop as any).id const shopId = 'id' in shop ? shop.id : (shop as any).id
if (shopId !== undefined) { if (shopId !== undefined) {
return shopImageUrls.value[shopId] || [] return shopImageUrls.value[String(shopId)] || []
} }
return [] return []
} }
@@ -489,7 +489,7 @@ const getShopImages = (shop: Shop | Record<string, any>): string[] => {
const getShopBannerImages = (shop: Shop | Record<string, any>): string[] => { const getShopBannerImages = (shop: Shop | Record<string, any>): string[] => {
const shopId = 'id' in shop ? shop.id : (shop as any).id const shopId = 'id' in shop ? shop.id : (shop as any).id
if (shopId !== undefined) { if (shopId !== undefined) {
return shopBannerUrls.value[shopId] || [] return shopBannerUrls.value[String(shopId)] || []
} }
return [] return []
} }
@@ -600,7 +600,7 @@ const handleBannerPreview = async (file: any) => {
} }
if (!imageIdCache.value[fileId]) { if (!imageIdCache.value[fileId]) {
const response = await adminFileApi.getSignedUrl(Number(fileId)) as any const response = await adminFileApi.getSignedUrl(fileId) as any
imageIdCache.value[fileId] = response imageIdCache.value[fileId] = response
} }
bannerPreviewImage.value = imageIdCache.value[fileId] || '' bannerPreviewImage.value = imageIdCache.value[fileId] || ''
@@ -680,7 +680,7 @@ const handlePreview = async (file: any) => {
} }
if (!imageIdCache.value[fileId]) { if (!imageIdCache.value[fileId]) {
const response = await adminFileApi.getSignedUrl(Number(fileId)) as any const response = await adminFileApi.getSignedUrl(fileId) as any
imageIdCache.value[fileId] = response imageIdCache.value[fileId] = response
} }
previewImage.value = imageIdCache.value[fileId] || '' previewImage.value = imageIdCache.value[fileId] || ''
@@ -805,7 +805,7 @@ const showViewModal = async (record: Shop | Record<string, any>) => {
try { try {
// 检查缓存 // 检查缓存
if (!imageIdCache.value[id]) { if (!imageIdCache.value[id]) {
const response = await adminFileApi.getSignedUrl(Number(id || '0')) as any const response = await adminFileApi.getSignedUrl(id.trim()) as any
imageIdCache.value[id] = response imageIdCache.value[id] = response
} }
urls.push(imageIdCache.value[id]!) urls.push(imageIdCache.value[id]!)
@@ -829,7 +829,7 @@ const showViewModal = async (record: Shop | Record<string, any>) => {
try { try {
// 检查缓存 // 检查缓存
if (!imageIdCache.value[id]) { if (!imageIdCache.value[id]) {
const response = await adminFileApi.getSignedUrl(Number(id || '0')) as any const response = await adminFileApi.getSignedUrl(id.trim()) as any
imageIdCache.value[id] = response imageIdCache.value[id] = response
} }
urls.push(imageIdCache.value[id]!) urls.push(imageIdCache.value[id]!)
@@ -879,7 +879,7 @@ const buildShopUploadFileList = async (ids: string[], fileNamePrefix: string) =>
for (const [index, id] of ids.entries()) { for (const [index, id] of ids.entries()) {
try { try {
if (!imageIdCache.value[id]) { if (!imageIdCache.value[id]) {
const response = await adminFileApi.getSignedUrl(Number(id || '0')) as any const response = await adminFileApi.getSignedUrl(id.trim()) as any
imageIdCache.value[id] = response imageIdCache.value[id] = response
} }
fileList.push({ fileList.push({
+2 -1
View File
@@ -192,6 +192,7 @@ import { PlusOutlined } from '@ant-design/icons-vue'
import DraftActions from '@/components/DraftActions.vue' import DraftActions from '@/components/DraftActions.vue'
import { adminTagApi, adminShopApi, type Shop } from '@/api/admin' import { adminTagApi, adminShopApi, type Shop } from '@/api/admin'
import { buildDraftStorageKey, clearDraftRecord, loadDraftRecord, saveDraftRecord } from '@/utils/form-draft' import { buildDraftStorageKey, clearDraftRecord, loadDraftRecord, saveDraftRecord } from '@/utils/form-draft'
import type { IdType } from '@/utils/id'
import { usePermission } from '@/utils/permission' import { usePermission } from '@/utils/permission'
const { hasPermission, loadUserPermissions } = usePermission() const { hasPermission, loadUserPermissions } = usePermission()
@@ -340,7 +341,7 @@ const normalizeShopIdValue = (value: string | number | undefined | null) => {
return String(value) return String(value)
} }
const getShopName = (shopId: number | string | undefined) => { const getShopName = (shopId: IdType | undefined) => {
const normalizedShopId = normalizeShopIdValue(shopId) const normalizedShopId = normalizeShopIdValue(shopId)
const shop = shops.value.find(s => normalizeShopIdValue(s.id) === normalizedShopId) const shop = shops.value.find(s => normalizeShopIdValue(s.id) === normalizedShopId)
return shop ? shop.shopName : '未知店铺' return shop ? shop.shopName : '未知店铺'
+6 -4
View File
@@ -403,6 +403,8 @@ import {
type UserBalanceHistoryItem, type UserBalanceHistoryItem,
type UserVO type UserVO
} from '@/api/admin' } from '@/api/admin'
import type { IdType } from '@/utils/id'
import { sameId } from '@/utils/id'
import { usePermission } from '@/utils/permission' import { usePermission } from '@/utils/permission'
const { hasPermission, hasAnyPermission, loadUserPermissions } = usePermission() const { hasPermission, hasAnyPermission, loadUserPermissions } = usePermission()
@@ -939,7 +941,7 @@ const showViewModal = (record: any) => {
viewModalVisible.value = true viewModalVisible.value = true
} }
const loadUserAssetData = async (userId: number) => { const loadUserAssetData = async (userId: IdType) => {
const [asset, history] = await Promise.all([ const [asset, history] = await Promise.all([
adminUserApi.getUserAsset(userId), adminUserApi.getUserAsset(userId),
adminUserApi.getUserBalanceHistory(userId) adminUserApi.getUserBalanceHistory(userId)
@@ -1080,7 +1082,7 @@ const handleDelete = async (record: any) => {
await fetchUserList() await fetchUserList()
return return
} }
userList.value = userList.value.filter(user => user.id !== record.id) userList.value = userList.value.filter(user => !sameId(user.id, record.id))
pagination.total = Math.max(0, Number(pagination.total || 0) - 1) pagination.total = Math.max(0, Number(pagination.total || 0) - 1)
message.success('已删除用户账号') message.success('已删除用户账号')
await fetchUserList() await fetchUserList()
@@ -1102,7 +1104,7 @@ const handleUnbind = async (record: any) => {
await fetchUserList() await fetchUserList()
return return
} }
userList.value = userList.value.filter(user => user.id !== record.id) userList.value = userList.value.filter(user => !sameId(user.id, record.id))
pagination.total = Math.max(0, Number(pagination.total || 0) - 1) pagination.total = Math.max(0, Number(pagination.total || 0) - 1)
if (currentUserType.value === 2 && record.type === 3) { if (currentUserType.value === 2 && record.type === 3) {
message.success('已解绑当前店铺下的美甲师,并已同步降级为普通用户') message.success('已解绑当前店铺下的美甲师,并已同步降级为普通用户')
@@ -1123,7 +1125,7 @@ const refreshAssetPanel = async () => {
assetLoading.value = true assetLoading.value = true
try { try {
await loadUserAssetData(assetTargetUser.value.id) await loadUserAssetData(assetTargetUser.value.id)
const matchedUser = userList.value.find(user => user.id === assetTargetUser.value?.id) const matchedUser = userList.value.find(user => sameId(user.id, assetTargetUser.value?.id))
if (matchedUser && assetData.value) { if (matchedUser && assetData.value) {
matchedUser.level = assetData.value.vipLevel matchedUser.level = assetData.value.vipLevel
matchedUser.vipId = assetData.value.vipInfoId matchedUser.vipId = assetData.value.vipInfoId
@@ -0,0 +1,18 @@
package com.xiaowang.messagehub.config;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class JacksonConfig {
@Bean
public Jackson2ObjectMapperBuilderCustomizer longToStringJacksonCustomizer() {
return builder -> {
builder.serializerByType(Long.class, ToStringSerializer.instance);
builder.serializerByType(Long.TYPE, ToStringSerializer.instance);
};
}
}
@@ -0,0 +1,18 @@
package com.xiaowang.yuminailcore.config;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class JacksonConfig {
@Bean
public Jackson2ObjectMapperBuilderCustomizer longToStringJacksonCustomizer() {
return builder -> {
builder.serializerByType(Long.class, ToStringSerializer.instance);
builder.serializerByType(Long.TYPE, ToStringSerializer.instance);
};
}
}
@@ -0,0 +1,95 @@
# 2026-03-27 全局雪花 ID 精度治理
## 问题背景
- 系统大量主键、关联键采用雪花 ID,数值已经超出 JavaScript `Number` 安全整数范围。
- 前端多个页面和 API 定义仍把这些 ID 当作 `number` 使用,典型表现包括:
- 路由参数、接口返回值、表单值被 `Number(...)` 强转后精度丢失
- 前端用字符串 ID 和数字 ID 做 `===` 比较时命中失败
- 文件签名 URL、店铺详情、购物车、美甲师选择、后台权限分配等链路出现“明明是同一个 ID 却对不上”的问题
## 根因分析
- 后端此前没有统一把 `Long/long` 序列化为字符串。
- 前端缺少统一的 ID 类型与比较工具,不同页面各自用 `number`、`string | number`、`Number(id)` 混用。
- 即使部分地方已经改成了字符串,只要还有一个环节继续转成 `number`,整个链路就会重新产生精度污染。
## 本次修复
### 1. 后端统一序列化 Long
- 在 [JacksonConfig.java](/E:/code/xiaowang/YumiNail-Core/src/main/java/com/xiaowang/yuminailcore/config/JacksonConfig.java) 中新增全局 Jackson 配置,将 `Long` 和 `long` 统一序列化为字符串。
- 在 [JacksonConfig.java](/E:/code/xiaowang/MessageHub/src/main/java/com/xiaowang/messagehub/config/JacksonConfig.java) 中同步增加相同配置,避免消息中心后续接口再出现同类问题。
### 2. 前端增加统一 ID 工具
- 新增 [id.ts](/E:/code/xiaowang/Frontend/src/utils/id.ts):
- `IdType`
- `toIdString`
- `toOptionalIdString`
- `sameId`
- 用于统一处理 ID 透传、判空和比较,避免页面继续各写一套。
### 3. API 层统一改为 ID 透传
- 调整以下文件中的 ID 类型定义,避免继续把雪花 ID 定义成 `number`:
- [admin.ts](/E:/code/xiaowang/Frontend/src/api/admin.ts)
- [auth.ts](/E:/code/xiaowang/Frontend/src/api/auth.ts)
- [cart.ts](/E:/code/xiaowang/Frontend/src/api/cart.ts)
- [coupon.ts](/E:/code/xiaowang/Frontend/src/api/coupon.ts)
- [file.ts](/E:/code/xiaowang/Frontend/src/api/file.ts)
- [index.ts](/E:/code/xiaowang/Frontend/src/api/index.ts)
- [order.ts](/E:/code/xiaowang/Frontend/src/api/order.ts)
- [permission.ts](/E:/code/xiaowang/Frontend/src/api/permission.ts)
- [product.ts](/E:/code/xiaowang/Frontend/src/api/product.ts)
- [productLike.ts](/E:/code/xiaowang/Frontend/src/api/productLike.ts)
- [shop.ts](/E:/code/xiaowang/Frontend/src/api/shop.ts)
- [tag.ts](/E:/code/xiaowang/Frontend/src/api/tag.ts)
- [user.ts](/E:/code/xiaowang/Frontend/src/api/user.ts)
- [wishlist.ts](/E:/code/xiaowang/Frontend/src/api/wishlist.ts)
### 4. 页面层清理所有高风险 ID 强转
- 重点修复用户侧页面:
- [ProductDetailView.vue](/E:/code/xiaowang/Frontend/src/views/ProductDetailView.vue)
- [ShopDetailView.vue](/E:/code/xiaowang/Frontend/src/views/ShopDetailView.vue)
- [HomeView.vue](/E:/code/xiaowang/Frontend/src/views/HomeView.vue)
- [ProductListView.vue](/E:/code/xiaowang/Frontend/src/views/ProductListView.vue)
- [CartView.vue](/E:/code/xiaowang/Frontend/src/views/CartView.vue)
- [OrderView.vue](/E:/code/xiaowang/Frontend/src/views/OrderView.vue)
- [ArtistOrderView.vue](/E:/code/xiaowang/Frontend/src/views/ArtistOrderView.vue)
- [WishlistView.vue](/E:/code/xiaowang/Frontend/src/views/WishlistView.vue)
- [AuthView.vue](/E:/code/xiaowang/Frontend/src/views/AuthView.vue)
- 重点修复后台页面:
- [AdminLoginView.vue](/E:/code/xiaowang/Frontend/src/views/admin/AdminLoginView.vue)
- [OrdersView.vue](/E:/code/xiaowang/Frontend/src/views/admin/OrdersView.vue)
- [PermissionsView.vue](/E:/code/xiaowang/Frontend/src/views/admin/PermissionsView.vue)
- [ProductsView.vue](/E:/code/xiaowang/Frontend/src/views/admin/ProductsView.vue)
- [ShopsView.vue](/E:/code/xiaowang/Frontend/src/views/admin/ShopsView.vue)
- [TagsView.vue](/E:/code/xiaowang/Frontend/src/views/admin/TagsView.vue)
- [UsersView.vue](/E:/code/xiaowang/Frontend/src/views/admin/UsersView.vue)
## 修复口径
- 所有用于主键、外键、店铺 ID、用户 ID、订单 ID、文件 ID、优惠券 ID 的字段,前端统一视为 `IdType`。
- 所有接口 URL、请求体、查询参数中的 ID 一律直接传字符串,不再手动转 `Number`。
- 所有对象缓存键统一按字符串存储。
- 所有跨来源 ID 比较统一使用 `sameId` 或字符串归一化,不再依赖 `===` 比较数字与字符串。
## 直接收益
- 超大雪花 ID 不再因为浏览器精度问题发生静默污染。
- 用户端和后台端的文件预览、详情页跳转、购物车预约、美甲师订单、权限分配、资产弹窗等链路的 ID 对齐问题同步收敛。
- 后续新增页面只要沿用 `IdType` 和 `sameId`,就能避免重复踩坑。
## SQL 与配置
- 本次无 SQL 变更。
- 本次无 Nacos 配置变更。
## 验证
- 在 [YumiNail-Core](/E:/code/xiaowang/YumiNail-Core) 执行:`mvn -q -DskipTests compile`
- 在 [MessageHub](/E:/code/xiaowang/MessageHub) 执行:`mvn -q -DskipTests compile`
- 在 [Frontend](/E:/code/xiaowang/Frontend) 执行:`npm run build`
- 以上命令均已通过。