Browse Source

Add parse repository and service

pull/1310/head
Hironsan 3 years ago
parent
commit
4c2f7347ee
3 changed files with 33 additions and 0 deletions
  1. 3
      frontend/domain/models/upload/parseRepository.ts
  2. 18
      frontend/repositories/upload/apiParseRepository.ts
  3. 12
      frontend/services/application/upload/parseApplicationService.ts

3
frontend/domain/models/upload/parseRepository.ts

@ -0,0 +1,3 @@
export interface ParseRepository {
analyze(projectId: string, format: string, uploadIds: number[]): Promise<string>
}

18
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<string> {
const url = `/projects/${projectId}/upload`
const data = {
format,
uploadIds
}
const response = await this.request.post(url, data)
return response.data.task_id
}
}

12
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<string> {
const item = await this.repository.analyze(projectId, format, uploadIds)
return item
}
}
Loading…
Cancel
Save