refactor dtos to ports
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import { Result } from '@core/shared/application/Result';
|
||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||
import type { IDriverRepository } from '../../domain/repositories/IDriverRepository';
|
||||
import type { DriverDTO } from '../dto/DriverDTO';
|
||||
import { EntityMappers } from '../mappers/EntityMappers';
|
||||
import type { Driver } from '../../domain/entities/Driver';
|
||||
|
||||
export interface UpdateDriverProfileInput {
|
||||
driverId: string;
|
||||
@@ -12,12 +11,13 @@ export interface UpdateDriverProfileInput {
|
||||
|
||||
/**
|
||||
* Application use case responsible for updating basic driver profile details.
|
||||
* Encapsulates domain entity mutation and mapping to a DriverDTO.
|
||||
* Encapsulates domain entity mutation and returns the updated entity.
|
||||
* Mapping to DTOs is handled by presenters in the presentation layer.
|
||||
*/
|
||||
export class UpdateDriverProfileUseCase {
|
||||
constructor(private readonly driverRepository: IDriverRepository) {}
|
||||
|
||||
async execute(input: UpdateDriverProfileInput): Promise<Result<DriverDTO, ApplicationErrorCode<'DRIVER_NOT_FOUND'>>> {
|
||||
async execute(input: UpdateDriverProfileInput): Promise<Result<Driver, ApplicationErrorCode<'DRIVER_NOT_FOUND'>>> {
|
||||
const { driverId, bio, country } = input;
|
||||
|
||||
const existing = await this.driverRepository.findById(driverId);
|
||||
@@ -31,7 +31,6 @@ export class UpdateDriverProfileUseCase {
|
||||
});
|
||||
|
||||
const persisted = await this.driverRepository.update(updated);
|
||||
const dto = EntityMappers.toDriverDTO(persisted);
|
||||
return Result.ok(dto!);
|
||||
return Result.ok(persisted);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user