use of com.ganster.cms.admin.dto.ModuleTree in project Ganster-CMS by Gangster-trio.
the class IndexController method index.
// @RequiresPermissions("super")
@GetMapping("/index")
public ModelAndView index(@RequestParam(required = false) Integer id) {
Subject subject = SecurityUtils.getSubject();
User user = (User) subject.getPrincipal();
if (id != null) {
LOGGER.info("用户id为{},名字为{} 刷新权限", user.getUserId(), user.getUserName());
PermissionUtil.flush(user.getUserId());
}
ModelAndView modelAndView = new ModelAndView();
// 查出所有的父模块
List<ModuleTree> treeList = new ArrayList<>();
ModuleExample moduleExample = new ModuleExample();
if (user.getUserName().equals("admin")) {
moduleExample.or().andModuleParentIdEqualTo(0);
} else {
moduleExample.or().andModuleParentIdEqualTo(0).andModuleIdNotEqualTo(4).andModuleIdNotEqualTo(8);
}
List<Module> parents = moduleService.selectByExample(moduleExample);
for (Module module : parents) {
ModuleExample moduleExample1 = new ModuleExample();
moduleExample1.or().andModuleParentIdEqualTo(module.getModuleId());
List<Module> childs = moduleService.selectByExample(moduleExample1);
ModuleTree moduleTree = new ModuleTree();
moduleTree.setModule(module);
moduleTree.setList(childs);
treeList.add(moduleTree);
}
List siteList = permissionService.findAllUserSite(user.getUserId());
modelAndView.addObject("moduleTreeList", treeList);
modelAndView.addObject("siteList", siteList);
modelAndView.addObject("user", user);
return modelAndView;
}
Aggregations