把这个查询条件用 myBatis-plus改写 <select id="selectALLBycondition" resultMap="TicketMap"> select * from t_ticket where <if test="companyName!=null and companyName!=''"> companyName like concat('%',#{companyName},'%') and </if> <if test="money!=null and money!=''"> money > #{money} and </if> <if test="subject!=null and subject!=''"> subject like concat('%',#{subject},'%') and </if> <if test="type!=null and type!=''"> type like concat('%',#{type},'%') and </if> status!='0' </select>

时间: 2024-03-22 08:38:53 浏览: 18
可以使用Mybatis-plus提供的QueryWrapper来实现条件查询,具体实现如下: ``` public List<Ticket> selectALLBycondition(String companyName, Double money, String subject, String type) { QueryWrapper<Ticket> queryWrapper = new QueryWrapper<>(); queryWrapper.eq("status", 1); if (companyName != null && !"".equals(companyName)) { queryWrapper.like("companyName", companyName); } if (money != null) { queryWrapper.gt("money", money); } if (subject != null && !"".equals(subject)) { queryWrapper.like("subject", subject); } if (type != null && !"".equals(type)) { queryWrapper.like("type", type); } return ticketMapper.selectList(queryWrapper); } ``` 其中,QueryWrapper的eq方法表示等于,like方法表示模糊查询,gt方法表示大于。最后通过调用selectList方法,返回符合条件的Ticket对象列表。

相关推荐

<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.phonemarket.mapper.BannerMapper"> <resultMap type="Banner" id="BaseResultMap"> <id property="bannerId" column="banner_id" /> <result property="bannerName" column="banner_name" /> <result property="bannerUrl" column="banner_url" /> <result property="bannerImg" column="banner_img" /> <result property="bannerState" column="banner_state" /> </resultMap> <insert id="addBanner" parameterType="Banner"> insert into banner(banner_name,banner_url,banner_img) values(#{bannerName},#{bannerUrl},#{bannerImg}) </insert> <update id="deleteBanner" parameterType="java.lang.Integer"> update banner set banner_state=-1 where banner_id=#{id} </update> <update id="changeBannerState" parameterType="java.lang.Integer"> update banner set banner_state=#{0} where banner_id=#{1} </update> <update id="updateBanner" parameterType="Banner"> update banner <set> <if test="bannerName!=null"> banner_name=#{bannerName}, </if> <if test="bannerUrl!=null"> banner_url=#{bannerUrl}, </if> <if test="bannerImg!=null"> banner_img=#{bannerImg} </if> </set> where banner_id=#{bannerId} </update> <select id="findBannerById" parameterType="java.lang.Integer" resultMap="BaseResultMap"> select * from banner where banner_id=#{id} </select> <select id="findAllBanner" resultMap="BaseResultMap"> select * from banner where banner_state > 0 </select> <select id="findAllBannerByLikeName" parameterType="java.lang.String" resultMap="BaseResultMap"> select * from banner where banner_state > 0 and banner_name like '%${value}%' </select> <select id="findAllShowBanner" resultMap="BaseResultMap"> select * from banner where banner_state=1 </select> </mapper>

最新推荐

recommend-type

MyBatis-Plus多表联合查询并且分页(3表联合)

主要介绍了MyBatis-Plus多表联合查询并且分页(3表联合),文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
recommend-type

mybatis-plus QueryWrapper自定义查询条件的实现

主要介绍了mybatis-plus QueryWrapper自定义查询条件的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
recommend-type

SpringBoot整合mybatis-plus实现多数据源的动态切换且支持分页查询.pdf

SpringBoot整合mybatis-plus实现多数据源的动态切换且支持分页查询,案例以postgresql和oracle数据库为数据源,分别使用mybatis-plus分页插件和pagehelper分页插件实现分页查询。
recommend-type

解决mybatis-plus3.1.1版本使用lambda表达式查询报错的方法

主要介绍了解决mybatis-plus3.1.1版本使用lambda表达式查询报错的方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
recommend-type

mybatis-plus配置控制台打印完整带参数SQL语句的实现

主要介绍了mybatis-plus配置控制台打印完整带参数SQL语句,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

MATLAB柱状图在信号处理中的应用:可视化信号特征和频谱分析

![matlab画柱状图](https://img-blog.csdnimg.cn/3f32348f1c9c4481a6f5931993732f97.png) # 1. MATLAB柱状图概述** MATLAB柱状图是一种图形化工具,用于可视化数据中不同类别或组的分布情况。它通过绘制垂直条形来表示每个类别或组中的数据值。柱状图在信号处理中广泛用于可视化信号特征和进行频谱分析。 柱状图的优点在于其简单易懂,能够直观地展示数据分布。在信号处理中,柱状图可以帮助工程师识别信号中的模式、趋势和异常情况,从而为信号分析和处理提供有价值的见解。 # 2. 柱状图在信号处理中的应用 柱状图在信号处理
recommend-type

hive中 的Metastore

Hive中的Metastore是一个关键的组件,它用于存储和管理Hive中的元数据。这些元数据包括表名、列名、表的数据类型、分区信息、表的存储位置等信息。Hive的查询和分析都需要Metastore来管理和访问这些元数据。 Metastore可以使用不同的后端存储来存储元数据,例如MySQL、PostgreSQL、Oracle等关系型数据库,或者Hadoop分布式文件系统中的HDFS。Metastore还提供了API,使得开发人员可以通过编程方式访问元数据。 Metastore的另一个重要功能是跟踪表的版本和历史。当用户对表进行更改时,Metastore会记录这些更改,并且可以让用户回滚到
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。