https://www.cnblogs.com/grey-wolf/p/8435723.html; WeekendUser weekend = new Weekend(User. class ); // 关键字查询部分 String keyword = pageReq.getKeyword(); WeekendCriteria User, Object keywordCriteria = weekend.weekendCriteria(); i
https://www.cnblogs.com/grey-wolf/p/8435723.html;
Weekend<User> weekend = new Weekend<>(User.class); //关键字查询部分 String keyword = pageReq.getKeyword(); WeekendCriteria<User, Object> keywordCriteria = weekend.weekendCriteria(); if (StringUtils.isNotEmpty(keyword)) { keywordCriteria.orLike(User::getUserName, keyword).orLike(User::getPoliceNo, keyword).orLike(User::getRealName, keyword); //此处不需要再用下面这一句了,不然上面这个条件组合会重复一次 //weekend.and(keywordCriteria) } //部门查询部分 Example example = new Example(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 = ?)