zoukankan      html  css  js  c++  java
  • 关于通用mapper的weekendCriteria用法

    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 = ?)
  • 相关阅读:
    HDU_2203_KMP入门
    HDU_1711_初识KMP算法
    过滤器基础
    HDU_1907_基础博弈nim游戏
    nim游戏解法(转)
    HDU_1517_博弈(巧妙规律)
    HDU_1850_nim游戏
    HDU_1847_基础博弈sg函数
    < 转>Java 反射机制浅析
    <转>单机版搭建Hadoop环境
  • 原文地址:https://www.cnblogs.com/cherishforchen/p/11564359.html
Copyright © 2011-2022 走看看