| <?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.wzy.dao.EmployeeMapper”>
    <resultMap id=”BaseResultMap” type=”com.wzy.pojo.Employee”>
    <id column=”emp_id” jdbcType=”INTEGER” property=”empId” />
    <result column=”emp_name” jdbcType=”VARCHAR” property=”empName” />
    <result column=”gender” jdbcType=”CHAR” property=”gender” />
    <result column=”email” jdbcType=”VARCHAR” property=”email” />
    <result column=”d_id” jdbcType=”INTEGER” property=”dId” />
    </resultMap>
    <resultMap id=”WithDeptResultMap” type=”com.wzy.pojo.Employee”>
    <id column=”emp_id” jdbcType=”INTEGER” property=”empId” />
    <result column=”emp_name” jdbcType=”VARCHAR” property=”empName” />
    <result column=”gender” jdbcType=”CHAR” property=”gender” />
    <result column=”email” jdbcType=”VARCHAR” property=”email” />
    <result column=”d_id” jdbcType=”INTEGER” property=”dId” />
    <association property=”department” javaType=”com.wzy.pojo.Department”>
    <id column=”dept_id” property=”deptId”/>
    <result column=”dept_name” property=”deptName”/>
    </association>
    </resultMap>

    <sql id=”Example_Where_Clause”>
    <where>
    <foreach collection=”oredCriteria” item=”criteria” separator=”or”>
    <if test=”criteria.valid”>
    <trim prefix=”(“ prefixOverrides=”and” suffix=”)”>
    <foreach collection=”criteria.criteria” item=”criterion”>
    <choose>
    <when test=”criterion.noValue”>
    and ${criterion.condition}
    </when>
    <when test=”criterion.singleValue”>
    and ${criterion.condition} #{criterion.value}
    </when>
    <when test=”criterion.betweenValue”>
    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
    </when>
    <when test=”criterion.listValue”>
    and ${criterion.condition}
    <foreach close=”)” collection=”criterion.value” item=”listItem” open=”(“ separator=”,”>
    #{listItem}
    </foreach>
    </when>
    </choose>
    </foreach>
    </trim>
    </if>
    </foreach>
    </where>
    </sql>
    <sql id=”Update_By_Example_Where_Clause”>
    <where>
    <foreach collection=”example.oredCriteria” item=”criteria” separator=”or”>
    <if test=”criteria.valid”>
    <trim prefix=”(“ prefixOverrides=”and” suffix=”)”>
    <foreach collection=”criteria.criteria” item=”criterion”>
    <choose>
    <when test=”criterion.noValue”>
    and ${criterion.condition}
    </when>
    <when test=”criterion.singleValue”>
    and ${criterion.condition} #{criterion.value}
    </when>
    <when test=”criterion.betweenValue”>
    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
    </when>
    <when test=”criterion.listValue”>
    and ${criterion.condition}
    <foreach close=”)” collection=”criterion.value” item=”listItem” open=”(“ separator=”,”>
    #{listItem}
    </foreach>
    </when>
    </choose>
    </foreach>
    </trim>
    </if>
    </foreach>
    </where>
    </sql>

    <sql id=”Base_Column_List”>
    emp_id, emp_name, gender, email, d_id
    </sql>


    <sql id=”WithDept_Column_List”>
    e.emp_id, e.emp_name, e.gender, e.email, e.d_id,d.dept_id,d.dept_name
    </sql>



    <select id=”selectByVague” resultMap=”WithDeptResultMap”>
    select
    <include refid=”WithDept_Column_List” />
    from myb_emp e left join myb_dept d
    on e.d_id = d.dept_id
    where emp_name like “%”#{empName,jdbcType=VARCHAR}”%” or emp_id = #{empId,jdbcType=INTEGER}

    </select>


    <select id=”selectEmpByName” resultMap=”WithDeptResultMap”>
    select
    <include refid=”Base_Column_List” />/emp_id, emp_name, gender, email, d_id/
    from myb_emp e
    where e.emp_name=#{empName}
    </select>


    <select id=”selectCountWhereName” resultType=”java.lang.Integer”>
    select
    count()
    from myb_emp e
    where e.emp_name=#{empName}
    </select>




    <select id=”selectByExampleWithDept” resultMap=”WithDeptResultMap”>
    select
    <if test=”distinct”>
    distinct
    </if>
    <include refid=”WithDept_Column_List” />

    from myb_emp e left join myb_dept d
    on e.d_id = d.dept_id
    order by e.emp_id

    </*select
    >



    <select id=”selectByPrimaryKeyWithDept” resultMap=”WithDeptResultMap”>
    select
    <include refid=”WithDept_Column_List” />
    from myb_emp e left join myb_dept d
    on e.d_id = d.dept_id
    where emp_id = #{empId,jdbcType=INTEGER}
    </select>



    <select id=”selectByExample” parameterType=”com.wzy.pojo.EmployeeExample” resultMap=”BaseResultMap”>
    select
    <if test=”distinct”>
    distinct
    </if>
    <include refid=”Base_Column_List” />
    from myb_emp
    <if test=”_parameter != null”>
    <include refid=”Example_Where_Clause” />
    </if>
    <if test=”orderByClause != null”>
    order by ${orderByClause}
    </if>
    </select>

    <select id=”selectByPrimaryKey” parameterType=”java.lang.Integer” resultMap=”BaseResultMap”>
    select
    <include refid=”Base_Column_List” />
    from myb_emp
    where emp_id = #{empId,jdbcType=INTEGER}
    </select>
    <delete id=”deleteByPrimaryKey” parameterType=”java.lang.Integer”>
    delete from myb_emp
    where emp_id = #{empId,jdbcType=INTEGER}
    </delete>
    <delete id=”deleteByExample” parameterType=”com.wzy.pojo.EmployeeExample”>
    delete from myb_emp
    <if test=”_parameter != null”>
    <include refid=”Example_Where_Clause” />
    </if>
    </delete>
    <insert id=”insert” parameterType=”com.wzy.pojo.Employee”>
    insert into myb_emp (emp_id, emp_name, gender,
    email, d_id)
    values (#{empId,jdbcType=INTEGER}, #{empName,jdbcType=VARCHAR}, #{gender,jdbcType=CHAR},
    #{email,jdbcType=VARCHAR}, #{dId,jdbcType=INTEGER})
    </insert>
    <insert id=”insertSelective” parameterType=”com.wzy.pojo.Employee”>
    insert into myb_emp
    <trim prefix=”(“ suffix=”)” suffixOverrides=”,”>
    <if test=”empId != null”>
    emp_id,
    </if>
    <if test=”empName != null”>
    emp_name,
    </if>
    <if test=”gender != null”>
    gender,
    </if>
    <if test=”email != null”>
    email,
    </if>
    <if test=”dId != null”>
    d_id,
    </if>
    </trim>
    <trim prefix=”values (“ suffix=”)” suffixOverrides=”,”>
    <if test=”empId != null”>
    #{empId,jdbcType=INTEGER},
    </if>
    <if test=”empName != null”>
    #{empName,jdbcType=VARCHAR},
    </if>
    <if test=”gender != null”>
    #{gender,jdbcType=CHAR},
    </if>
    <if test=”email != null”>
    #{email,jdbcType=VARCHAR},
    </if>
    <if test=”dId != null”>
    #{dId,jdbcType=INTEGER},
    </if>
    </trim>
    </insert>
    <select id=”countByExample” parameterType=”com.wzy.pojo.EmployeeExample” resultType=”java.lang.Long”>
    select count() from myb_emp
    <if test=”_parameter != null”>
    <include refid=”Example_Where_Clause” />
    </if>
    </select>
    <update id=”updateByExampleSelective” parameterType=”map”>
    update myb_emp
    <set>
    <if test=”record.empId != null”>
    emp_id = #{record.empId,jdbcType=INTEGER},
    </if>
    <if test=”record.empName != null”>
    emp_name = #{record.empName,jdbcType=VARCHAR},
    </if>
    <if test=”record.gender != null”>
    gender = #{record.gender,jdbcType=CHAR},
    </if>
    <if test=”record.email != null”>
    email = #{record.email,jdbcType=VARCHAR},
    </if>
    <if test=”record.dId != null”>
    d_id = #{record.dId,jdbcType=INTEGER},
    </if>
    </set>
    <if test=”_parameter != null”>
    <include refid=”Update_By_Example_Where_Clause” />
    </if>
    </update>
    <update id=”updateByExample” parameterType=”map”>
    update myb_emp
    set emp_id = #{record.empId,jdbcType=INTEGER},
    emp_name = #{record.empName,jdbcType=VARCHAR},
    gender = #{record.gender,jdbcType=CHAR},
    email = #{record.email,jdbcType=VARCHAR},
    d_id = #{record.dId,jdbcType=INTEGER}
    <if test=”_parameter != null”>
    <include refid=”Update_By_Example_Where_Clause” />
    </if>
    </update>
    <update id=”updateByPrimaryKeySelective” parameterType=”com.wzy.pojo.Employee”>
    update myb_emp
    <set>
    <if test=”empName != null”>
    emp_name = #{empName,jdbcType=VARCHAR},
    </if>
    <if test=”gender != null”>
    gender = #{gender,jdbcType=CHAR},
    </if>
    <if test=”email != null”>
    email = #{email,jdbcType=VARCHAR},
    </if>
    <if test=”dId != null”>
    d_id = #{dId,jdbcType=INTEGER},
    </if>
    </set>
    where emp_id = #{empId,jdbcType=INTEGER}
    </update>
    <update id=”updateByPrimaryKey” parameterType=”com.wzy.pojo.Employee”>
    update myb_emp
    set emp_name = #{empName,jdbcType=VARCHAR},
    gender = #{gender,jdbcType=CHAR},
    email = #{email,jdbcType=VARCHAR},
    d_id = #{dId,jdbcType=INTEGER}
    where emp_id = #{empId,jdbcType=INTEGER}
    </update>
    </*mapper
    > | | —- |