|
@@ -1,11 +1,21 @@
|
|
|
package com.fdkankan.fusion.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.fdkankan.fusion.entity.TmRole;
|
|
|
+import com.fdkankan.fusion.entity.TmUserRole;
|
|
|
import com.fdkankan.fusion.mapper.ITmRoleMapper;
|
|
|
import com.fdkankan.fusion.service.ITmRoleService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fdkankan.fusion.service.ITmUserRoleService;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
* 角色表 服务实现类
|
|
@@ -17,4 +27,34 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
|
public class TmRoleServiceImpl extends ServiceImpl<ITmRoleMapper, TmRole> implements ITmRoleService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ ITmUserRoleService tmUserRoleService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HashMap<String, TmRole> getMapByUserIds(Set<String> userIds) {
|
|
|
+ HashMap<String, TmRole> map = new HashMap<>();
|
|
|
+ HashMap<String, TmRole> userMap = new HashMap<>();
|
|
|
+ HashMap<String, String > userRoleMap = new HashMap<>();
|
|
|
+ if(userIds.size() >0){
|
|
|
+ LambdaQueryWrapper<TmUserRole> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.in(TmUserRole::getUserId,userIds);
|
|
|
+ List<TmUserRole> list = tmUserRoleService.list(wrapper);
|
|
|
+ list.forEach(entity -> userRoleMap.put(entity.getUserId(),entity.getRoleId()));
|
|
|
+ Set<String> roleIds = list.stream().map(TmUserRole::getRoleId).collect(Collectors.toSet());
|
|
|
+ if(roleIds.size() >0){
|
|
|
+ List<TmRole> tmRoles = this.listByIds(roleIds);
|
|
|
+ tmRoles.forEach(entity -> map.put(entity.getId(),entity));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(map.size() >0 && userRoleMap.size() >0){
|
|
|
+ for (String userId : userRoleMap.keySet()) {
|
|
|
+ String roleId = userRoleMap.get(userId);
|
|
|
+ if(StringUtils.isNotBlank(roleId) && map.get(roleId) !=null){
|
|
|
+ userMap.put(userId,map.get(roleId));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return userMap;
|
|
|
+ }
|
|
|
}
|