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:
Innei
2024-09-14 20:26:18 +08:00
committed by GitHub
parent ced1a20c15
commit 26b2b4f134
20 changed files with 230 additions and 43 deletions

View File

@@ -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 },
})
}
/**
* 评论

View File

@@ -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,
}

View File

@@ -27,6 +27,7 @@ export interface CommentModel extends BaseModel {
location?: string
source?: string
readerId?: string
}
export interface CommentRef {
id: string

View File

@@ -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'

View File

@@ -0,0 +1,9 @@
export interface ReaderModel {
email: string
name: string
handle: string
image: string
isOwner: boolean
}