Total Complexity | 2 |
Total Lines | 19 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | import { QueryHandler } from '@nestjs/cqrs'; |
||
7 | |||
8 | @QueryHandler(GetShippingCostByIdQuery) |
||
9 | export class GetShippingCostByIdQueryHandler { |
||
10 | constructor( |
||
11 | @Inject('IShippingCostRepository') |
||
12 | private readonly shippingcostRepository: IShippingCostRepository |
||
13 | ) {} |
||
14 | |||
15 | public async execute(query: GetShippingCostByIdQuery): Promise<ShippingCostView> { |
||
16 | const shippingCost = await this.shippingcostRepository.findOneById(query.id); |
||
17 | |||
18 | if (!shippingCost) { |
||
19 | throw new ShippingCostNotFoundException(); |
||
20 | } |
||
21 | |||
22 | return new ShippingCostView( |
||
23 | shippingCost.getId(), |
||
24 | shippingCost.getGrams(), |
||
25 | shippingCost.getPriceFromCents(), |
||
26 | ); |
||
29 |