From ed42153d587015bc21e7a11233798238598c289e Mon Sep 17 00:00:00 2001 From: Hironsan Date: Wed, 9 Feb 2022 13:08:03 +0900 Subject: [PATCH] Update label repository and service --- frontend/domain/models/label/labelRepository.ts | 2 ++ frontend/repositories/label/apiLabelRepository.ts | 6 ++++++ .../services/application/label/labelApplicationService.ts | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/frontend/domain/models/label/labelRepository.ts b/frontend/domain/models/label/labelRepository.ts index 3d0e2786..a38178a9 100644 --- a/frontend/domain/models/label/labelRepository.ts +++ b/frontend/domain/models/label/labelRepository.ts @@ -3,6 +3,8 @@ import { LabelItem } from '~/domain/models/label/label' export interface LabelRepository { list(projectId: string): Promise + findById(projectId: string, labelId: number): Promise + create(projectId: string, item: LabelItem): Promise update(projectId: string, item: LabelItem): Promise diff --git a/frontend/repositories/label/apiLabelRepository.ts b/frontend/repositories/label/apiLabelRepository.ts index 47bd015d..ff35e982 100644 --- a/frontend/repositories/label/apiLabelRepository.ts +++ b/frontend/repositories/label/apiLabelRepository.ts @@ -24,6 +24,12 @@ export class APILabelRepository implements LabelRepository { return response.data.map((item: any) => plainToInstance(LabelItem, item)) } + async findById(projectId: string, labelId: number): Promise { + const url = `/projects/${projectId}/${this.baseUrl}s/${labelId}` + const response = await this.request.get(url) + return plainToInstance(LabelItem, response.data) + } + async create(projectId: string, item: LabelItem): Promise { const url = `/projects/${projectId}/${this.baseUrl}s` const response = await this.request.post(url, item.toObject()) diff --git a/frontend/services/application/label/labelApplicationService.ts b/frontend/services/application/label/labelApplicationService.ts index 31a1e263..15e0c498 100644 --- a/frontend/services/application/label/labelApplicationService.ts +++ b/frontend/services/application/label/labelApplicationService.ts @@ -14,6 +14,11 @@ export class LabelApplicationService { return items.map(item => new LabelDTO(item)) } + public async findById(projectId: string, labelId: number): Promise { + const item = await this.repository.findById(projectId, labelId) + return new LabelDTO(item) + } + public async create(projectId: string, item: CreateLabelCommand): Promise { // Todo: use auto mapping. const label = new LabelItem()