From 4c2f7347ee0b40208ae7a1bc0cab06946a763b6e Mon Sep 17 00:00:00 2001 From: Hironsan Date: Thu, 8 Apr 2021 13:43:50 +0900 Subject: [PATCH] Add parse repository and service --- .../domain/models/upload/parseRepository.ts | 3 +++ .../repositories/upload/apiParseRepository.ts | 18 ++++++++++++++++++ .../upload/parseApplicationService.ts | 12 ++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 frontend/domain/models/upload/parseRepository.ts create mode 100644 frontend/repositories/upload/apiParseRepository.ts create mode 100644 frontend/services/application/upload/parseApplicationService.ts diff --git a/frontend/domain/models/upload/parseRepository.ts b/frontend/domain/models/upload/parseRepository.ts new file mode 100644 index 00000000..519b6ef5 --- /dev/null +++ b/frontend/domain/models/upload/parseRepository.ts @@ -0,0 +1,3 @@ +export interface ParseRepository { + analyze(projectId: string, format: string, uploadIds: number[]): Promise +} diff --git a/frontend/repositories/upload/apiParseRepository.ts b/frontend/repositories/upload/apiParseRepository.ts new file mode 100644 index 00000000..c36ba4c6 --- /dev/null +++ b/frontend/repositories/upload/apiParseRepository.ts @@ -0,0 +1,18 @@ +import ApiService from '@/services/api.service' +import { ParseRepository } from '@/domain/models/upload/parseRepository' + +export class APIParseRepository implements ParseRepository { + constructor( + private readonly request = ApiService + ) {} + + async analyze(projectId: string, format: string, uploadIds: number[]): Promise { + const url = `/projects/${projectId}/upload` + const data = { + format, + uploadIds + } + const response = await this.request.post(url, data) + return response.data.task_id + } +} diff --git a/frontend/services/application/upload/parseApplicationService.ts b/frontend/services/application/upload/parseApplicationService.ts new file mode 100644 index 00000000..8d68c2cd --- /dev/null +++ b/frontend/services/application/upload/parseApplicationService.ts @@ -0,0 +1,12 @@ +import { ParseRepository } from '~/domain/models/upload/parseRepository' + +export class ParseApplicationService { + constructor( + private readonly repository: ParseRepository + ) {} + + public async analyze(projectId: string, format: string, uploadIds: number[]): Promise { + const item = await this.repository.analyze(projectId, format, uploadIds) + return item + } +}