clean using es6

This commit is contained in:
sbriat 2023-05-05 16:58:03 +02:00
parent f430a4bfb6
commit 0f8233616d
1 changed files with 12 additions and 12 deletions

View File

@ -33,21 +33,21 @@ import { RpcValidationPipe } from '../../../../utils/pipes/rpc.validation-pipe';
@Controller()
export class UserController {
constructor(
private readonly _commandBus: CommandBus,
private readonly _queryBus: QueryBus,
@InjectMapper() private readonly _mapper: Mapper,
private readonly commandBus: CommandBus,
private readonly queryBus: QueryBus,
@InjectMapper() private readonly mapper: Mapper,
) {}
@GrpcMethod('UsersService', 'FindAll')
@UseInterceptors(CacheInterceptor)
@CacheKey('UsersServiceFindAll')
async findAll(data: FindAllUsersRequest): Promise<ICollection<User>> {
const userCollection = await this._queryBus.execute(
const userCollection = await this.queryBus.execute(
new FindAllUsersQuery(data),
);
return Promise.resolve({
data: userCollection.data.map((user: User) =>
this._mapper.map(user, User, UserPresenter),
this.mapper.map(user, User, UserPresenter),
),
total: userCollection.total,
});
@ -58,8 +58,8 @@ export class UserController {
@CacheKey('UsersServiceFindOneByUuid')
async findOneByUuid(data: FindUserByUuidRequest): Promise<UserPresenter> {
try {
const user = await this._queryBus.execute(new FindUserByUuidQuery(data));
return this._mapper.map(user, User, UserPresenter);
const user = await this.queryBus.execute(new FindUserByUuidQuery(data));
return this.mapper.map(user, User, UserPresenter);
} catch (error) {
throw new RpcException({
code: 5,
@ -71,8 +71,8 @@ export class UserController {
@GrpcMethod('UsersService', 'Create')
async createUser(data: CreateUserRequest): Promise<UserPresenter> {
try {
const user = await this._commandBus.execute(new CreateUserCommand(data));
return this._mapper.map(user, User, UserPresenter);
const user = await this.commandBus.execute(new CreateUserCommand(data));
return this.mapper.map(user, User, UserPresenter);
} catch (e) {
if (e instanceof DatabaseException) {
if (e.message.includes('Already exists')) {
@ -89,9 +89,9 @@ export class UserController {
@GrpcMethod('UsersService', 'Update')
async updateUser(data: UpdateUserRequest): Promise<UserPresenter> {
try {
const user = await this._commandBus.execute(new UpdateUserCommand(data));
const user = await this.commandBus.execute(new UpdateUserCommand(data));
return this._mapper.map(user, User, UserPresenter);
return this.mapper.map(user, User, UserPresenter);
} catch (e) {
if (e instanceof DatabaseException) {
if (e.message.includes('not found')) {
@ -108,7 +108,7 @@ export class UserController {
@GrpcMethod('UsersService', 'Delete')
async deleteUser(data: FindUserByUuidRequest): Promise<void> {
try {
await this._commandBus.execute(new DeleteUserCommand(data.uuid));
await this.commandBus.execute(new DeleteUserCommand(data.uuid));
return Promise.resolve();
} catch (e) {