2026-02-24 09:59:22 +08:00
|
|
|
import api from './index'
|
|
|
|
|
|
|
|
|
|
export interface ProductVO {
|
|
|
|
|
id: number
|
2026-02-25 10:37:16 +08:00
|
|
|
shopId: number | null
|
2026-03-03 17:50:10 +08:00
|
|
|
shopName?: string
|
2026-02-25 10:37:16 +08:00
|
|
|
name: string
|
2026-03-03 17:50:10 +08:00
|
|
|
title?: string
|
2026-02-24 09:59:22 +08:00
|
|
|
description: string
|
2026-02-25 10:37:16 +08:00
|
|
|
image: string
|
2026-03-03 17:50:10 +08:00
|
|
|
imageFileIds?: string
|
|
|
|
|
imageUrls?: string[]
|
2026-02-24 09:59:22 +08:00
|
|
|
price: number
|
2026-02-25 10:37:16 +08:00
|
|
|
estimatedTime: number
|
2026-03-03 17:50:10 +08:00
|
|
|
approximateDuration?: string
|
2026-02-25 10:37:16 +08:00
|
|
|
category: string
|
2026-03-03 17:50:10 +08:00
|
|
|
tags?: string
|
|
|
|
|
tagList?: string[]
|
|
|
|
|
tagInfos?: TagInfo[]
|
2026-02-25 10:37:16 +08:00
|
|
|
status: number
|
2026-03-03 17:50:10 +08:00
|
|
|
likeCount?: number
|
|
|
|
|
collectCount?: number
|
2026-02-24 09:59:22 +08:00
|
|
|
createTime: string
|
|
|
|
|
updateTime: string
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-03 17:50:10 +08:00
|
|
|
export interface TagInfo {
|
|
|
|
|
id: number
|
|
|
|
|
tagName: string
|
|
|
|
|
textColor?: string
|
|
|
|
|
bgColor?: string
|
|
|
|
|
borderColor?: string
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-25 10:37:16 +08:00
|
|
|
export interface ListProductsParams {
|
|
|
|
|
page: number
|
|
|
|
|
size: number
|
|
|
|
|
keyword?: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface CreateProductRequest {
|
|
|
|
|
name: string
|
2026-02-24 09:59:22 +08:00
|
|
|
description: string
|
2026-02-25 10:37:16 +08:00
|
|
|
image: string
|
2026-02-24 09:59:22 +08:00
|
|
|
price: number
|
2026-02-25 10:37:16 +08:00
|
|
|
estimatedTime: number
|
|
|
|
|
category: string
|
|
|
|
|
status: number
|
|
|
|
|
shopId: number | null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface UpdateProductRequest {
|
|
|
|
|
name?: string
|
|
|
|
|
description?: string
|
|
|
|
|
image?: string
|
|
|
|
|
price?: number
|
|
|
|
|
estimatedTime?: number
|
|
|
|
|
category?: string
|
|
|
|
|
status?: number
|
|
|
|
|
shopId?: number | null
|
2026-02-24 09:59:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const productApi = {
|
|
|
|
|
getAllProducts: () => {
|
|
|
|
|
return api.get<ProductVO[]>('/product/list/all')
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getProductById: (id: number) => {
|
|
|
|
|
return api.get<ProductVO>(`/product/get/${id}`)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getProductsByTag: (tag: string) => {
|
|
|
|
|
return api.get<ProductVO[]>(`/product/list/tag/${tag}`)
|
2026-03-05 15:15:59 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
likeProduct: (productId: number) => {
|
|
|
|
|
return api.post<boolean>(`/product/like/${productId}`)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
unlikeProduct: (productId: number) => {
|
|
|
|
|
return api.post<boolean>(`/product/unlike/${productId}`)
|
2026-03-05 16:02:34 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
searchProducts: (keyword: string) => {
|
|
|
|
|
return api.get<ProductVO[]>('/product/list/search', {
|
|
|
|
|
params: {
|
|
|
|
|
keyword: keyword
|
|
|
|
|
}
|
|
|
|
|
})
|
2026-02-24 09:59:22 +08:00
|
|
|
}
|
2026-02-25 10:37:16 +08:00
|
|
|
}
|