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:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user