refactor use cases
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import type { Logger } from '@core/shared/application';
|
||||
import { Result } from '@core/shared/application/Result';
|
||||
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
|
||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||
import type { League } from '../../domain/entities/League';
|
||||
import type { ILeagueRepository } from '../../domain/repositories/ILeagueRepository';
|
||||
@@ -33,12 +32,11 @@ export class GetLeagueAdminPermissionsUseCase {
|
||||
private readonly leagueRepository: ILeagueRepository,
|
||||
private readonly leagueMembershipRepository: ILeagueMembershipRepository,
|
||||
private readonly logger: Logger,
|
||||
private readonly output: UseCaseOutputPort<GetLeagueAdminPermissionsResult>,
|
||||
) {}
|
||||
|
||||
async execute(
|
||||
input: GetLeagueAdminPermissionsInput,
|
||||
): Promise<Result<void, ApplicationErrorCode<GetLeagueAdminPermissionsErrorCode, { message: string }>>> {
|
||||
): Promise<Result<GetLeagueAdminPermissionsResult, ApplicationErrorCode<GetLeagueAdminPermissionsErrorCode, { message: string }>>> {
|
||||
const { leagueId, performerDriverId } = input;
|
||||
|
||||
try {
|
||||
@@ -75,9 +73,7 @@ export class GetLeagueAdminPermissionsUseCase {
|
||||
permissions,
|
||||
};
|
||||
|
||||
this.output.present(result);
|
||||
|
||||
return Result.ok(undefined);
|
||||
return Result.ok(result);
|
||||
} catch (error) {
|
||||
const err = error instanceof Error ? error : new Error('Unknown error');
|
||||
this.logger.error('Failed to load league admin permissions', err);
|
||||
@@ -87,4 +83,4 @@ export class GetLeagueAdminPermissionsUseCase {
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user