Browse Source

Remove CommentItemList

pull/2146/head
Hironsan 1 year ago
parent
commit
aaff695c6a
4 changed files with 11 additions and 17 deletions
  1. 9
      frontend/domain/models/comment/comment.ts
  2. 5
      frontend/domain/models/comment/commentRepository.ts
  3. 9
      frontend/repositories/comment/apiCommentRepository.ts
  4. 5
      frontend/services/application/comment/commentData.ts

9
frontend/domain/models/comment/comment.ts

@ -12,12 +12,3 @@ export class CommentItem {
return this.user === userId
}
}
export class CommentItemList {
constructor(
readonly count: number,
readonly next: string | null,
readonly prev: string | null,
readonly items: CommentItem[]
) {}
}

5
frontend/domain/models/comment/commentRepository.ts

@ -1,9 +1,10 @@
import { CommentItem, CommentItemList } from '~/domain/models/comment/comment'
import { Page } from '@/domain/models/page'
import { CommentItem } from '~/domain/models/comment/comment'
export type SearchOption = { [key: string]: string | (string | null)[] }
export interface CommentRepository {
listAll(projectId: string, { limit, offset, q }: SearchOption): Promise<CommentItemList>
listAll(projectId: string, { limit, offset, q }: SearchOption): Promise<Page<CommentItem>>
list(projectId: string, docId: number): Promise<CommentItem[]>

9
frontend/repositories/comment/apiCommentRepository.ts

@ -1,6 +1,7 @@
import ApiService from '@/services/api.service'
import { CommentItem } from '@/domain/models/comment/comment'
import { CommentRepository, SearchOption } from '@/domain/models/comment/commentRepository'
import { CommentItem, CommentItemList } from '@/domain/models/comment/comment'
import { Page } from '@/domain/models/page'
import ApiService from '@/services/api.service'
function toModel(item: { [key: string]: any }): CommentItem {
return new CommentItem(
@ -27,10 +28,10 @@ export class APICommentRepository implements CommentRepository {
async listAll(
projectId: string,
{ limit = '10', offset = '0', q = '' }: SearchOption
): Promise<CommentItemList> {
): Promise<Page<CommentItem>> {
const url = `/projects/${projectId}/comments?q=${q}&limit=${limit}&offset=${offset}`
const response = await this.request.get(url)
return new CommentItemList(
return new Page(
response.data.count,
response.data.next,
response.data.previous,

5
frontend/services/application/comment/commentData.ts

@ -1,4 +1,5 @@
import { CommentItem, CommentItemList } from '~/domain/models/comment/comment'
import { Page } from '@/domain/models/page'
import { CommentItem } from '~/domain/models/comment/comment'
export class CommentReadDTO {
id: number
@ -24,7 +25,7 @@ export class CommentListDTO {
prev: string | null
items: CommentReadDTO[]
constructor(item: CommentItemList) {
constructor(item: Page<CommentItem>) {
this.count = item.count
this.next = item.next
this.prev = item.prev

Loading…
Cancel
Save