From 08ea41e8f7e4a863c9fed18299544c3687ab30c2 Mon Sep 17 00:00:00 2001 From: Hironsan Date: Thu, 11 Mar 2021 13:29:47 +0900 Subject: [PATCH] Add text classification service --- .../tasks/text.classification.service.ts | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 frontend/services/application/tasks/text.classification.service.ts diff --git a/frontend/services/application/tasks/text.classification.service.ts b/frontend/services/application/tasks/text.classification.service.ts new file mode 100644 index 00000000..e24ec941 --- /dev/null +++ b/frontend/services/application/tasks/text.classification.service.ts @@ -0,0 +1,33 @@ +import { TextClassificationItem } from '@/models/tasks/text-classification' +import { TextClassificationRepository } from '@/repositories/tasks/text-classification/interface' + +export class TextClassificationDTO { + id: number + label: number + user: number + + constructor(item: TextClassificationItem) { + this.id = item.id + this.label = item.label + this.user = item.user + } +} + +export class TextClassificationApplicationService { + constructor( + private readonly repository: TextClassificationRepository + ) {} + + public async list(projectId: string, docId: number): Promise { + const items = await this.repository.list(projectId, docId) + return items.map(item => new TextClassificationDTO(item)) + } + + public async create(projectId: string, docId: number, labelId: number): Promise { + await this.repository.create(projectId, docId, labelId) + } + + public async delete(projectId: string, docId: number, annotationId: number): Promise { + await this.repository.delete(projectId, docId, annotationId) + } +}