xml中根据各种字段进行查询
- 欲实现:
- 其中映射的类为:
- xml中映射的语句为:
> > > > ```<?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.ws.firestation.mapper.TradeRecordMapper"> <select id="listsome" resultType="com.ws.firestation.entity.po.TradeRecord"> select * from firecab.trade_record where 1=1 <if test= "goodsName !=null and goodsName !=''"> and goods_name=#{goodsName} </if> <if test= "serverId !=null and serverId !=''"> and server_id=#{serverId} </if> <if test= "cabintCatalogy !=null and cabintCatalogy !=''"> and cabint_catalogy=#{cabintCatalogy} </if> <if test= "Type !=null and Type !=''"> and type=#{Type} </if> <if test= "Tradetime !=null and Tradetime !=''"> and tradetime </if> </select> </mapper>
- 这样就能实现随意用户输入哪几个字段来进行查询。