| | |
| | | @Resource |
| | | private RoleMenuMapper roleMenuMapper; |
| | | @Resource |
| | | private ColumnMapper columnMapper; |
| | | @Resource |
| | | private ArticleMapper articleMapper; |
| | | @Resource |
| | | private MessageBoardMapper messageBoardMapper; |
| | | @Resource |
| | | private MenuMapper menuMapper; |
| | | |
| | | @Override |
| | |
| | | List<UserRoleEntity> userRoleEntities = userRoleMapper.selectList(userRoleQueryWrapper); |
| | | if(CollUtil.isNotEmpty(userRoleEntities)){ |
| | | List menuIds = new ArrayList<Long>(); |
| | | for(UserRoleEntity userRoleEntity : userRoleEntities){ |
| | | List<RoleMenuEntity> roleMenuEntities = roleMenuMapper.selectListByRoleId(userRoleEntity.getRoleId()); |
| | | if(CollUtil.isNotEmpty(roleMenuEntities)){ |
| | | for(RoleMenuEntity roleMenuEntity : roleMenuEntities){ |
| | | menuIds.add(roleMenuEntity.getMenuId()); |
| | | if(UserEntity.USERNAME_DEFAULT.equals(loginUser.getUsername())){ |
| | | List<MenuEntity> menuEntities = menuMapper.selectList(new QueryWrapper<>()); |
| | | if(CollUtil.isNotEmpty(menuEntities)){ |
| | | for(MenuEntity menuEntity : menuEntities){ |
| | | menuIds.add(menuEntity.getId()); |
| | | } |
| | | } |
| | | }else{ |
| | | for(UserRoleEntity userRoleEntity : userRoleEntities){ |
| | | List<RoleMenuEntity> roleMenuEntities = roleMenuMapper.selectListByRoleId(userRoleEntity.getRoleId()); |
| | | if(CollUtil.isNotEmpty(roleMenuEntities)){ |
| | | for(RoleMenuEntity roleMenuEntity : roleMenuEntities){ |
| | | menuIds.add(roleMenuEntity.getMenuId()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | return Result.ok(adminUserInfoVo); |
| | | } |
| | | |
| | | @Override |
| | | public Result viewHomePage() { |
| | | UserEntity loginUser = LoginUserUtil.getLoginUser(); |
| | | Long companyId = LoginUserUtil.getCompanyId(); |
| | | |
| | | AdminHomePageInfoVo adminHomePageInfoVo = new AdminHomePageInfoVo(); |
| | | |
| | | QueryWrapper<UserRoleEntity> userRoleQueryWrapper = new QueryWrapper<>(); |
| | | userRoleQueryWrapper.eq("user_id",loginUser.getId()); |
| | | List<UserRoleEntity> userRoleEntities = userRoleMapper.selectList(userRoleQueryWrapper); |
| | | if(CollUtil.isNotEmpty(userRoleEntities)){ |
| | | List<String> roleNames = new ArrayList<>(); |
| | | for(UserRoleEntity userRoleEntity : userRoleEntities){ |
| | | RoleEntity roleEntity = roleMapper.selectById(userRoleEntity.getRoleId()); |
| | | roleNames.add(roleEntity.getRoleName()); |
| | | } |
| | | adminHomePageInfoVo.setRoleNames(roleNames); |
| | | } |
| | | |
| | | QueryWrapper<ColumnEntity> columnQueryWrapper = new QueryWrapper<>(); |
| | | columnQueryWrapper.eq("company_id",companyId); |
| | | adminHomePageInfoVo.setColumnNum(columnMapper.selectCount(columnQueryWrapper)); |
| | | |
| | | QueryWrapper<ArticleEntity> articleQueryWrapper = new QueryWrapper<>(); |
| | | articleQueryWrapper.eq("company_id",companyId); |
| | | articleQueryWrapper.eq("del_status",ArticleEntity.DELETE_STATUS_NO); |
| | | adminHomePageInfoVo.setArticleNum(articleMapper.selectCount(articleQueryWrapper)); |
| | | |
| | | QueryWrapper<MessageBoardEntity> messageQueryWrapper = new QueryWrapper<>(); |
| | | messageQueryWrapper.eq("company_id",companyId); |
| | | adminHomePageInfoVo.setMessageNum(messageBoardMapper.selectCount(messageQueryWrapper)); |
| | | return Result.ok(adminHomePageInfoVo); |
| | | } |
| | | |
| | | private void saveUserRole(String roleIds,Long userId) { |
| | | if (StrUtil.isNotEmpty(roleIds)) { |
| | | String[] roleIdList = roleIds.split(StringPool.COMMA); |