diff --git a/src/modules/users/services/users.service.ts b/src/modules/users/services/users.service.ts index a902b7d..87a314a 100644 --- a/src/modules/users/services/users.service.ts +++ b/src/modules/users/services/users.service.ts @@ -183,7 +183,7 @@ export class UsersService { /*******************************/ async getWatchers(business: Business) { - return this.userRepository.find({ business: { id: business.id }, role: { name: RoleEnum.WATCHER } }) + return this.userRepository.find({ business: { id: business.id }, role: { name: RoleEnum.WATCHER }, deletedAt: null }) } /*******************************/ @@ -194,6 +194,7 @@ export class UsersService { /*******************************/ async deleteWatcherById(id: string, business: Business) { const watcher = await this.userRepository.findOne({ id, business: { id: business.id } }) + if (!watcher) { throw new BadRequestException("Not found") } diff --git a/src/modules/users/users.controller.ts b/src/modules/users/users.controller.ts index e7ca4a0..8594f91 100644 --- a/src/modules/users/users.controller.ts +++ b/src/modules/users/users.controller.ts @@ -42,7 +42,7 @@ export class UsersController { @ApiOperation({ summary: "delete Watcher by id" }) @Delete("watcher/:id") deleteWatcher(@Param("id") watcherId: string, @BusinessDec() business: Business) { - return this.usersService.getWatcherById(watcherId, business); + return this.usersService.deleteWatcherById(watcherId, business); } }