feat: RBAC

This commit is contained in:
2025-03-11 17:21:40 +08:00
parent 5058aefd66
commit 95de4f6484
8 changed files with 68 additions and 12 deletions

View File

@@ -111,7 +111,7 @@ export class MenuService {
});
//step2 删除菜单数据
await prisma.sysResourcePermission.delete({ where: { id } });
await prisma.sysResource.delete({ where: { id } });
});
}
}

View File

@@ -107,7 +107,7 @@ export class ResourceService {
});
//step2 删除资源数据
await prisma.sysResourcePermission.delete({ where: { id } });
await prisma.sysResource.delete({ where: { id } });
});
}
}

View File

@@ -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) {}

View File

@@ -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 [];
}
}

View File

@@ -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);
}