Commit 1ec96cf6 authored by xiaoguang.xu's avatar xiaoguang.xu

fix : 只能equals

parent 15d2f3ec
......@@ -123,26 +123,14 @@ public class UserDetailServiceImpl implements IUserDetailService {
private Specification<UserDetail> getSpecification(String name, String phoneNo, String idNo) {
List<Predicate> list = new ArrayList<>();
Specification<UserDetail> specification = (root, criteriaQuery, criteriaBuilder) -> {
if(ValidationUtil.validatePhoneNo(phoneNo)){
list.add(criteriaBuilder.equal(root.get(Constants.PHONE_NO).as(String.class), phoneNo));
}else if (StringUtils.isNotBlank(phoneNo)) {
if (phoneNo.length() < 9) {
log.error("哪个傻逼用这么少的数字查. phoneNo:{}", phoneNo);
throw new RuntimeException("not_allowed");
}
if (!StringUtils.isEmpty(name)) {
list.add(criteriaBuilder.equal(root.get("name").as(String.class), name));
}
if (StringUtils.isNotBlank(idNo)) {
if(Objects.equals(Constants.IDNO_LENGTH, idNo.length())){
list.add(criteriaBuilder.equal(root.get("idNo").as(String.class), idNo));
}else{
if (idNo.length() < 16) {
log.error("哪个傻逼用这么少的数字查. idNo:{}", idNo);
throw new RuntimeException("not_allowed");
}
}
if (!StringUtils.isEmpty(phoneNo)) {
list.add(criteriaBuilder.equal(root.get(Constants.PHONE_NO).as(String.class), phoneNo));
}
if (StringUtils.isNotBlank(name)) {
list.add(criteriaBuilder.equal(root.get("name").as(String.class), name));
if (!StringUtils.isEmpty(idNo)) {
list.add(criteriaBuilder.equal(root.get("idNo").as(String.class), idNo));
}
Predicate[] p = new Predicate[list.size()];
return criteriaBuilder.and(list.toArray(p));
......
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