@ApiOperation(value = "动态查询员工", httpMethod = "GET")
@GetMapping("/findUser")
public Page<User> findUser(String realName, Date start, Date end, Boolean sex, String email, String phoneNum,
String telephoneNum, Boolean status,
Pageable pageable) {
QUser user = QUser.user;
Predicate predicate = user.isNotNull().or(user.isNull());
predicate = realName == null ? predicate : ExpressionUtils.and(predicate, user.realName.like("%" + realName + "%"));
predicate = start == null ? predicate : ExpressionUtils.and(predicate, user.birthday.between(start, end));
predicate = sex == null ? predicate : ExpressionUtils.and(predicate, user.sex.ne(sex));
predicate = email == null ? predicate : ExpressionUtils.and(predicate, user.email.like("%" + email + "%"));
predicate = phoneNum == null ? predicate : ExpressionUtils.and(predicate, user.phoneNum.like("%" + phoneNum + "%"));
predicate = telephoneNum == null ? predicate : ExpressionUtils.and(predicate, user.telephoneNum.like("%" + telephoneNum + "%"));
predicate = status == null ? predicate : ExpressionUtils.and(predicate, user.status.eq(status));
return userService.findUser(predicate, pageable);
}
动态模糊查询,是不是有更简便的写法?