feat: RBAC
This commit is contained in:
@@ -111,7 +111,7 @@ export class MenuService {
|
||||
});
|
||||
|
||||
//step2 删除菜单数据
|
||||
await prisma.sysResourcePermission.delete({ where: { id } });
|
||||
await prisma.sysResource.delete({ where: { id } });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ export class ResourceService {
|
||||
});
|
||||
|
||||
//step2 删除资源数据
|
||||
await prisma.sysResourcePermission.delete({ where: { id } });
|
||||
await prisma.sysResource.delete({ where: { id } });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,11 @@ import { Controller, Get } from '@nestjs/common';
|
||||
import { TestService } from './test.service';
|
||||
|
||||
import { SkipAuth } from '@/common/decorators/skip-auth.decorator';
|
||||
import { Permissions } from '@/common/decorators/permissions.decorator';
|
||||
|
||||
@Controller()
|
||||
@SkipAuth()
|
||||
// @SkipAuth()
|
||||
@Permissions('test', 'test2')
|
||||
export class TestController {
|
||||
constructor(private readonly testService: TestService) {}
|
||||
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
||||
import { PrismaService } from '@/prisma/prisma.service';
|
||||
|
||||
@Injectable()
|
||||
export class TestService {
|
||||
findAll() {
|
||||
throw new HttpException('用户不存在!', HttpStatus.NOT_FOUND);
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
|
||||
async findAll() {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ export class UserController {
|
||||
getUserInfo(@Request() req) {
|
||||
const { sub } = req['user'];
|
||||
const { isAdmin } = req;
|
||||
console.log(isAdmin);
|
||||
return this.userService.getUserInfo(sub, isAdmin);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user