| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.constant.UserConstants; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.system.api.domain.SysRole; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.model.UserShop; |
| | | import com.ruoyi.system.domain.SysRoleDept; |
| | | import com.ruoyi.system.domain.SysRoleMenu; |
| | | import com.ruoyi.system.domain.SysUserRole; |
| | |
| | | import com.ruoyi.system.mapper.SysRoleMenuMapper; |
| | | import com.ruoyi.system.mapper.SysUserRoleMapper; |
| | | import com.ruoyi.system.service.ISysRoleService; |
| | | import com.ruoyi.system.service.UserShopService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | |
| | | @Autowired |
| | | private SysRoleDeptMapper roleDeptMapper; |
| | | |
| | | @Resource |
| | | private UserShopService userShopService; |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 根据条件分页查询角色数据 |
| | |
| | | * @return 权限列表 |
| | | */ |
| | | @Override |
| | | public Set<String> selectRolePermissionByUserId(Long userId) { |
| | | List<SysRole> perms = roleMapper.selectRolePermissionByUserId(userId); |
| | | public Set<String> selectRolePermissionByUserId(SysUser user) { |
| | | Set<String> permsSet = new HashSet<>(); |
| | | for (SysRole perm : perms) { |
| | | if (StringUtils.isNotNull(perm)) { |
| | | permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(","))); |
| | | if(user.getRoleType() == 1){ |
| | | List<SysRole> perms = roleMapper.selectRolePermissionByUserId(user.getUserId()); |
| | | for (SysRole perm : perms) { |
| | | if (StringUtils.isNotNull(perm)) { |
| | | permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(","))); |
| | | } |
| | | } |
| | | }else{ |
| | | List<UserShop> list = userShopService.list(new LambdaQueryWrapper<UserShop>().eq(UserShop::getUserId, user.getUserId()) |
| | | .eq(UserShop::getShopId, user.getObjectId())); |
| | | for (UserShop userShop : list) { |
| | | if (StringUtils.isNotNull(userShop)) { |
| | | permsSet.add(userShop.getRoleId() + ""); |
| | | } |
| | | } |
| | | } |
| | | return permsSet; |