<select id="select" parameterType="java.util.Map" resultType="com.test.model.User">
select
user_id userid,
username,
password,
sex,
createtime
from
user
<where>
<if test="username != null and username != ''">
and username like concat('%',#{username},'%')
</if>
<if test="sex != null">
and sex = #{sex}
</if>
<if test="startDay != null and startDay != ''">
and createtime >= #{startDay}
</if>
<if test="endDay != null and endDay != ''">
<![CDATA[
and createtime <= concat(#{endDay},' 23:59:59')
]]>
</if>
</where>
<select id="select" parameterType="java.util.Map" resultType="com.test.model.User">
select
user_id userid,
username,
password,
sex,
createtime
from
user
<trim prefix="where" prefixOverrides="and" >
<if test="username != null and username != ''">
and username like concat('%',#{username},'%')
</if>
<if test="sex != null">
and sex = #{sex}
</if>
<if test="startDay != null and startDay != ''">
and createtime >= #{startDay}
</if>
<if test="endDay != null and endDay != ''">
<![CDATA[
and createtime <= concat(#{endDay},' 23:59:59')
]]>
</if>
</trim>
<choose>
<when test="type == 1">
and 1=1
</when>
<when test="type == 2">
or 1=1
</when>
<otherwise>
and 1!=1
</otherwise>
</choose>