59 lines
1.2 KiB
TypeScript
59 lines
1.2 KiB
TypeScript
import api from './index'
|
|||
|
|
|
||
|
|
export interface ProductVO {
|
||
|
|
id: number
|
||
|
|
shopId: number
|
||
|
|
shopName: string
|
||
|
|
title: string
|
||
|
|
description: string
|
||
|
|
imageFileIds: string
|
||
|
|
imageUrls: string[]
|
||
|
|
price: number
|
||
|
|
tags: string
|
||
|
|
tagList: string[]
|
||
|
|
likeCount: number
|
||
|
|
collectCount: number
|
||
|
|
approximateDuration: string
|
||
|
|
bookableArtists: string
|
||
|
|
availableCoupons: string
|
||
|
|
createTime: string
|
||
|
|
updateTime: string
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface ProductDTO {
|
||
|
|
shopId: number
|
||
|
|
title: string
|
||
|
|
description: string
|
||
|
|
imageFileIds: string
|
||
|
|
price: number
|
||
|
|
tags: string
|
||
|
|
approximateDuration: string
|
||
|
|
bookableArtists: string
|
||
|
|
availableCoupons: string
|
||
|
|
}
|
||
|
|
|
||
|
|
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}`)
|
||
|
|
},
|
||
|
|
|
||
|
|
createProduct: (data: ProductDTO) => {
|
||
|
|
return api.post<ProductVO>('/product/add', data)
|
||
|
|
},
|
||
|
|
|
||
|
|
updateProduct: (id: number, data: ProductDTO) => {
|
||
|
|
return api.put<ProductVO>(`/product/update/${id}`, data)
|
||
|
|
},
|
||
|
|
|
||
|
|
deleteProduct: (id: number) => {
|
||
|
|
return api.delete(`/product/delete/${id}`)
|
||
|
|
}
|
||
|
|
}
|