Skip to content

Commit

Permalink
_id to id
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfganggreschus committed Sep 28, 2023
1 parent 862e587 commit 11f068f
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -17,7 +17,7 @@ export class FederalStateResponse {
}

@ApiProperty()
_id: string;
id: string;

@ApiProperty()
@DecodeHtmlEntities()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export interface CountyProps {
name: string;
countyId: number;
antaresKey: string;
antaresKey?: string;
}

export class CountyDO {
Expand All @@ -19,7 +19,7 @@ export class CountyDO {
return this.props.countyId;
}

get antaresKey(): string {
get antaresKey(): string | undefined {
return this.props.antaresKey;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -60,13 +61,12 @@ export class FederalStateRepo extends BaseRepo<FederalStateEntity> {
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;
}
}
6 changes: 3 additions & 3 deletions apps/server/src/modules/federal-state/uc/federal-state.uc.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -11,7 +12,7 @@ export class FederalStateUC {
private readonly authorizationService: AuthorizationService
) {}

async findAllFederalStates(userId: EntityId) {
async findAllFederalStates(userId: EntityId): Promise<FederalStateDO[]> {
const user = await this.authorizationService.getUserWithPermissions(userId);

this.authorizationService.checkOneOfPermissions(user, [Permission.FEDERALSTATE_VIEW]);
Expand All @@ -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);
}
}

0 comments on commit 11f068f

Please sign in to comment.