concroller:

/*** 查询列表* @return*/@ApiResponses({@ApiResponse(code = 200, message = "正常", response = SourceMateria.class)})@ApiOperation(value="全部查询")@GetMappingpublic AjaxResult selectAll(@RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,@RequestParam(value = "pageSize", required = false, defaultValue = "20") Integer pageSize,@ApiParam(name="id", value="素材id(根据id查询)")@RequestParam(value = "id", required=false)Long id,@ApiParam(name="screenId", value="筛选条件号:1001=最新,1002=最热,1003=免费,1004=付费")@RequestParam(value = "screenId", required=false)Integer screenId,@ApiParam(name="typeId", value="素材类型id(根据类型查询)")@RequestParam(value = "typeId", required=false)Long typeId,@ApiParam(name="title", value="素材标题(根据标题模糊查询)")@RequestParam(value = "title", required=false)String title) {Page<SourceMateria> page = new Page<SourceMateria>(pageNo, pageSize);QueryWrapper<SourceMateria> queryWrapper=new QueryWrapper<>();if(id!=null&&id>0){queryWrapper=queryWrapper.eq("t_source_materia.id",id);//添加访问量SourceMateria sourceMateria = sourceMateriaService.selectById(id);sourceMateria.setTraffic(sourceMateria.getTraffic()+1);sourceMateriaService.updateById(sourceMateria);}if(typeId!=null&&typeId>0){queryWrapper=queryWrapper.eq("t_source_materia_type.id",typeId);}if(title!=null&&title!=""){queryWrapper=queryWrapper.like("t_source_materia.title",title);}if(screenId!=null&&screenId>0){switch (screenId){case 1001: queryWrapper=queryWrapper.orderByDesc("create_time");break;case 1002: queryWrapper=queryWrapper.orderByDesc("share_number");break;case 1003: queryWrapper=queryWrapper.eq("smart_coin",0);break;case 1004: queryWrapper=queryWrapper.gt("smart_coin",0);break;default:break;}}IPage<SourceMateria> pageInfo = sourceMateriaService.restListPage(queryWrapper,page);List<SourceMateriaType> sourceMateriaTypes = sourceMateriaTypeService.selectList(null);Map<String, Object> map = new HashMap<>();map.put("pageInfo",new PageInfo(pageInfo));map.put("allType",sourceMateriaTypes);return AjaxResult.success(map);}

IService :

/*** 接口查询分页列表* @param queryWrapper* @param page* @return*/IPage<SourceMateria> restListPage(QueryWrapper<SourceMateria> queryWrapper, IPage page);

ServiceImpl :

/*** 接口查询分页列表* @param queryWrapper* @param page* @return*/@Overridepublic IPage<SourceMateria> restListPage(QueryWrapper<SourceMateria> queryWrapper, IPage page) {return page.setRecords(sourceMateriaMapper.restListPage(queryWrapper,page));}

Mapper :

List<SourceMateria> restListPage(@Param(Constants.WRAPPER) QueryWrapper<SourceMateria> queryWrapper, IPage<SourceMateria> page);

XML :

<select id="restListPage" resultType="com.mbyte.easy.admin.entity.SourceMateria">SELECTt_source_materia.id,t_source_materia.source_id,t_source_materia_type.name as name,t_source_materia.Icon,t_source_materia.title,t_source_materia.content,t_source_materia.video_url,t_source_materia.smart_coin,t_source_materia.traffic,t_source_materia.share_number,t_source_materia.is_goods,t_source_materia.create_time,t_source_materia.update_timeFROMt_source_materiaINNER JOIN t_source_materia_type ON t_source_materia.source_id = t_source_materia_type.id${ew.customSqlSegment} //querywrapper导入</select>

querywrapper多条件查询相关推荐

  1. Mybatis Plus 入门 简单的CRUD 使用详解 条件查询 分页查询 DML操作 MP代码生成器

    Mybatis Plus入门 MP是 MybatisPlus,简称MP,是一个 Mybatis 的增强工具,在 Mybatis 的基础上只做增强不做改变.MP为简化开发.提高效率而生. 它已经封装好了 ...

  2. springboot封装统一查询对象进行多条件查询案例(mybatis和mybatis-plus+反射两种版本)

    文章目录 mybatis版本: 通用查询接口 封装辅助查询类: 通用controller: 自定义注解 controller service mapper测试 mybatis-plus实现版本 ent ...

  3. mybatisplus的详细使用(自动填充,乐观锁,分页,条件查询)

    1.自动填充 @Data @EqualsAndHashCode(callSuper = false) @TableName("t_user") public class User ...

  4. MyBatis-Plus条件查询——Wrapper

    Wrapper 在MyBatis-Plus中,对于单表的查询我们基本上不用写sql语句的,那么对于一些带有条件判断的sql语句怎么办呢,官方提供了一个很强的东西--Wrapper条件构造器. 环境搭建 ...

  5. Mybatis Plus条件查询

    QueryWrapper 说明:继承自 AbstractWrapper ,自身的内部属性 entity 也用于生成 where 条件及 LambdaQueryWrapper, 可以通过 new Que ...

  6. mybatis-plus在Mapper类中使用@select标签进行多表联合动态条件查询

    1.单表动态条件查询 1)单字段作为参数 直接用@param设置的值作为注入就好了 @Select("select * from ppms_person_message where crea ...

  7. Shardingsphere的分库分表+读写分离+分页条件查询

    Shardingsphere的分库分表与读写分离 导入依赖 <dependencies><dependency><groupId>org.springframewo ...

  8. mybatis XML 中<if>、<choose>、<when>、<otherwise>等标签的使用?多条件查询该怎么处理?

    mybatis XML 中if.choose.when.otherwise等标签的使用 一般使用在多条查询,虽然也可以通过注解写,我比较菜,我不会. 一般多条查询怎么解决? 1.如果是单表间的多条件查 ...

  9. Mybatis-plus :分页带条件查询

    StudentController @ApiOperation("分页带条件查询学生信息")@GetMapping("/getStudentByOpr/{pageNo}/ ...

最新文章

  1. Eclipse 输出的文本乱码
  2. spring web参数传递
  3. Linux下利用rsync实现网站镜像同步
  4. 编写一个Windows服务程序,定时从数据库中拿出记录发送邮件
  5. 中文代码示例之5分钟入门TypeScript
  6. Linux 数据流重定向
  7. 【Linux/Ubuntu学习6】unbuntu 下载android源码
  8. django 套vue 模板_Vue admin template + Django 快速进行Web开发
  9. python flask框架优点_python之全栈(Flask框架)
  10. 如果你产品的卖点跟竞争对手一样,那你怎么脱颖而出?
  11. Atitit ioc 之道 attilax著 第2章 装配Bean 33 2.1 Spring配置的可选方案 34 2.2 自动化装配bean 35 2.2.1 创建可被发现的bean 35 2.
  12. ctf web3 30 flag就在这里快来找找吧http://123.206.87.240:8002/web3
  13. 1.(python)阿拉伯数字转中文大写
  14. ORACLE的exp和expdp何时需要特权豁免访问策略(Exempt Access Policy)进行导出?
  15. Flutter问题集锦——Android Studio 4.0.1 在AVD Manger中启动模拟器报“unable to locate abd”
  16. 天堂里有没有车来车往
  17. 空指针异常是什么意思
  18. Snipaste截图时下拉菜单消失解决方法
  19. SMT贴片元件拆卸的妙招分享
  20. 视频目标检测与轨迹跟踪代码案例

热门文章

  1. php 熊掌号api,关于熊掌号资源提交功能API接口解读
  2. 大数据笔记--Hive(第三篇)
  3. 湖北省美丽乡村示范片建设试点项目资金管理办法
  4. RT1052的PIT定时器
  5. Java.lang.SecurityException
  6. Robocup2D环境搭配以及安装(Ubuntu18.04)
  7. 大神用法 | 我是这样「拆建」笔记结构的
  8. 面试官说 “你还有什么问题想问的” ,作为一名程序员该如何回答?
  9. SOLIDWORKS Electrical和CAD电气版有啥区别?
  10. chatGPT对汽车制造行业有什么帮助