This commit is contained in:
2025-12-29 23:08:18 +03:30
parent 9f0ca2fe02
commit 6f972a9e12
2 changed files with 6 additions and 9 deletions
@@ -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<Admin[]> {
getAdminForRestaurant(@Param('restaurantId') restaurantId: string): Promise<Admin[]> {
return this.adminService.getAdminsForRestaurantBySuperAdmin(restaurantId);
}
+3 -3
View File
@@ -20,7 +20,7 @@ export class AdminService {
private readonly adminRoleRepository: EntityRepository<AdminRole>,
private readonly em: EntityManager,
private readonly cacheService: CacheService,
) { }
) {}
async findByPhone(phone: string): Promise<Admin | null> {
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');