| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | public class RoleServiceImpl implements IRoleService { |
| | |
| | | return userRoleMapper.deleteUserRoleInfo(userRole); |
| | | } |
| | | |
| | | @Override |
| | | public int deleteAuthUsers(Long roleId, String userIds) { |
| | | return userRoleMapper.deleteUserRoleInfos(roleId, Convert.toLongArray(userIds)); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public int insertAuthUsers(Long roleId, String userIds) { |
| | | Long[] users = Convert.toLongArray(userIds); |
| | | |
| | | List<UserRole> list = new ArrayList<UserRole>(); |
| | | for (Long userId : users) { |
| | | |
| | | /** |
| | | * 遍历分配用户集合 多角色 |
| | | */ |
| | | List<UserRole> list = Arrays.stream(users).map(u -> { |
| | | UserRole ur = new UserRole(); |
| | | ur.setUserId(userId); |
| | | ur.setUserId(u); |
| | | ur.setRoleId(roleId); |
| | | list.add(ur); |
| | | } |
| | | return ur; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | return userRoleMapper.batchUserRole(list); |
| | | } |
| | | } |