https://www.cnblogs.com/grey-wolf/p/8435723.html;
Weekend <the User> Weekend = new new Weekend <> (the User. Class ); // keyword query part of the String keyword = pageReq.getKeyword (); WeekendCriteria <the User, Object> keywordCriteria = weekend.weekendCriteria (); IF (StringUtils.isNotEmpty (keyword)) { keywordCriteria.orLike (the User ::, getUserName, keyword) .orLike (the User :: getPoliceNo, keyword) .orLike (the User :: getRealName, keyword); // here not necessary to use the one below it, otherwise, the above combination of conditions will repeat // weekend.and (keywordCriteria) } // sector query part Example Example = new new Example (the User.class); Example.Criteria criteria = example.createCriteria(); criteria.andEqualTo("departmentId", departmentId); weekend.and(criteria); PageHelper.startPage(pageReq.getPageIndex(), pageReq.getPageSize()); List<User> users = userMapper.selectByExample(weekend);
相当于
WHERE ( user_name = ? OR police_no = ? OR real_name = ? ) AND (department_id = ?)