实现admin-role
This commit is contained in:
@@ -5,6 +5,8 @@ import { AdminUserService } from './service/admin-user.service';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { User } from 'src/user/entities/user.entity';
|
||||
import { UserModule } from 'src/user/user.module';
|
||||
import { RoleModule } from 'src/role/role.module';
|
||||
import { AdminRoleController } from './controller/admin-role.controller';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -12,10 +14,12 @@ import { UserModule } from 'src/user/user.module';
|
||||
User,
|
||||
]),
|
||||
UserModule,
|
||||
RoleModule,
|
||||
],
|
||||
controllers: [
|
||||
AdminController,
|
||||
AdminUserController,
|
||||
AdminRoleController,
|
||||
],
|
||||
providers: [
|
||||
AdminUserService,
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import { Body, Controller, Delete, Get, Param, ParseUUIDPipe, Post } from "@nestjs/common";
|
||||
import { RoleService } from "src/role/services/role.service";
|
||||
import { CreateRoleDto } from "../dto/admin-role/create-role.dto";
|
||||
|
||||
@Controller('admin/role')
|
||||
export class AdminRoleController {
|
||||
|
||||
constructor(
|
||||
private readonly roleService: RoleService,
|
||||
) { }
|
||||
|
||||
@Get()
|
||||
async list() {
|
||||
return this.roleService.list();
|
||||
}
|
||||
|
||||
@Post()
|
||||
async create(
|
||||
@Body() dto: CreateRoleDto
|
||||
) {
|
||||
return this.roleService.create(dto);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
async delete(
|
||||
@Param('id', new ParseUUIDPipe({ version: '4' })) id: string,
|
||||
) {
|
||||
return this.roleService.delete(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { IsString } from "class-validator";
|
||||
|
||||
export class CreateRoleDto {
|
||||
@IsString()
|
||||
name: string
|
||||
|
||||
@IsString()
|
||||
localName: string;
|
||||
}
|
||||
Reference in New Issue
Block a user