Commit 5ef19976 authored by 董建华's avatar 董建华

批量查询

parent 2e2da97a
...@@ -76,14 +76,10 @@ import org.apache.commons.lang3.StringUtils; ...@@ -76,14 +76,10 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils; import org.apache.commons.lang3.math.NumberUtils;
import org.apache.http.HttpStatus; import org.apache.http.HttpStatus;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.Min; import javax.validation.constraints.Min;
......
...@@ -3,9 +3,12 @@ package cn.quantgroup.xyqb.controller.middleoffice.user; ...@@ -3,9 +3,12 @@ package cn.quantgroup.xyqb.controller.middleoffice.user;
import cn.quantgroup.xyqb.entity.User; import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.model.JsonResult; import cn.quantgroup.xyqb.model.JsonResult;
import cn.quantgroup.xyqb.service.user.IUserService; import cn.quantgroup.xyqb.service.user.IUserService;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/** /**
* 用户信息 * 用户信息
...@@ -63,5 +66,20 @@ public class UserController { ...@@ -63,5 +66,20 @@ public class UserController {
//TODO convert to userVO //TODO convert to userVO
return JsonResult.buildSuccessResultGeneric(user); return JsonResult.buildSuccessResultGeneric(user);
} }
/**
* 根据uuid或者userids 获取用户信息
* @param params
* @return
*/
@PostMapping("/getByUuidsOrUserIds")
public JsonResult getByUuidsOrUserIds(@RequestBody Map<String,Object> params){
List<String> vals = (List<String>)params.get("vals");
Integer type = (Integer)params.get("type");
if(type== null || (type !=1 && type !=2)){
return JsonResult.buildErrorStateResult("type错误",null);
}
return JsonResult.buildSuccessResultGeneric(userService.findByUuidsOrUserIds(vals, type));
}
} }
...@@ -49,4 +49,6 @@ public interface IUserRepository extends JpaRepository<User, Long>, JpaSpecifica ...@@ -49,4 +49,6 @@ public interface IUserRepository extends JpaRepository<User, Long>, JpaSpecifica
List<User> findByIdBetween(Long id, Long endId); List<User> findByIdBetween(Long id, Long endId);
List<User> findByUuidIn(List<String> uuids);
} }
...@@ -85,4 +85,12 @@ public interface IUserService { ...@@ -85,4 +85,12 @@ public interface IUserService {
* @return * @return
*/ */
UserFullResp findUserFullSearchByUserId(Long userId); UserFullResp findUserFullSearchByUserId(Long userId);
/**
* 按照userid 或者 uuid 批量查询
* @param vals
* @param type
* @return
*/
List<User> findByUuidsOrUserIds(List<String> vals,Integer type);
} }
...@@ -56,6 +56,7 @@ import java.util.Map; ...@@ -56,6 +56,7 @@ import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/** /**
* Created by Miraculous on 15/7/5. * Created by Miraculous on 15/7/5.
...@@ -412,4 +413,22 @@ public class UserServiceImpl implements IUserService, IBaseController { ...@@ -412,4 +413,22 @@ public class UserServiceImpl implements IUserService, IBaseController {
userFullResp.setContacts(contacts); userFullResp.setContacts(contacts);
return userFullResp; return userFullResp;
} }
@Override
public List<User> findByUuidsOrUserIds(List<String> vals, Integer type) {
if (CollectionUtils.isEmpty(vals)) {
return Collections.EMPTY_LIST;
}
if (type == 1) {//1是userids
List<Long> collect = vals.stream()
.map(Long::valueOf)
.collect(Collectors.toList());
return userRepository.findByIdIn(collect);
} else { //不是1 就是 uuids
return userRepository.findByUuidIn(vals);
}
}
} }
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