| | |
| | | //校验密码 |
| | | String password = parameters.get("password").toString(); |
| | | //密码解密 |
| | | //password = AESUtils.decrypt(password, AESKey); |
| | | password = AESUtils.decrypt(password, AESKey); |
| | | if (!MD5Utils.saltMD5Verify(password, userBo.getPassword())) { |
| | | result.put("code", ResponseCodeEnum.PASSWORD_INVALID.getCode()); |
| | | result.put("msg", ResponseCodeEnum.PASSWORD_INVALID.getMsg()); |
| | |
| | | userInfo.put("organizationName", organization.getName()); |
| | | userInfo.put("locationLevel", organization.getLocationLevel()); |
| | | userInfo.put("groups", groups); |
| | | userInfo.putAll(getMenus(userBo.getId(), -1)); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("userId",userBo.getId()); |
| | | userInfo.putAll(getMenus(map)); |
| | | try { |
| | | //生成token,并存入redis |
| | | String token = TokenUtils.getToken(userBo.getId().toString(), userInfo); |
| | |
| | | return result; |
| | | } |
| | | |
| | | //根据userId获取用户层级菜单 |
| | | public Map<String, Object> getMenus(int userId, int orgId) { |
| | | @Override |
| | | public Map<String, Object> getMenus(Map<String, Object> parameters) { |
| | | List<Menu> allMenus; |
| | | if (orgId == -1) { |
| | | allMenus = menuMapper.selectUserMenu(userId); |
| | | if (parameters.containsKey("userId")) { |
| | | allMenus = menuMapper.selectUserMenu(Integer.parseInt(parameters.get("userId").toString())); |
| | | } else { |
| | | allMenus = menuMapper.selectOrganizationMenu(orgId); |
| | | allMenus = menuMapper.selectOrganizationMenu(Integer.parseInt(parameters.get("orgId").toString())); |
| | | } |
| | | |
| | | Map<String, Object> resultMap = new LinkedHashMap<>(); |
| | |
| | | } |
| | | |
| | | //获取用户层级菜单递归方法 |
| | | public List<Map<String, Object>> getMenusByRecursion(Menu menu, List<Menu> menus) { |
| | | List<List<Map<String, Object>>> resultList = new ArrayList(); |
| | | private List<Map<String, Object>> getMenusByRecursion(Menu menu, List<Menu> menus) { |
| | | Menu newMenu = new Menu(); |
| | | newMenu.setParentId(menu.getId()); |
| | | //筛选出下一级菜单信息 |
| | |
| | | menuMap.put("menus", getMenusByRecursion(o, menus)); |
| | | list.add(menuMap); |
| | | }); |
| | | resultList.add(list); |
| | | } |
| | | return list; |
| | | } |