实现admin-role
This commit is contained in:
@@ -5,6 +5,8 @@ import { AdminUserService } from './service/admin-user.service';
|
|||||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
import { User } from 'src/user/entities/user.entity';
|
import { User } from 'src/user/entities/user.entity';
|
||||||
import { UserModule } from 'src/user/user.module';
|
import { UserModule } from 'src/user/user.module';
|
||||||
|
import { RoleModule } from 'src/role/role.module';
|
||||||
|
import { AdminRoleController } from './controller/admin-role.controller';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -12,10 +14,12 @@ import { UserModule } from 'src/user/user.module';
|
|||||||
User,
|
User,
|
||||||
]),
|
]),
|
||||||
UserModule,
|
UserModule,
|
||||||
|
RoleModule,
|
||||||
],
|
],
|
||||||
controllers: [
|
controllers: [
|
||||||
AdminController,
|
AdminController,
|
||||||
AdminUserController,
|
AdminUserController,
|
||||||
|
AdminRoleController,
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
AdminUserService,
|
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