數(shù)據(jù)權(quán)限的使用
在運(yùn)營(yíng)平臺(tái)配置角色的菜單權(quán)限
在運(yùn)營(yíng)平臺(tái)按賬號(hào)或者角色斥赋,配置菜單的數(shù)據(jù)權(quán)限
代碼修改:
3.1 在需要做權(quán)限控制的接口添加注解:
@DataPerm(resourceName = "揭榜掛帥管理") // resourceName 指定該接口對(duì)應(yīng)的資源名稱
@ApiOperation("管理端 - 揭榜掛帥管理")
@GetMapping("/pageJbManage")
public JsonResult<Page<JbgsPageResponse>> pageJbManage(JbgsPageRequest request, SimplePage page) {
return JsonResult.ok(ResultConstant.QUERY_OK, jbgsProjectService.pageJbManage(request, page));
}
3.2 service可以通過(guò)ContextHandler 拿到數(shù)據(jù)權(quán)限的標(biāo)識(shí)
public PageInfo<JbgsPageResponse> pageJbManage(JbgsPageRequest request, SimplePage page) {
JbgsQuery query = modelMapper.map(request, JbgsQuery.class);
query.setDataScope(ContextHandler.getString(DataPermConstant.DATA_SCOPE));
List<JbgsProjectResponse> list = this.mapper.selectJbgsProjectList(query, area);
}
3.3 在sql文件中根據(jù)數(shù)據(jù)權(quán)限的標(biāo)識(shí)做響應(yīng)處理
image.png