From 11f068f1e85594a5970e031a41b8806ffda7a752 Mon Sep 17 00:00:00 2001 From: Wolfgang Date: Thu, 28 Sep 2023 13:56:23 +0200 Subject: [PATCH] _id to id --- .../controller/dto/federal-state.response.ts | 6 +++--- .../federal-state/controller/federal-state.controller.ts | 4 +--- .../controller/mapper/federal-state.mapper.ts | 6 +++--- .../src/modules/federal-state/domainobject/county.do.ts | 4 ++-- .../src/modules/federal-state/repo/federal-state.repo.ts | 8 ++++---- .../src/modules/federal-state/uc/federal-state.uc.ts | 6 +++--- 6 files changed, 16 insertions(+), 18 deletions(-) diff --git a/apps/server/src/modules/federal-state/controller/dto/federal-state.response.ts b/apps/server/src/modules/federal-state/controller/dto/federal-state.response.ts index 07e3ac46a9b..6ef1bea8dd5 100644 --- a/apps/server/src/modules/federal-state/controller/dto/federal-state.response.ts +++ b/apps/server/src/modules/federal-state/controller/dto/federal-state.response.ts @@ -6,8 +6,8 @@ import { CountyResponse } from './county.response'; * DTO for returning a task document via api. */ export class FederalStateResponse { - constructor({ _id, name, abbreviation, logoUrl, counties, createdAt, updatedAt }: FederalStateResponse) { - this._id = _id; + constructor({ id, name, abbreviation, logoUrl, counties, createdAt, updatedAt }: FederalStateResponse) { + this.id = id; this.name = name; this.abbreviation = abbreviation; this.logoUrl = logoUrl; @@ -17,7 +17,7 @@ export class FederalStateResponse { } @ApiProperty() - _id: string; + id: string; @ApiProperty() @DecodeHtmlEntities() diff --git a/apps/server/src/modules/federal-state/controller/federal-state.controller.ts b/apps/server/src/modules/federal-state/controller/federal-state.controller.ts index ea7dffd1f7c..f02fee667f4 100644 --- a/apps/server/src/modules/federal-state/controller/federal-state.controller.ts +++ b/apps/server/src/modules/federal-state/controller/federal-state.controller.ts @@ -49,8 +49,6 @@ export class FederalStateController { @ApiResponse({ status: 404, type: NotFoundException, description: 'federal state is not found.' }) @Delete(':id') async deleteFederalState(@CurrentUser() currentUser: ICurrentUser, @Param('id') id: string) { - const federalStateDo = await this.federalStateUC.deleteFederalState(id, currentUser.userId); - const federalStateResponse = FederalStateMapper.mapFederalStateToResponse(federalStateDo); - return federalStateResponse; + await this.federalStateUC.deleteFederalState(id, currentUser.userId); } } diff --git a/apps/server/src/modules/federal-state/controller/mapper/federal-state.mapper.ts b/apps/server/src/modules/federal-state/controller/mapper/federal-state.mapper.ts index 9f7f4046163..8fb6742941f 100644 --- a/apps/server/src/modules/federal-state/controller/mapper/federal-state.mapper.ts +++ b/apps/server/src/modules/federal-state/controller/mapper/federal-state.mapper.ts @@ -5,7 +5,7 @@ import { FederalStateResponse } from '../dto/federal-state.response'; export class FederalStateMapper { static mapFederalStateToResponse(federalStateDO: FederalStateDO): FederalStateResponse { const dto = new FederalStateResponse({ - _id: federalStateDO.id, + id: federalStateDO.id, name: federalStateDO.name, abbreviation: federalStateDO.abbreviation, counties: federalStateDO.counties @@ -19,11 +19,11 @@ export class FederalStateMapper { } static mapCountyToResponse(county: ICounty) { - const countyResponse = { + const countyResponse = new CountyResponse({ name: county.name, countyId: county.countyId, antaresKey: county.antaresKey, - }; + }); return countyResponse; } } diff --git a/apps/server/src/modules/federal-state/domainobject/county.do.ts b/apps/server/src/modules/federal-state/domainobject/county.do.ts index c9f95edf356..6797e9e9cc4 100644 --- a/apps/server/src/modules/federal-state/domainobject/county.do.ts +++ b/apps/server/src/modules/federal-state/domainobject/county.do.ts @@ -1,7 +1,7 @@ export interface CountyProps { name: string; countyId: number; - antaresKey: string; + antaresKey?: string; } export class CountyDO { @@ -19,7 +19,7 @@ export class CountyDO { return this.props.countyId; } - get antaresKey(): string { + get antaresKey(): string | undefined { return this.props.antaresKey; } } diff --git a/apps/server/src/modules/federal-state/repo/federal-state.repo.ts b/apps/server/src/modules/federal-state/repo/federal-state.repo.ts index 32042b7257d..18253df4c83 100644 --- a/apps/server/src/modules/federal-state/repo/federal-state.repo.ts +++ b/apps/server/src/modules/federal-state/repo/federal-state.repo.ts @@ -2,6 +2,7 @@ import { EntityName } from '@mikro-orm/core'; import { Injectable } from '@nestjs/common'; import { BaseRepo } from '@shared/repo/base.repo'; import { FederalStateDO } from '../domainobject'; +import { CountyDO } from '../domainobject/county.do'; import { County, FederalStateEntity } from '../entity'; import { IFederalStateCreate } from '../interface'; @@ -60,13 +61,12 @@ export class FederalStateRepo extends BaseRepo { return federalStateDo; } - mapCountyEntityToDomainObject(countyEntity: County) { - console.log('countyEntity', countyEntity); - const county = { + mapCountyEntityToDomainObject(countyEntity: County): CountyDO { + const county = new CountyDO({ name: countyEntity.name, countyId: countyEntity.countyId, antaresKey: countyEntity.antaresKey, - }; + }); return county; } } diff --git a/apps/server/src/modules/federal-state/uc/federal-state.uc.ts b/apps/server/src/modules/federal-state/uc/federal-state.uc.ts index d967f48171b..6b937a4f13d 100644 --- a/apps/server/src/modules/federal-state/uc/federal-state.uc.ts +++ b/apps/server/src/modules/federal-state/uc/federal-state.uc.ts @@ -1,6 +1,7 @@ import { Injectable } from '@nestjs/common'; import { EntityId, Permission } from '@shared/domain'; import { AuthorizationService } from '@src/modules/authorization'; +import { FederalStateDO } from '../domainobject'; import { IFederalStateCreate } from '../interface'; import { FederalStateService } from '../service/federal-state.service'; @@ -11,7 +12,7 @@ export class FederalStateUC { private readonly authorizationService: AuthorizationService ) {} - async findAllFederalStates(userId: EntityId) { + async findAllFederalStates(userId: EntityId): Promise { const user = await this.authorizationService.getUserWithPermissions(userId); this.authorizationService.checkOneOfPermissions(user, [Permission.FEDERALSTATE_VIEW]); @@ -37,7 +38,6 @@ export class FederalStateUC { const user = await this.authorizationService.getUserWithPermissions(userId); this.authorizationService.checkOneOfPermissions(user, [Permission.FEDERALSTATE_EDIT]); - const deletedFederalState = await this.federalStateService.delete(id); - return deletedFederalState; + await this.federalStateService.delete(id); } }