| | |
| | | import com.google.common.collect.Lists; |
| | | import com.yami.trading.bean.model.User; |
| | | import com.yami.trading.common.constants.Constants; |
| | | import com.yami.trading.security.common.model.YamiSysUser; |
| | | import com.yami.trading.security.common.util.SecurityUtils; |
| | | import com.yami.trading.service.user.UserRecomService; |
| | | import com.yami.trading.service.user.UserService; |
| | |
| | | |
| | | public boolean checkAgent() { |
| | | List<Long> roleIds = sysRoleService.listRoleIdByUserId(SecurityUtils.getSysUser().getUserId()); |
| | | Map<Long, SysRole> sysRoleMap = sysRoleService.list().stream().collect(Collectors.toMap(SysRole::getRoleId, SysRole -> SysRole)); |
| | | List<SysRole> sysRoles = sysRoleService.listByIds(roleIds); |
| | | boolean isAgent = sysRoles.stream().filter(x -> x.getRoleName().equals("代理商")).findFirst().orElse(null) != null; |
| | | /*Map<Long, SysRole> sysRoleMap = sysRoleService.list().stream().collect(Collectors.toMap(SysRole::getRoleId, SysRole -> SysRole)); |
| | | List<String> roleNames = new ArrayList<>(); |
| | | boolean isAgent = false; |
| | | for (Long id : roleIds) { |
| | |
| | | sysRoleMap.get(id).getRoleName().equals("代理商"); |
| | | isAgent = true; |
| | | } |
| | | } |
| | | }*/ |
| | | return isAgent; |
| | | } |
| | | |
| | |
| | | * @return |
| | | */ |
| | | public List<String> getOwnerUserIds() { |
| | | // String userName = SecurityUtils.getSysUser().getUsername(); |
| | | // User user = userService.findByUserName(userName); |
| | | // if (userName.equals("admin")){ |
| | | // return null; |
| | | // } |
| | | // List<String> checked_list = userRecomService. |
| | | // findChildren(user.getUserId()); |
| | | // if (checkAgent()) { |
| | | // if (checked_list.size() > 0) { |
| | | // return checked_list; |
| | | // } else { |
| | | // checked_list.add(userName); |
| | | // return checked_list; |
| | | // } |
| | | // } else { |
| | | // return null; |
| | | // } |
| | | |
| | | return null; |
| | | String userName = SecurityUtils.getSysUser().getUsername(); |
| | | if (userName.equals("admin")){ |
| | | return null; |
| | | } |
| | | if (checkAgent()) { |
| | | User user = userService.findByUserName(userName); |
| | | List<String> checked_list = userRecomService. |
| | | findChildren(user.getUserId()); |
| | | if (checked_list == null || checked_list.isEmpty()) { |
| | | checked_list = new ArrayList<>(); |
| | | } |
| | | checked_list.add(user.getUserId()); |
| | | return checked_list; |
| | | } else { |
| | | return null; |
| | | } |
| | | // if (CollectionUtil.isNotEmpty(roleNames) && roleNames.contains(Constants.SECURITY_ROLE_AGENT)) { |
| | | // List<String> children = this.userRecomService.findChildren(userId.toString()); |
| | | // if (CollectionUtil.isEmpty(children)) { |