From 6f972a9e123872417a3b959a6d0c69386c1cccf3 Mon Sep 17 00:00:00 2001 From: morteza-mortezai Date: Mon, 29 Dec 2025 23:08:18 +0330 Subject: [PATCH] admin --- src/modules/admin/controllers/admin.controller.ts | 9 +++------ src/modules/admin/providers/admin.service.ts | 6 +++--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/modules/admin/controllers/admin.controller.ts b/src/modules/admin/controllers/admin.controller.ts index 5e7ab16..3bea57b 100644 --- a/src/modules/admin/controllers/admin.controller.ts +++ b/src/modules/admin/controllers/admin.controller.ts @@ -2,7 +2,7 @@ import { Controller, Post, Body, HttpCode, HttpStatus, Get, UseGuards, Patch, Pa import { AdminService } from '../providers/admin.service'; import { CreateAdminDto } from '../dto/create-admin.dto'; import { UpdateAdminDto } from '../dto/update-admin.dto'; -import { ApiTags, ApiOperation, ApiBody, ApiBearerAuth, ApiParam, ApiHeader } from '@nestjs/swagger'; +import { ApiTags, ApiOperation, ApiBody, ApiBearerAuth, ApiParam } from '@nestjs/swagger'; import { AdminAuthGuard } from 'src/modules/auth/guards/adminAuth.guard'; import { SuperAdminAuthGuard } from 'src/modules/auth/guards/superAdminAuth.guard'; import { RestId } from 'src/common/decorators'; @@ -16,7 +16,7 @@ import { CreateMyRestaurantAdminDto } from '../dto/create-my-restaurant-admin.dt @ApiTags('admin') @Controller() export class AdminController { - constructor(private readonly adminService: AdminService) { } + constructor(private readonly adminService: AdminService) {} @Get('admin/admins') @UseGuards(AdminAuthGuard) @@ -80,10 +80,7 @@ export class AdminController { @Get('super-admin/restaurants/:restaurantId/admins') @ApiOperation({ summary: 'Get admins for a specific restaurant (Super Admin only)' }) @ApiParam({ name: 'restaurantId', description: 'Restaurant ID' }) - - getAdminForRestaurant( - @Param('restaurantId') restaurantId: string, - ): Promise { + getAdminForRestaurant(@Param('restaurantId') restaurantId: string): Promise { return this.adminService.getAdminsForRestaurantBySuperAdmin(restaurantId); } diff --git a/src/modules/admin/providers/admin.service.ts b/src/modules/admin/providers/admin.service.ts index befa4da..dcda64d 100644 --- a/src/modules/admin/providers/admin.service.ts +++ b/src/modules/admin/providers/admin.service.ts @@ -20,7 +20,7 @@ export class AdminService { private readonly adminRoleRepository: EntityRepository, private readonly em: EntityManager, private readonly cacheService: CacheService, - ) { } + ) {} async findByPhone(phone: string): Promise { const normalizedPhone = normalizePhone(phone); @@ -94,8 +94,8 @@ export class AdminService { }); await this.em.persistAndFlush(admin); } - const role = await this.em.findOne(Role, { id: roleId, isSystem: false }); - if (!role) throw new NotFoundException('Role not found'); + const role = await this.em.findOne(Role, { id: roleId }); + if (!role) throw new NotFoundException('Role* not found' + roleId); const restaurant = await this.em.findOne(Restaurant, { id: restId }); if (!restaurant) throw new NotFoundException('Restaurant not found');