mirror of https://github.com/doccano/doccano.git
Hironsan
1 year ago
9 changed files with 32 additions and 121 deletions
Split View
Diff Options
-
6frontend/components/comment/Comment.vue
-
6frontend/components/comment/CommentList.vue
-
16frontend/components/tasks/toolbar/forms/FormComment.vue
-
18frontend/domain/models/comment/commentRepository.ts
-
11frontend/pages/projects/_id/comments/index.vue
-
3frontend/plugins/services.ts
-
20frontend/repositories/comment/apiCommentRepository.ts
-
39frontend/services/application/comment/commentApplicationService.ts
-
34frontend/services/application/comment/commentData.ts
@ -1,18 +0,0 @@ |
|||
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<Page<CommentItem>> |
|||
|
|||
list(projectId: string, docId: number): Promise<CommentItem[]> |
|||
|
|||
create(projectId: string, docId: number, text: string): Promise<CommentItem> |
|||
|
|||
update(projectId: string, item: CommentItem): Promise<CommentItem> |
|||
|
|||
delete(projectId: string, commentId: number): Promise<void> |
|||
|
|||
deleteBulk(projectId: string, items: number[]): Promise<void> |
|||
} |
@ -1,39 +0,0 @@ |
|||
import { plainToInstance } from 'class-transformer' |
|||
import { CommentReadDTO, CommentListDTO } from './commentData' |
|||
import { CommentRepository, SearchOption } from '~/domain/models/comment/commentRepository' |
|||
import { CommentItem } from '~/domain/models/comment/comment' |
|||
|
|||
export class CommentApplicationService { |
|||
constructor(private readonly repository: CommentRepository) {} |
|||
|
|||
public async listProjectComment( |
|||
projectId: string, |
|||
options: SearchOption |
|||
): Promise<CommentListDTO> { |
|||
const item = await this.repository.listAll(projectId, options) |
|||
return new CommentListDTO(item) |
|||
} |
|||
|
|||
public async list(projectId: string, docId: number): Promise<CommentReadDTO[]> { |
|||
const items = await this.repository.list(projectId, docId) |
|||
return items.map((item) => new CommentReadDTO(item)) |
|||
} |
|||
|
|||
public create(projectId: string, docId: number, text: string): Promise<CommentItem> { |
|||
return this.repository.create(projectId, docId, text) |
|||
} |
|||
|
|||
public update(projectId: string, item: CommentReadDTO): Promise<CommentItem> { |
|||
const comment = plainToInstance(CommentItem, item) |
|||
return this.repository.update(projectId, comment) |
|||
} |
|||
|
|||
public delete(projectId: string, item: CommentReadDTO): Promise<void> { |
|||
return this.repository.delete(projectId, item.id) |
|||
} |
|||
|
|||
public deleteBulk(projectId: string, items: CommentReadDTO[]): Promise<void> { |
|||
const ids = items.map((item) => item.id) |
|||
return this.repository.deleteBulk(projectId, ids) |
|||
} |
|||
} |
@ -1,34 +0,0 @@ |
|||
import { Page } from '@/domain/models/page' |
|||
import { CommentItem } from '~/domain/models/comment/comment' |
|||
|
|||
export class CommentReadDTO { |
|||
id: number |
|||
user: number |
|||
username: string |
|||
example: number |
|||
text: string |
|||
createdAt: string |
|||
|
|||
constructor(item: CommentItem) { |
|||
this.id = item.id |
|||
this.user = item.user |
|||
this.username = item.username |
|||
this.example = item.example |
|||
this.text = item.text |
|||
this.createdAt = item.createdAt |
|||
} |
|||
} |
|||
|
|||
export class CommentListDTO { |
|||
count: number |
|||
next: string | null |
|||
prev: string | null |
|||
items: CommentReadDTO[] |
|||
|
|||
constructor(item: Page<CommentItem>) { |
|||
this.count = item.count |
|||
this.next = item.next |
|||
this.prev = item.prev |
|||
this.items = item.items.map((_) => new CommentReadDTO(_)) |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save