32 lines
925 B
TypeScript
32 lines
925 B
TypeScript
import api from './index'
|
|||
|
|
import type { IdType } from '@/utils/id'
|
||
|
|
|
||
|
|
export interface CommentVO {
|
||
|
|
id: IdType
|
||
|
|
userId: IdType
|
||
|
|
userNickname?: string
|
||
|
|
shopId?: IdType
|
||
|
|
shopName?: string
|
||
|
|
productId?: IdType
|
||
|
|
productTitle?: string
|
||
|
|
commentContent: string
|
||
|
|
parentCommentId?: IdType
|
||
|
|
parentCommentContent?: string
|
||
|
|
likeCount?: number
|
||
|
|
createTime?: string
|
||
|
|
updateTime?: string
|
||
|
|
replies?: CommentVO[]
|
||
|
|
}
|
||
|
|
|
||
|
|
export const commentApi = {
|
||
|
|
listByProduct: (productId: IdType) => {
|
||
|
|
return api.get<CommentVO[]>(`/comment/list/product/${productId}`) as unknown as Promise<CommentVO[]>
|
||
|
|
},
|
||
|
|
create: (data: { productId: IdType; shopId?: IdType | null; parentCommentId?: IdType | null; commentContent: string }) => {
|
||
|
|
return api.post<IdType>('/comment/create', data) as unknown as Promise<IdType>
|
||
|
|
},
|
||
|
|
delete: (id: IdType) => {
|
||
|
|
return api.delete<boolean>(`/comment/delete/${id}`) as unknown as Promise<boolean>
|
||
|
|
}
|
||
|
|
}
|