增加接口:根据用户id查询菜单
This commit is contained in:
@@ -244,4 +244,58 @@ public class FunctionController {
|
|||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户id查询菜单
|
||||||
|
* @param userId
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/getMenuByUserId")
|
||||||
|
@ApiOperation(value = "根据用户id查询菜单")
|
||||||
|
public BaseResponseInfo getMenuByUserId(@RequestParam("userId") Long userId,
|
||||||
|
HttpServletRequest request)throws Exception {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
try {
|
||||||
|
JSONArray dataArray = new JSONArray();
|
||||||
|
Long roleId = 0L;
|
||||||
|
String fc = "";
|
||||||
|
List<UserBusiness> roleList = userBusinessService.getBasicData(userId.toString(), "UserRole");
|
||||||
|
if(roleList!=null && roleList.size()>0){
|
||||||
|
String value = roleList.get(0).getValue();
|
||||||
|
if(StringUtil.isNotEmpty(value)){
|
||||||
|
String roleIdStr = value.replace("[", "").replace("]", "");
|
||||||
|
roleId = Long.parseLong(roleIdStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//当前用户所拥有的功能列表,格式如:[1][2][5]
|
||||||
|
List<UserBusiness> funList = userBusinessService.getBasicData(roleId.toString(), "RoleFunctions");
|
||||||
|
if(funList!=null && funList.size()>0){
|
||||||
|
fc = funList.get(0).getValue();
|
||||||
|
}
|
||||||
|
List<Function> dataList = functionService.getRoleFunctionLeaf();
|
||||||
|
if (dataList.size() != 0) {
|
||||||
|
for (Function function : dataList) {
|
||||||
|
if (fc.contains("[" + function.getId().toString() + "]")) {
|
||||||
|
String page = function.getUrl();
|
||||||
|
page = page.replace("/system/", "").replace("/bill/", "")
|
||||||
|
.replace("/financial/", "").replace("/report/", "")
|
||||||
|
.replace("/material/","");
|
||||||
|
JSONObject item = new JSONObject();
|
||||||
|
item.put("id", function.getId());
|
||||||
|
item.put("page", page);
|
||||||
|
dataArray.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
res.code = 200;
|
||||||
|
res.data = dataArray;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -178,6 +178,26 @@ public class FunctionService {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取功能列表的叶子节点
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public List<Function> getRoleFunctionLeaf()throws Exception {
|
||||||
|
FunctionExample example = new FunctionExample();
|
||||||
|
example.createCriteria().andEnabledEqualTo(true).andParentNumberNotEqualTo("0")
|
||||||
|
.andComponentNotEqualTo("/layouts/IframePageView")
|
||||||
|
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||||
|
example.setOrderByClause("Sort");
|
||||||
|
List<Function> list=null;
|
||||||
|
try{
|
||||||
|
list = functionsMapper.selectByExample(example);
|
||||||
|
}catch(Exception e){
|
||||||
|
JshException.readFail(logger, e);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
public List<Function> findRoleFunction(String pnumber)throws Exception{
|
public List<Function> findRoleFunction(String pnumber)throws Exception{
|
||||||
FunctionExample example = new FunctionExample();
|
FunctionExample example = new FunctionExample();
|
||||||
example.createCriteria().andEnabledEqualTo(true).andParentNumberEqualTo(pnumber)
|
example.createCriteria().andEnabledEqualTo(true).andParentNumberEqualTo(pnumber)
|
||||||
|
|||||||
Reference in New Issue
Block a user