一、mapper.java
public List<IncenseNews> selectIncenseNewsList(
@Param("incenseNews") IncenseNews incenseNews,
@Param("dateTime") String dateTime);
二、mapper.xml
注意,使⽤了@Pram注解在mapper.xml不加 parameterType
<select id="selectIncenseNewsList" resultMap="IncenseNewsResult">
select news_id,
news_title,
news_introduction,
news_photo,
news_source,
news_time,
news_body,
n.type_id,
nt.type_name,
news_order,
n.deleted
from news n
join news_type nt on n.type_id = nt.type_id
<where>
<if test="incenseNews.newsTitle != null and incenseNews.newsTitle != ''">and news_title like concat('%', #{incenseNews.newsTitle}, '%')</if>
<if test="incenseNews.newsSource != null and incenseNews.newsSource != ''">and news_source like concat('%', #{incenseNews.newsSource}, '%')
</if>
<if test="incenseNews.typeName != null and incenseNews.typeName != ''">and nt.type_name like concat('%', #{incenseNews.typeName}, '%')
</if>
<if test="incenseNews.typeId != null ">and n.type_id = #{incenseNews.typeId}</if>
<if test="dateTime != null ">and news_time like concat('%', #{dateTime}, '%')</if>
</where>
</select>