Files
JayuCloud/JC-Salon-Frontend/src/api/shop.ts
T

185 lines
5.4 KiB
TypeScript

/**
* Front-end API wrapper for this module.
* Call guide: import the named API object, then call the matching method from a Vue page or composable.
*/
import api from './index'
import type { IdType } from '@/utils/id'
/**
* Purpose: ShopVO supports shop.ts by holding or executing the shop vo page or API role.
* Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow.
*/
export interface ShopVO {
id: IdType
shopName: string
description: string
address: string
mapProvider?: string
longitude?: number | string
latitude?: number | string
navigationUrls?: Record<string, string>
businessHours: string
status?: number
authorizationStartDate?: string
authorizationDays?: number
authorizationExpireTime?: string
authorizationExpired?: boolean
authorizationStatusText?: string
coverImageFileId?: string
coverImageUrls?: string[]
imageFileIds: string
imageUrls?: string[]
themePrimaryColor?: string
themeSecondaryColor?: string
themeAccentColor?: string
themePageBgColor?: string
themeCardBgColor?: string
themeBackgroundImageFileId?: string
createTime: string
updateTime: string
}
/**
* Purpose: ShopSimpleVO supports shop.ts by holding or executing the shop simple vo page or API role.
* Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow.
*/
export interface ShopSimpleVO {
id: string | number
shopName?: string
name?: string
}
/**
* Purpose: ShopTrustProfileVO carries public trust signals for a shop detail page.
* Usage: fetch it with getTrustProfile and render ratings, recent reviews, environment images, and booking hints.
*/
export interface ShopTrustProfileVO {
shopId: IdType
shopName?: string
businessHoursText?: string
businessStatusText?: string
locationAvailable?: boolean
distanceCapabilityText?: string
navigationAvailable?: boolean
stats?: {
averageRating?: number
reviewCount?: number
productCount?: number
artistCount?: number
recentReviewCount?: number
}
environmentImages?: string[]
featuredProducts?: Array<{
id: IdType
title?: string
imageUrl?: string
imageFileIds?: string
price?: number
likeCount?: number
collectCount?: number
availableBookableArtistCount?: number
bookingHint?: string
}>
recentReviews?: Array<{
id: IdType
productId?: IdType
productTitle?: string
ratingScore?: number
content?: string
imageUrls?: string[]
submittedAt?: string
}>
availabilitySummary?: {
available?: boolean
summaryText?: string
nextSlots?: string[]
}
contactSummary?: {
actionText?: string
phoneExposed?: boolean
phone?: string
}
}
/**
* Purpose: ListShopsParams supports shop.ts by holding or executing the list shops params page or API role.
* Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow.
*/
export interface ListShopsParams {
page: number
size: number
keyword?: string
}
/**
* Purpose: CreateShopRequest supports shop.ts by holding or executing the create shop request page or API role.
* Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow.
*/
export interface CreateShopRequest {
name: string
description: string
image: string
phone: string
address: string
businessHours: string
status: number
authorizationStartDate?: string
authorizationDays?: number
authorizationExpireTime?: string
themePrimaryColor?: string
themeSecondaryColor?: string
themeAccentColor?: string
themePageBgColor?: string
themeCardBgColor?: string
themeBackgroundImageFileId?: string
}
/**
* Purpose: UpdateShopRequest supports shop.ts by holding or executing the update shop request page or API role.
* Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow.
*/
export interface UpdateShopRequest {
name?: string
description?: string
image?: string
phone?: string
address?: string
businessHours?: string
status?: number
authorizationStartDate?: string
authorizationDays?: number
authorizationExpireTime?: string
themePrimaryColor?: string
themeSecondaryColor?: string
themeAccentColor?: string
themePageBgColor?: string
themeCardBgColor?: string
themeBackgroundImageFileId?: string
}
/**
* shopApi groups all API calls for this page domain.
* Call guide: pass the typed payload or identifier into the method below, and use the returned Promise in the page script.
*/
export const shopApi = {
getAllShops: async (): Promise<ShopVO[]> => {
return await api.get<ShopVO[]>('/shop/list/all') as unknown as ShopVO[]
},
getPublicShops: async (): Promise<ShopVO[]> => {
return await api.get<ShopVO[]>('/shop/list/public') as unknown as ShopVO[]
},
getShopsSimple: async (): Promise<ShopSimpleVO[]> => {
return await api.get<ShopSimpleVO[]>('/shop/list/simple') as unknown as ShopSimpleVO[]
},
getShopById: async (id: IdType): Promise<ShopVO> => {
return await api.get<ShopVO>(`/shop/get/${id}`) as unknown as ShopVO
},
getTrustProfile: async (id: IdType): Promise<ShopTrustProfileVO> => {
return await api.get<ShopTrustProfileVO>(`/shop/trust-profile/${id}`) as unknown as ShopTrustProfileVO
}
}