From 2babd2041997edcabaa3d471142272b19f663f6b Mon Sep 17 00:00:00 2001 From: morteza-mortezai Date: Sun, 8 Mar 2026 14:53:07 +0330 Subject: [PATCH] watcher:bug --- src/modules/users/services/users.service.ts | 3 ++- src/modules/users/users.controller.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) 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); } }