feat: reader for comment and like action (#2122)
* init Signed-off-by: Innei <i@innei.in> * update Signed-off-by: Innei <i@innei.in> * feat: reader like activity Signed-off-by: Innei <i@innei.in> * feat: add comment Signed-off-by: Innei <i@innei.in> * feat: comment reader Signed-off-by: Innei <i@innei.in> --------- Signed-off-by: Innei <i@innei.in>
This commit is contained in:
@@ -2,6 +2,7 @@ import type { IRequestAdapter } from '~/interfaces/adapter'
|
||||
import type { IController } from '~/interfaces/controller'
|
||||
import type { PaginationParams } from '~/interfaces/params'
|
||||
import type { IRequestHandler } from '~/interfaces/request'
|
||||
import type { ReaderModel } from '~/models'
|
||||
import type { PaginateResult } from '~/models/base'
|
||||
import type { CommentModel } from '~/models/comment'
|
||||
import type { HTTPClient } from '../core'
|
||||
@@ -31,7 +32,7 @@ export class CommentController<ResponseWrapper> implements IController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 comment id 获取评论, 包括子评论
|
||||
* 根据 comment id 获取评论,包括子评论
|
||||
*/
|
||||
getById(id: string) {
|
||||
return this.proxy(id).get<CommentModel & { ref: string }>()
|
||||
@@ -43,11 +44,13 @@ export class CommentController<ResponseWrapper> implements IController {
|
||||
*/
|
||||
getByRefId(refId: string, pagination: PaginationParams = {}) {
|
||||
const { page, size } = pagination
|
||||
return this.proxy
|
||||
.ref(refId)
|
||||
.get<PaginateResult<CommentModel & { ref: string }>>({
|
||||
params: { page: page || 1, size: size || 10 },
|
||||
})
|
||||
return this.proxy.ref(refId).get<
|
||||
PaginateResult<CommentModel & { ref: string }> & {
|
||||
readers: Record<string, ReaderModel>
|
||||
}
|
||||
>({
|
||||
params: { page: page || 1, size: size || 10 },
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 评论
|
||||
|
||||
@@ -72,10 +72,10 @@ export const allControllerNames = [
|
||||
] as const
|
||||
|
||||
export {
|
||||
AIController,
|
||||
AckController,
|
||||
ActivityController,
|
||||
AggregateController,
|
||||
AIController,
|
||||
CategoryController,
|
||||
CommentController,
|
||||
LinkController,
|
||||
@@ -83,16 +83,15 @@ export {
|
||||
PageController,
|
||||
PostController,
|
||||
ProjectController,
|
||||
RecentlyController,
|
||||
SayController,
|
||||
SearchController,
|
||||
SnippetController,
|
||||
ServerlessController,
|
||||
SubscribeController,
|
||||
UserController,
|
||||
TopicController,
|
||||
|
||||
// Enum
|
||||
RecentlyAttitudeEnum,
|
||||
RecentlyAttitudeResultEnum,
|
||||
RecentlyController,
|
||||
SayController,
|
||||
SearchController,
|
||||
ServerlessController,
|
||||
SnippetController,
|
||||
SubscribeController,
|
||||
TopicController,
|
||||
UserController,
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ export interface CommentModel extends BaseModel {
|
||||
location?: string
|
||||
|
||||
source?: string
|
||||
readerId?: string
|
||||
}
|
||||
export interface CommentRef {
|
||||
id: string
|
||||
|
||||
@@ -10,6 +10,7 @@ export * from './note'
|
||||
export * from './page'
|
||||
export * from './post'
|
||||
export * from './project'
|
||||
export * from './reader'
|
||||
export * from './recently'
|
||||
export * from './say'
|
||||
export * from './setting'
|
||||
|
||||
9
packages/api-client/models/reader.ts
Normal file
9
packages/api-client/models/reader.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export interface ReaderModel {
|
||||
email: string
|
||||
name: string
|
||||
handle: string
|
||||
|
||||
image: string
|
||||
|
||||
isOwner: boolean
|
||||
}
|
||||
Reference in New Issue
Block a user