52 lines
1.9 KiB
TypeScript
52 lines
1.9 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'
|
|
|
|
/**
|
|
* productLikeApi 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 productLikeApi = {
|
|
/**
|
|
* 点赞作品
|
|
* @param productId 作品ID
|
|
*/
|
|
/**
|
|
* `likeProduct` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|
* @param productId: IdType caller-supplied value for `productId: IdType`
|
|
*/
|
|
likeProduct: (productId: IdType) => {
|
|
return api.post<boolean>(`/product-like/like/${productId}`)
|
|
},
|
|
|
|
/**
|
|
* 取消点赞作品
|
|
* @param productId 作品ID
|
|
*/
|
|
/**
|
|
* `unlikeProduct` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|
* @param productId: IdType caller-supplied value for `productId: IdType`
|
|
*/
|
|
unlikeProduct: (productId: IdType) => {
|
|
return api.post<boolean>(`/product-like/unlike/${productId}`)
|
|
},
|
|
|
|
/**
|
|
* 检查用户是否已点赞作品
|
|
* @param productId 作品ID
|
|
*/
|
|
/**
|
|
* `checkLikeStatus` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
|
* @param productId: IdType caller-supplied value for `productId: IdType`
|
|
*/
|
|
checkLikeStatus: (productId: IdType) => {
|
|
return api.get<boolean>(`/product-like/check/${productId}`)
|
|
}
|
|
}
|