查角色下的人

This commit is contained in:
wangxiaopeng
2024-04-08 12:19:50 +08:00
parent 7193807f2e
commit 8b50b807a5
7 changed files with 48 additions and 4 deletions

View File

@@ -117,7 +117,7 @@ public interface SysRoleMapper {
List<EnterpriseUserRole> selectUserRoleBySourceAndUserId(@Param("source") String source , List<EnterpriseUserRole> selectUserRoleBySourceAndUserId(@Param("source") String source ,
@Param("userIdList") List<String> userIdList); @Param("userIdList") List<String> userIdList);
List<String> getUserIdListByRoleIdList(@Param("roleIdList") List<Long> roleIdList); List<EnterpriseUserRole> getUserIdListByRoleIdList(@Param("roleIdList") List<Long> roleIdList);
/** /**
* 获取用户岗位信息 * 获取用户岗位信息
* @param userIdList * @param userIdList

View File

@@ -89,9 +89,10 @@
</if> </if>
</select> </select>
<select id="getUserIdListByRoleIdList" resultType="java.lang.String"> <select id="getUserIdListByRoleIdList" resultType="com.cool.store.entity.EnterpriseUserRole">
select select
distinct a.user_id b.role_id as roleId,
b.user_id as userId
from enterprise_user_${enterpriseId} a from enterprise_user_${enterpriseId} a
left join enterprise_user_role_${enterpriseId} b on a.user_id=b.user_id left join enterprise_user_role_${enterpriseId} b on a.user_id=b.user_id
<where> <where>

View File

@@ -9,6 +9,13 @@ public interface RegionService {
RegionPathNameVO getAllRegionName(Long regionId); RegionPathNameVO getAllRegionName(Long regionId);
/**
* 获取所属战区
* @param regionId
* @return
*/
String getBelongWarRegionName(Long regionId);
/** /**
* 根据意向区域找大区id * 根据意向区域找大区id
* @param wantShopAreaId * @param wantShopAreaId

View File

@@ -90,6 +90,16 @@ public class RegionServiceImpl implements RegionService {
return regionPathNameVO; 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 * 根据意向区域找大区id
* @param wantShopAreaId * @param wantShopAreaId

View File

@@ -113,7 +113,20 @@ public class UserAuthMappingServiceImpl implements UserAuthMappingService {
if(CollectionUtils.isEmpty(roleIds) || Objects.isNull(regionId)){ if(CollectionUtils.isEmpty(roleIds) || Objects.isNull(regionId)){
return Maps.newHashMap(); 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;
} }
/** /**

View File

@@ -40,5 +40,10 @@ public class RegionController {
return ResponseResult.success(regionService.listByThirdRegionType(parentId, thirdRegionType)); 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));
}
} }

View File

@@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @ClassName UserAuthMappingController * @ClassName UserAuthMappingController
@@ -41,4 +42,11 @@ public class UserAuthMappingController {
return ResponseResult.success(userAuthMappingService.listWantShopAreaIdByUserId(userId)); 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));
}
} }