完成JC-ArtList与JC-Salon端侧清理和统一命名

This commit is contained in:
2026-08-25 16:21:05 +08:00
parent aa93695704
commit abce4a2787
1839 changed files with 653 additions and 50415 deletions
+114
View File
@@ -0,0 +1,114 @@
/**
* 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 { AxiosProgressEvent } from 'axios'
import type { ChunkUploadInitRequest, ChunkUploadSessionVO } from '@/api/file'
import type { IdType } from '@/utils/id'
/**
* Purpose: CommentVO supports comment.ts by holding or executing the comment 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 CommentVO {
id: IdType
userId: IdType
userNickname?: string
shopId?: IdType
shopName?: string
productId?: IdType
productTitle?: string
commentContent: string
parentCommentId?: IdType
parentCommentContent?: string
likeCount?: number
ratingScore?: number
imageFileIds?: IdType[]
imageUrls?: string[]
createTime?: string
updateTime?: string
replies?: CommentVO[]
}
export interface CommentCreateRequest {
productId: IdType
shopId?: IdType | null
parentCommentId?: IdType | null
commentContent: string
ratingScore?: number
imageFileIds?: IdType[]
}
export interface CommentImageFileVO {
id: IdType
fileName?: string
fileUrl?: string
createTime?: string
}
/**
* commentApi 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 commentApi = {
/**
* `listByProduct` 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`
*/
listByProduct: (productId: IdType) => {
return api.get<CommentVO[]>(`/comment/list/product/${productId}`) as unknown as Promise<CommentVO[]>
},
/**
* `create` 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 data: { productId: IdType; shopId?: IdType | null; parentCommentId?: IdType | null; commentContent: string } caller-supplied value for `data: { productId: IdType; shopId?: IdType | null; parentCommentId?: IdType | null; commentContent: string }`
*/
create: (data: CommentCreateRequest) => {
return api.post<IdType>('/comment/create', data) as unknown as Promise<IdType>
},
uploadImage: (file: File) => {
const formData = new FormData()
formData.append('file', file)
return api.post<CommentImageFileVO>('/comment/upload-image', formData, {
headers: {
'Content-Type': 'multipart/form-data'
}
}) as unknown as Promise<CommentImageFileVO>
},
initImageChunkUpload: (data: ChunkUploadInitRequest) => {
return api.post<ChunkUploadSessionVO>('/comment/upload-image/init', data) as unknown as Promise<ChunkUploadSessionVO>
},
uploadImageChunk: (
data: { uploadId: string; chunkIndex: number; totalChunks: number; chunk: Blob },
config?: { signal?: AbortSignal; onUploadProgress?: (event: AxiosProgressEvent) => void }
) => {
const formData = new FormData()
formData.append('uploadId', data.uploadId)
formData.append('chunkIndex', String(data.chunkIndex))
formData.append('totalChunks', String(data.totalChunks))
formData.append('chunk', data.chunk)
return api.post<boolean>('/comment/upload-image/chunk', formData, {
headers: {
'Content-Type': 'multipart/form-data'
},
signal: config?.signal,
onUploadProgress: config?.onUploadProgress
})
},
completeImageChunkUpload: (uploadId: string) => {
return api.post<CommentImageFileVO>('/comment/upload-image/complete', { uploadId }) as unknown as Promise<CommentImageFileVO>
},
cancelImageChunkUpload: (uploadId: string) => {
return api.delete<boolean>(`/comment/upload-image/${uploadId}`)
},
/**
* `delete` 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 id: IdType caller-supplied value for `id: IdType`
*/
delete: (id: IdType) => {
return api.delete<boolean>(`/comment/delete/${id}`) as unknown as Promise<boolean>
}
}