Commit 5fc79319 authored by guangjing.gao's avatar guangjing.gao

批量根据用户id手机号改造

parent 29fa2d0a
...@@ -269,15 +269,15 @@ public class InnerController implements IBaseController { ...@@ -269,15 +269,15 @@ public class InnerController implements IBaseController {
*/ */
@RequestMapping("/user/getPhoneByUserIds") @RequestMapping("/user/getPhoneByUserIds")
@ApiOperation(httpMethod = "POST", value = "根据用户 ID 批量查询用户信息") @ApiOperation(httpMethod = "POST", value = "根据用户 ID 批量查询用户信息")
public JsonResult findByIds(@RequestParam(value = "userIds") String userIdsString) { public JsonResult findByIds(@RequestParam(value = "userIds") String userIdsString, @RequestParam(required = false) Integer tenantId) {
log.info("批量查询用户的手机号列表, userIdsString:" + userIdsString); log.info("批量查询用户的手机号列表, userIdsString:" + userIdsString + ", tenantId:" + tenantId);
if (StringUtils.isEmpty(userIdsString)) { if (StringUtils.isEmpty(userIdsString)) {
return JsonResult.buildErrorStateResult(null, null); return JsonResult.buildErrorStateResult(null, null);
} }
List<Long> userIds = JSONObject.parseObject(userIdsString, new TypeReference<List<Long>>() { List<Long> userIds = JSONObject.parseObject(userIdsString, new TypeReference<List<Long>>() {
}); });
if (!CollectionUtils.isEmpty(userIds) && userIds.size() <= Constants.USER_ID_BATCH_SIZE) { if (!CollectionUtils.isEmpty(userIds) && userIds.size() <= Constants.USER_ID_BATCH_SIZE) {
Map<Long, String> userIdAndPhoneMap = userService.findPhoneByIdsInDb(userIds); Map<Long, String> userIdAndPhoneMap = userService.findPhoneByIdsInDb(userIds, tenantId);
return JsonResult.buildSuccessResult("", userIdAndPhoneMap); return JsonResult.buildSuccessResult("", userIdAndPhoneMap);
} else { } else {
return JsonResult.buildErrorStateResult("批量查询每次最多进行500条用户信息的查询", null); return JsonResult.buildErrorStateResult("批量查询每次最多进行500条用户信息的查询", null);
......
...@@ -38,7 +38,7 @@ public interface IUserService { ...@@ -38,7 +38,7 @@ public interface IUserService {
*/ */
String findUuid(String phoneNo, String idNo); String findUuid(String phoneNo, String idNo);
Map<Long, String> findPhoneByIdsInDb(List<Long> userIds); Map<Long, String> findPhoneByIdsInDb(List<Long> userIds, Integer tenantId);
User saveUser(User user); User saveUser(User user);
......
...@@ -106,12 +106,16 @@ public class UserServiceImpl implements IUserService, IBaseController { ...@@ -106,12 +106,16 @@ public class UserServiceImpl implements IUserService, IBaseController {
@Override @Override
@TargetDataSource(type = DSType.SLAVE)//查询从库 @TargetDataSource(type = DSType.SLAVE)//查询从库
public Map<Long, String> findPhoneByIdsInDb(List<Long> userIds) { public Map<Long, String> findPhoneByIdsInDb(List<Long> userIds, Integer tenantId) {
if (CollectionUtils.isEmpty(userIds)) { if (CollectionUtils.isEmpty(userIds)) {
return Maps.newHashMap(); return Maps.newHashMap();
} }
Map<Long, String> userIdAndPhoneMap = Maps.newHashMap(); Map<Long, String> userIdAndPhoneMap = Maps.newHashMap();
List<User> users = userRepository.findByIdIn(userIds); List<User> users = userRepository.findByIdIn(userIds);
//校验租户ID
if (TenantUtil.checkoutTenantIsDefault(tenantId)) {
users = tenantService.selectUsersByTenantId(users, tenantId);
}
users.forEach(user -> userIdAndPhoneMap.put(user.getId(), user.getPhoneNo())); users.forEach(user -> userIdAndPhoneMap.put(user.getId(), user.getPhoneNo()));
return userIdAndPhoneMap; return userIdAndPhoneMap;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment