Permissions
权限值
权限是一个 unsigned int
值,由比特位代表是否拥有对应的权限。 权限值与对应比特位进行按位与操作,判断是否拥有该权限。
判断是否有某权限
其中: permissions
代表权限值,bitValue
代表某权限比特位,1 << bitValue
代表某权限值。
permissions & (1 << bitValue) == (1 << bitValue);
Content copied to clipboard
注意: 正常角色由上向下排序,这个先后顺序是角色的优先级(position字段)。 如果你有管理员权限,你只能管理优先级比自己低的用户,不能管理优先级等于或比自己高的用户。这个地方的逻辑举例来说是这样的:对于一个公司的hr来说,他是有招员工的权利也有开除员工的权利(类比于管理权限),但是他不能开掉老板,也不是招自己的boss。因此,在使用授予权限,更新等接口时,要注意一下,可能机器人虽然有管理权限,但是也不是什么角色都可以授予,也不是什么人都可以操作。
更多参考文档
Author
ForteScarlet