Refactor admin module structure: moved services and controllers to providers and controllers directories, added PermissionService and PermissionController, updated Admin entity relationships, and created AdminRole entity.

This commit is contained in:
2025-11-17 23:04:28 +03:30
parent b3c44d734c
commit 7bd2b59cb1
8 changed files with 78 additions and 18 deletions
@@ -0,0 +1,34 @@
import { Controller, Post, Body, HttpCode, HttpStatus, Get } from '@nestjs/common';
import { AdminService } from '../providers/admin.service';
import { CreateAdminDto } from '../dto/create-admin.dto';
import { ApiTags, ApiOperation, ApiBody, ApiResponse } from '@nestjs/swagger';
@ApiTags('admin')
@Controller('admin')
export class AdminController {
constructor(private readonly adminService: AdminService) {}
@Get()
@ApiOperation({ summary: 'admin' })
@ApiResponse({ status: 201, description: 'Admins' })
async getAll() {
const admin = await this.adminService.findAll();
return admin;
}
@Post()
@HttpCode(HttpStatus.CREATED)
@ApiOperation({ summary: 'Create a new admin' })
@ApiBody({ type: CreateAdminDto })
@ApiResponse({ status: 201, description: 'Admin created' })
async create(@Body() dto: CreateAdminDto) {
const admin = await this.adminService.create({
phone: dto.phone,
firstName: dto.firstName,
lastName: dto.lastName,
roleId: dto.roleId,
restId: dto.restId,
});
return admin;
}
}