<?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.slcf.dao.UserDao">
|
|
<resultMap type="com.slcf.pojo.UserBean" id="UserBeanResult"></resultMap>
|
|
<!-- mapper不支持sql语句嵌套时,采用sql片段包含方式,解决xml标签问题 -->
|
<sql id="userConditionSql">
|
<if test="userId!=null and userId!='' and userId!=0 ">
|
and user_id=#{userId}
|
</if>
|
<if test="userName!=null and userName!=''">
|
and user_name like '%' + #{userName} + '%'
|
</if>
|
<if test="deptId!=null and deptId!=0">
|
and u.dept_id=#{deptId}
|
</if>
|
</sql>
|
|
<select id="getUserListByCon" parameterType="map" resultMap="UserBeanResult">
|
SELECT top (#{epage}) u.*,d.dept_name from tb_user u left join tb_dept d on u.dept_id=d.dept_id
|
<where>
|
user_id not in (select top ((#{spage}-1)*#{epage}) user_id from tb_user u left join tb_dept d on u.dept_id=d.dept_id
|
<where>
|
1=1
|
<include refid="userConditionSql"></include>
|
)
|
</where>
|
<include refid="userConditionSql"></include>
|
</where>
|
</select>
|
|
|
<select id="getContByCon" parameterType="map" resultType="Integer">
|
select count(1) from tb_user u left join tb_dept d on u.dept_id=d.dept_id
|
<where>
|
<![CDATA[
|
1=1
|
]]>
|
<include refid="userConditionSql"></include>
|
</where>
|
</select>
|
</mapper>
|