| | |
| | | import com.qxueyou.scc.user.model.UserRole; |
| | | |
| | | /** |
| | | * 系统权限服务 |
| | | * 系统权限服务 |
| | | * |
| | | * @author 德虎 |
| | | * @author 德虎 |
| | | * |
| | | */ |
| | | @Service |
| | |
| | | @Override |
| | | public List<SysMenu> getPrivilegesMenus(String userId) { |
| | | |
| | | // 获取当前用户角色ID, 过滤当前角色 |
| | | // 获取当前用户角色ID, 过滤当前角色 |
| | | String currRoleId = null; |
| | | Short currOrgType = null; |
| | | if (null != ClientUtils.getUserInfo() && StringUtils.isNotBlank(ClientUtils.getOrgId())) { |
| | |
| | | |
| | | List<SysMenu> firstLevelMenus = new ArrayList<SysMenu>(5); |
| | | |
| | | // 获取该用户当前角色的所有菜单权限 |
| | | // 获取该用户当前角色的所有菜单权限 |
| | | List<SysMenu> allMenus = initAllMenus(currRoleId); |
| | | |
| | | // 过滤出第一层及第二层菜单权限 |
| | | // 过滤出第一层及第二层菜单权限 |
| | | initFirstSecondMenu(allMenus, firstLevelMenus, currOrgType); |
| | | |
| | | // 排序 |
| | | // 排序 |
| | | sortMenuList(firstLevelMenus); |
| | | |
| | | return firstLevelMenus; |
| | |
| | | |
| | | allMenus.addAll(this.find(hql, CollectionUtils.newList(currRoleId), SysMenu.class)); |
| | | |
| | | // 如果是超管,菜单 |
| | | // 如果是超管,菜单 |
| | | if ("6".equals(currRoleId) && allMenus.isEmpty()) { |
| | | UserRole role = this.read(UserRole.class, "6"); |
| | | allMenus = role.getMenus(); |
| | |
| | | initSecondMenu(allMenus, secondMenus, childMenus, currOrgType); |
| | | |
| | | if (!secondMenus.isEmpty()) { |
| | | // 排序 |
| | | // 排序 |
| | | sortMenuList(secondMenus); |
| | | menu.setChildren(secondMenus); |
| | | firstLevelMenus.add(menu); |
| | |
| | | |
| | | if (allMenus.contains(m)) { |
| | | |
| | | // 非高校过滤掉 |
| | | // 非高校过滤掉 |
| | | if (currOrgType == null) { |
| | | continue; |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取已授权按钮列表,默认已经编辑过按钮权限的用户 |
| | | * 获取已授权按钮列表,默认已经编辑过按钮权限的用户 |
| | | * |
| | | * @param name |
| | | * @return |
| | |
| | | |
| | | Integer order1 = (Integer) menu1.getMenuOrder(); |
| | | Integer order2 = (Integer) menu2.getMenuOrder(); |
| | | // 升序 |
| | | // 升序 |
| | | return order1.compareTo(order2); |
| | | } |
| | | }); |
| | |
| | | } |
| | | |
| | | /* |
| | | * 获取讲师直播关联的class |
| | | * 获取讲师直播关联的class |
| | | * |
| | | */ |
| | | @Override |
| | |
| | | } |
| | | |
| | | /** |
| | | * 助理讲师班级列表 |
| | | * 助理讲师班级列表 |
| | | */ |
| | | @SuppressWarnings({ "unchecked", "rawtypes" }) |
| | | @Override |
| | | public List<ClsClass> getAssisTeacherClasses(String userId, String orgId) { |
| | | // 1、讲师助教 |
| | | // 1、讲师助教 |
| | | String hql = "select distinct cls from MediaVideoLive live,OrgAssistantTeacher teacher , ClsClass cls " |
| | | + "where live.anchorId = teacher.orgTeacherId " + "and live.classId = cls.classId " |
| | | + "and teacher.userId= ? " + "and teacher.orgId= ? " + "and live.deleteFlag is false " |
| | |
| | | |
| | | List<ClsClass> teacherList = find(hql, CollectionUtils.newList(userId, orgId), ClsClass.class); |
| | | |
| | | // 2.班主任助教 |
| | | // 2.班主任助教 |
| | | String hql2 = "select distinct cls from OrgAssistantTeacher teacher , ClsClass cls " |
| | | + "where teacher.orgTeacherId=cls.classChargerId " + "and teacher.classId = cls.classId " |
| | | + "and teacher.userId= ? " + "and teacher.orgId= ? " + "and teacher.deleteFlag is false " |
| | |
| | | List<ClsClass> chargerList = find(hql2, CollectionUtils.newList(userId, orgId), ClsClass.class); |
| | | |
| | | teacherList.addAll(chargerList); |
| | | // 去重 |
| | | // 去重 |
| | | HashSet h = new HashSet(teacherList); |
| | | teacherList.clear(); |
| | | teacherList.addAll(h); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 新增list |
| | | * 新增list |
| | | * |
| | | * @param privileges |
| | | * @return |
| | |
| | | } |
| | | |
| | | /** |
| | | * 删除list |
| | | * 删除list |
| | | * |
| | | * @param privileges |
| | | * @return |
| | | */ |
| | | public Result deletePrivileges(String[] deleteMenuIds, String roleId) { |
| | | |
| | | // 修改为使用update |
| | | // 修改为使用update |
| | | // bulkUpdateInLoop("update SysPrivilege set deleteFlag = true where roleId = '" |
| | | // + roleId + "' and menuId = ?", deleteMenuIds ); |
| | | String hql = " from SysPrivilege where menuId in (:menuIds) and deleteFlag is false and roleId = :roleId "; |
| | |
| | | |
| | | String maxRoleTypeStr = findUniqueByHql(hqlRole, CollectionUtils.newObjectMap("userId", user.getUserId())); |
| | | if (StringUtils.isBlank(maxRoleTypeStr)) { |
| | | return new Result(false, "该用户没有权限,登录失败"); |
| | | return new Result(false, "该用户没有权限,登录失败"); |
| | | } |
| | | Integer maxRoleType = Integer.valueOf(maxRoleTypeStr); |
| | | return new Result(true, "success", CollectionUtils.newObjectMap("menuLst", menuLst, "userName", user.getName(), |