查角色下的人
This commit is contained in:
@@ -117,7 +117,7 @@ public interface SysRoleMapper {
|
||||
List<EnterpriseUserRole> selectUserRoleBySourceAndUserId(@Param("source") String source ,
|
||||
@Param("userIdList") List<String> userIdList);
|
||||
|
||||
List<String> getUserIdListByRoleIdList(@Param("roleIdList") List<Long> roleIdList);
|
||||
List<EnterpriseUserRole> getUserIdListByRoleIdList(@Param("roleIdList") List<Long> roleIdList);
|
||||
/**
|
||||
* 获取用户岗位信息
|
||||
* @param userIdList
|
||||
|
||||
@@ -89,9 +89,10 @@
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getUserIdListByRoleIdList" resultType="java.lang.String">
|
||||
<select id="getUserIdListByRoleIdList" resultType="com.cool.store.entity.EnterpriseUserRole">
|
||||
select
|
||||
distinct a.user_id
|
||||
b.role_id as roleId,
|
||||
b.user_id as userId
|
||||
from enterprise_user_${enterpriseId} a
|
||||
left join enterprise_user_role_${enterpriseId} b on a.user_id=b.user_id
|
||||
<where>
|
||||
|
||||
@@ -9,6 +9,13 @@ public interface RegionService {
|
||||
|
||||
RegionPathNameVO getAllRegionName(Long regionId);
|
||||
|
||||
/**
|
||||
* 获取所属战区
|
||||
* @param regionId
|
||||
* @return
|
||||
*/
|
||||
String getBelongWarRegionName(Long regionId);
|
||||
|
||||
/**
|
||||
* 根据意向区域找大区id
|
||||
* @param wantShopAreaId
|
||||
|
||||
@@ -90,6 +90,16 @@ public class RegionServiceImpl implements RegionService {
|
||||
return regionPathNameVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBelongWarRegionName(Long regionId) {
|
||||
RegionPathNameVO regionPathNameVO = this.getAllRegionName(regionId);
|
||||
if(regionPathNameVO != null && StringUtils.isNotBlank(regionPathNameVO.getAllRegionName())){
|
||||
String allRegionName = regionPathNameVO.getAllRegionName();
|
||||
return allRegionName.substring(allRegionName.indexOf(Constants.M_LINE) + 1);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据意向区域找大区id
|
||||
* @param wantShopAreaId
|
||||
|
||||
@@ -113,7 +113,20 @@ public class UserAuthMappingServiceImpl implements UserAuthMappingService {
|
||||
if(CollectionUtils.isEmpty(roleIds) || Objects.isNull(regionId)){
|
||||
return Maps.newHashMap();
|
||||
}
|
||||
return null;
|
||||
RegionDO regionDO = regionMapper.getByRegionId(regionId);
|
||||
if(regionDO == null){
|
||||
throw new ServiceException(ErrorCodeEnum.REGION_NOT_EXIST);
|
||||
}
|
||||
// 查找有区域权限的人
|
||||
List<String> authRegionUserIdList = authWarRegionUser(regionId);
|
||||
if(CollectionUtils.isEmpty(authRegionUserIdList)){
|
||||
return Maps.newHashMap();
|
||||
}
|
||||
List<Long> roleIdList = roleIds.stream().map(a -> Long.valueOf(a)).collect(Collectors.toList());
|
||||
List<EnterpriseUserRole> enterpriseUserRoleList = sysRoleMapper.getUserIdListByRoleIdList(roleIdList);
|
||||
enterpriseUserRoleList = enterpriseUserRoleList.stream().filter(o -> authRegionUserIdList.contains(o.getUserId())).collect(Collectors.toList());
|
||||
Map<String, List<String>> enterpriseUserRoleMap = ListUtils.emptyIfNull(enterpriseUserRoleList).stream().collect(Collectors.groupingBy(EnterpriseUserRole::getRoleId, Collectors.mapping(k->k.getUserId(), Collectors.toList())));
|
||||
return enterpriseUserRoleMap;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -40,5 +40,10 @@ public class RegionController {
|
||||
return ResponseResult.success(regionService.listByThirdRegionType(parentId, thirdRegionType));
|
||||
}
|
||||
|
||||
@ApiOperation("获取所属战区")
|
||||
@GetMapping("/getBelongWarRegionName")
|
||||
public ResponseResult<String> getBelongWarRegionName(@RequestParam(value = "regionId", required = true) Long regionId) {
|
||||
return ResponseResult.success(regionService.getBelongWarRegionName(regionId));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @ClassName UserAuthMappingController
|
||||
@@ -41,4 +42,11 @@ public class UserAuthMappingController {
|
||||
return ResponseResult.success(userAuthMappingService.listWantShopAreaIdByUserId(userId));
|
||||
}
|
||||
|
||||
@ApiOperation("找角色下的人")
|
||||
@GetMapping("/getUserIdByRoleIdAndRegionId")
|
||||
public ResponseResult<Map<String, List<String>>> getUserIdByRoleIdAndRegionId(@RequestParam(value = "roleIds", required = true) List<String> roleIds,
|
||||
@RequestParam(value = "regionId", required = true) Long regionId) {
|
||||
return ResponseResult.success(userAuthMappingService.getUserIdByRoleIdAndRegionId(roleIds, regionId));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user