You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何查询指定角色与所有权限的关联状态并返回结果

查询指定角色与所有权限的关联关系

需求

查询指定角色与所有权限的关联关系是否存在,返回所有权限行并标注该关联是否存在。

表结构

Permissions表

indexControllerAction
5Errorindex
2Homeindex
3Homelogin
4Homelogout
1Testindex
9UserManagementcreateUser
8UserManagementeditUser
6UserManagementindex

Roles_Permissions表

RolesPermissions
12
13
15
21
22
23
24
25
31
32
33
34
35
41
42
43
44
45
46
48
49

Roles表

Role_idRole_name
4Admin
2special
3User
1Visitor

示例查询结果

当查询变量为Special时,返回结果如下:

indexControllerActionExist
5Errorindexyes
2Homeindexyes
3Homeloginyes
4Homelogoutyes
1Testindexyes
9UserManagementcreateUserno
8UserManagementeditUserno
6UserManagementindexno

补充说明

role_id与perm_id之间存在外键约束。

内容的提问来源于stack exchange,提问作者Smit Sanghvi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.21 12:33:17