版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sinat_33625560/article/details/84834817
<select id="list" resultType="com.bootdo.system.domain.UserDO">
select
`user_id`,`username`,`name`,`password`,`dept_id`,`email`,`mobile`,`status`,`user_id_create`,`gmt_create`,`gmt_modified`,`sex`,`birth`,`pic_id`,`live_address`,`hobby`,`province`,`city`,`district`
from sys_user
<where>
<if test="userId != null and userId != ''">and user_id = #{userId}</if>
<if test="username != null and username != ''">and username = #{username}</if>
<if test="name != null and name != ''">and name = #{name}</if>
<if test="password != null and password != ''">and password = #{password}</if>
<if test="deptId != null and deptId != ''">and dept_id = #{deptId}</if>
<if test="deptIds != null and deptIds.size() > 0">and dept_id in
<foreach collection="deptIds" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="email != null and email != ''">and email = #{email}</if>
<if test="mobile != null and mobile != ''">and mobile = #{mobile}</if>
<if test="status != null and status != ''">and status = #{status}</if>
<if test="userIdCreate != null and userIdCreate != ''">and user_id_create = #{userIdCreate}</if>
<if test="gmtCreate != null and gmtCreate != ''">and gmt_create = #{gmtCreate}</if>
<if test="gmtModified != null and gmtModified != ''">and gmt_modified = #{gmtModified}</if>
<if test="sex != null and sex != ''">and sex = #{sex}</if>
<if test="birth != null and birth != ''">and birth = #{birth}</if>
<if test="picId != null and picId != ''">and pic_id = #{picId}</if>
<if test="liveAddress != null and liveAddress != ''">and live_address = #{liveAddress}</if>
<if test="hobby != null and hobby != ''">and hobby = #{hobby}</if>
<if test="province != null and province != ''">and province = #{province}</if>
<if test="city != null and city != ''">and city = #{city}</if>
<if test="district != null and district != ''">and district = #{district}</if>
</where>
<choose>
<when test="sort != null and sort.trim() != ''">
order by ${sort} ${order}
</when>
<otherwise>
order by user_id desc
</otherwise>
</choose>
<if test="offset != null and limit != null">
limit #{offset}, #{limit}
</if>