pai.user.permission.get(获取用户套件权限)
通用场景
服务端获取到用户token信息,调用此接口获取对应的pai账户权限信息。
角色及权限配置
套件的角色权限需要从开发者后台,通过套件去配置对应的角色权限,然后进入控制台安装该套件后,进行配置。
开发者后台配置
控制台配置
请求示例
@Test
public void getUserRolePerm(){
LoginUser loginUser = SecurityUtils.getLoginUser();
//飞智云考勤
String suiteCode = "cn.flyrise.suite.0e9ec";
Reply reply = permissionService.findAppPermsByCode(suiteCode,loginUser.getUserId(),loginUser.getEntId(),
SecurityConstants.FROM_IN);
System.out.println(JSONUtil.parse(reply).toStringPretty());
}
响应示例
{
"msg": "操作成功",
"code": "200",
"data": {
"roles": [
"in_work",
"front"
],
"perms": [
"in_work:add",
"in_work:update",
"in_work:delete",
"in_work:list",
"front:list"
]
},
"time": 1618372042490
}
使用用例
在接口上可以使用@PreAuthorize(“@pms.hasSuiteRoles(‘’)”) 来进行接口鉴权。
参数描述:
套件code:cn.flyrise.suite.0e9ec
角色标识:in_work
权限标识:add
@PreAuthorize(“@pms.hasSuiteRoles(‘cn.flyrise.suite.0e9ec:in_work:add’)”)参数是由套件 + 角色 + 权限组成,也允许只控制到角色,
即@pms.hasSuiteRoles(‘cn.flyrise.suite.0e9ec:in_work’)
@ApiModelProperty("需要权限")
@GetMapping("/must/perm")
@PreAuthorize("@pms.hasSuiteRoles('cn.flyrise.suite.0e9ec:in_work:add')")
public Reply<?> mustPerm() {
return Reply.success("有权限");
}
无权限返回信息
{
"code": "500",
"data": null,
"time": 1618383892161,
"msg": "不允许访问",
"annex": {
"applicationName": "pai-user-center",
"ExceptionClassName": "org.springframework.security.access.AccessDeniedException"
},
"success": false
}
pai.user.permission.get(获取用户套件权限)
通用场景
服务端获取到用户token信息,调用此接口获取对应的pai账户权限信息。
角色及权限配置
套件的角色权限需要从开发者后台,通过套件去配置对应的角色权限,然后进入控制台安装该套件后,进行配置。
开发者后台配置
控制台配置
请求示例
@Test
public void getUserRolePerm(){
LoginUser loginUser = SecurityUtils.getLoginUser();
//飞智云考勤
String suiteCode = "cn.flyrise.suite.0e9ec";
Reply reply = permissionService.findAppPermsByCode(suiteCode,loginUser.getUserId(),loginUser.getEntId(),
SecurityConstants.FROM_IN);
System.out.println(JSONUtil.parse(reply).toStringPretty());
}
响应示例
{
"msg": "操作成功",
"code": "200",
"data": {
"roles": [
"in_work",
"front"
],
"perms": [
"in_work:add",
"in_work:update",
"in_work:delete",
"in_work:list",
"front:list"
]
},
"time": 1618372042490
}
使用用例
在接口上可以使用@PreAuthorize(“@pms.hasSuiteRoles(‘’)”) 来进行接口鉴权。
参数描述:
套件code:cn.flyrise.suite.0e9ec
角色标识:in_work
权限标识:add
@PreAuthorize(“@pms.hasSuiteRoles(‘cn.flyrise.suite.0e9ec:in_work:add’)”)参数是由套件 + 角色 + 权限组成,也允许只控制到角色,
即@pms.hasSuiteRoles(‘cn.flyrise.suite.0e9ec:in_work’)
@ApiModelProperty("需要权限")
@GetMapping("/must/perm")
@PreAuthorize("@pms.hasSuiteRoles('cn.flyrise.suite.0e9ec:in_work:add')")
public Reply<?> mustPerm() {
return Reply.success("有权限");
}
无权限返回信息
{
"code": "500",
"data": null,
"time": 1618383892161,
"msg": "不允许访问",
"annex": {
"applicationName": "pai-user-center",
"ExceptionClassName": "org.springframework.security.access.AccessDeniedException"
},
"success": false
}
pai.user.data.access.get(获取用户数据权限)
通用场景
服务端获取到用户token信息,调用此接口获取对应的pai账户数据权限信息。
角色及权限配置
套件的角色权限需要从开发者后台,通过套件去配置对应的角色权限,然后进入控制台安装该套件后,进行配置。
开发者后台配置
控制台配置
请求示例
@Test
public void getDataAccessBySuiteCode(){
LoginUser loginUser = SecurityUtils.getLoginUser();
//飞智云考勤
String suiteCode = "cn.flyrise.suite.0e9ec";
Reply reply = permissionService.getCurrentUserDataAccess(suiteCode,
SecurityConstants.FROM_IN);
System.out.println(JSONUtil.parse(reply).toStringPretty());
}
响应示例
{
"code": "200",
"data": [
{
"suiteCode": "cn.flyrise.suite.0e9ec",
"accessCode": "add_exception",
"scope": "D",
"organizations": [
{
"id": "1309393146970509312",
"name": "数字中台部",
"scope": "D",
"cascading": 0
},
{
"id": "1333317403593019392",
"name": "测试小组",
"scope": "D",
"cascading": 0
}
]
}
],
"time": 1618381203434,
"msg": "操作成功",
"annex": null,
"success": true
}
pai.role.config.all.get(获取套件角色配置)
请求示例
@ApiModelProperty("getRole")
@GetMapping("/getRole")
public Reply<?> getRole(String suiteCode) {
LoginUser loginUser = SecurityUtils.getLoginUser();
return permissionService.findRoleByEntAndSuiteCode(loginUser.getEntId(),suiteCode,SecurityConstants.FROM_IN);
}
响应示例
{
"code": "200",
"data": [
{
"roleId": "1385525323440984064",
"roleName": "停车管理员",
"roleKey": "停车管理员",
"staffList": [
{
"staffId": "1342019611775864832",
"staffName": "朱灿义"
},
{
"staffId": "1310129886668656640",
"staffName": "5号测试"
},
{
"staffId": "1375208436622561280",
"staffName": "李金明"
}
],
"roleDesc": "停车管理员"
}
],
"time": 1619409021729,
"msg": "操作成功",
"annex": null,
"success": true
}
pai.role.config.one.get(获取单个角色配置)
请求示例
@ApiModelProperty("getRoleByKey")
@GetMapping("/getRoleByKey")
public Reply<?> getRole(String suiteCode,String key) {
LoginUser loginUser = SecurityUtils.getLoginUser();
return permissionService.findRoleByEntAndSuiteCodeAndRoleKey(loginUser.getEntId(),suiteCode,key,
SecurityConstants.FROM_IN);
}
响应示例
{
"code": "200",
"data": {
"roleId": "1385525323440984064",
"roleName": "停车管理员",
"roleKey": "停车管理员",
"staffList": [
{
"staffId": "1342019611775864832",
"staffName": "朱灿义"
},
{
"staffId": "1310129886668656640",
"staffName": "5号测试"
},
{
"staffId": "1375208436622561280",
"staffName": "李金明"
}
],
"roleDesc": "停车管理员"
},
"time": 1619415257019,
"msg": "操作成功",
"annex": null,
"success": true
}