<?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.goafanti.common.dao.PersonnelPromotionMapper">
  <resultMap id="BaseResultMap" type="com.goafanti.common.model.PersonnelPromotion">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Sun Apr 26 10:10:12 CST 2020.
    -->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="pd_id" jdbcType="INTEGER" property="pdId" />
    <result column="old_jobs" jdbcType="VARCHAR" property="oldJobs" />
    <result column="old_lvl" jdbcType="VARCHAR" property="oldLvl" />
    <result column="new_jobs" jdbcType="VARCHAR" property="newJobs" />
    <result column="new_lvl" jdbcType="VARCHAR" property="newLvl" />
    <result column="promotion_time" jdbcType="TIMESTAMP" property="promotionTime" />
    <result column="promotion_remarks" jdbcType="VARCHAR" property="promotionRemarks" />
    <result column="annex_url" jdbcType="VARCHAR" property="annexUrl" />
    <result column="annex_name" jdbcType="VARCHAR" property="annexName" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Sun Apr 26 10:10:12 CST 2020.
    -->
    <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">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Sun Apr 26 10:10:12 CST 2020.
    -->
    <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">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Sun Apr 26 10:10:12 CST 2020.
    -->
    id, pd_id, old_jobs, old_lvl, new_jobs, new_lvl, promotion_time, promotion_remarks, 
    annex_url, annex_name, create_time
  </sql>
  <select id="selectByExample" parameterType="com.goafanti.common.model.PersonnelPromotionExample" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Sun Apr 26 10:10:12 CST 2020.
    -->
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from personnel_promotion
    <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">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Sun Apr 26 10:10:12 CST 2020.
    -->
    select 
    <include refid="Base_Column_List" />
    from personnel_promotion
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Sun Apr 26 10:10:12 CST 2020.
    -->
    delete from personnel_promotion
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.goafanti.common.model.PersonnelPromotionExample">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Sun Apr 26 10:10:12 CST 2020.
    -->
    delete from personnel_promotion
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.goafanti.common.model.PersonnelPromotion">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Sun Apr 26 10:10:12 CST 2020.
    -->
    insert into personnel_promotion (id, pd_id, old_jobs, 
      old_lvl, new_jobs, new_lvl, 
      promotion_time, promotion_remarks, annex_url, 
      annex_name, create_time)
    values (#{id,jdbcType=INTEGER}, #{pdId,jdbcType=INTEGER}, #{oldJobs,jdbcType=VARCHAR}, 
      #{oldLvl,jdbcType=VARCHAR}, #{newJobs,jdbcType=VARCHAR}, #{newLvl,jdbcType=VARCHAR}, 
      #{promotionTime,jdbcType=TIMESTAMP}, #{promotionRemarks,jdbcType=VARCHAR}, #{annexUrl,jdbcType=VARCHAR}, 
      #{annexName,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" parameterType="com.goafanti.common.model.PersonnelPromotion">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Sun Apr 26 10:10:12 CST 2020.
    -->
    insert into personnel_promotion
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="pdId != null">
        pd_id,
      </if>
      <if test="oldJobs != null">
        old_jobs,
      </if>
      <if test="oldLvl != null">
        old_lvl,
      </if>
      <if test="newJobs != null">
        new_jobs,
      </if>
      <if test="newLvl != null">
        new_lvl,
      </if>
      <if test="promotionTime != null">
        promotion_time,
      </if>
      <if test="promotionRemarks != null">
        promotion_remarks,
      </if>
      <if test="annexUrl != null">
        annex_url,
      </if>
      <if test="annexName != null">
        annex_name,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="pdId != null">
        #{pdId,jdbcType=INTEGER},
      </if>
      <if test="oldJobs != null">
        #{oldJobs,jdbcType=VARCHAR},
      </if>
      <if test="oldLvl != null">
        #{oldLvl,jdbcType=VARCHAR},
      </if>
      <if test="newJobs != null">
        #{newJobs,jdbcType=VARCHAR},
      </if>
      <if test="newLvl != null">
        #{newLvl,jdbcType=VARCHAR},
      </if>
      <if test="promotionTime != null">
        #{promotionTime,jdbcType=TIMESTAMP},
      </if>
      <if test="promotionRemarks != null">
        #{promotionRemarks,jdbcType=VARCHAR},
      </if>
      <if test="annexUrl != null">
        #{annexUrl,jdbcType=VARCHAR},
      </if>
      <if test="annexName != null">
        #{annexName,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.goafanti.common.model.PersonnelPromotionExample" resultType="java.lang.Long">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Sun Apr 26 10:10:12 CST 2020.
    -->
    select count(*) from personnel_promotion
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Sun Apr 26 10:10:12 CST 2020.
    -->
    update personnel_promotion
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=INTEGER},
      </if>
      <if test="record.pdId != null">
        pd_id = #{record.pdId,jdbcType=INTEGER},
      </if>
      <if test="record.oldJobs != null">
        old_jobs = #{record.oldJobs,jdbcType=VARCHAR},
      </if>
      <if test="record.oldLvl != null">
        old_lvl = #{record.oldLvl,jdbcType=VARCHAR},
      </if>
      <if test="record.newJobs != null">
        new_jobs = #{record.newJobs,jdbcType=VARCHAR},
      </if>
      <if test="record.newLvl != null">
        new_lvl = #{record.newLvl,jdbcType=VARCHAR},
      </if>
      <if test="record.promotionTime != null">
        promotion_time = #{record.promotionTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.promotionRemarks != null">
        promotion_remarks = #{record.promotionRemarks,jdbcType=VARCHAR},
      </if>
      <if test="record.annexUrl != null">
        annex_url = #{record.annexUrl,jdbcType=VARCHAR},
      </if>
      <if test="record.annexName != null">
        annex_name = #{record.annexName,jdbcType=VARCHAR},
      </if>
      <if test="record.createTime != null">
        create_time = #{record.createTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Sun Apr 26 10:10:12 CST 2020.
    -->
    update personnel_promotion
    set id = #{record.id,jdbcType=INTEGER},
      pd_id = #{record.pdId,jdbcType=INTEGER},
      old_jobs = #{record.oldJobs,jdbcType=VARCHAR},
      old_lvl = #{record.oldLvl,jdbcType=VARCHAR},
      new_jobs = #{record.newJobs,jdbcType=VARCHAR},
      new_lvl = #{record.newLvl,jdbcType=VARCHAR},
      promotion_time = #{record.promotionTime,jdbcType=TIMESTAMP},
      promotion_remarks = #{record.promotionRemarks,jdbcType=VARCHAR},
      annex_url = #{record.annexUrl,jdbcType=VARCHAR},
      annex_name = #{record.annexName,jdbcType=VARCHAR},
      create_time = #{record.createTime,jdbcType=TIMESTAMP}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.PersonnelPromotion">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Sun Apr 26 10:10:12 CST 2020.
    -->
    update personnel_promotion
    <set>
      <if test="pdId != null">
        pd_id = #{pdId,jdbcType=INTEGER},
      </if>
      <if test="oldJobs != null">
        old_jobs = #{oldJobs,jdbcType=VARCHAR},
      </if>
      <if test="oldLvl != null">
        old_lvl = #{oldLvl,jdbcType=VARCHAR},
      </if>
      <if test="newJobs != null">
        new_jobs = #{newJobs,jdbcType=VARCHAR},
      </if>
      <if test="newLvl != null">
        new_lvl = #{newLvl,jdbcType=VARCHAR},
      </if>
      <if test="promotionTime != null">
        promotion_time = #{promotionTime,jdbcType=TIMESTAMP},
      </if>
      <if test="promotionRemarks != null">
        promotion_remarks = #{promotionRemarks,jdbcType=VARCHAR},
      </if>
      <if test="annexUrl != null">
        annex_url = #{annexUrl,jdbcType=VARCHAR},
      </if>
      <if test="annexName != null">
        annex_name = #{annexName,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.PersonnelPromotion">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Sun Apr 26 10:10:12 CST 2020.
    -->
    update personnel_promotion
    set pd_id = #{pdId,jdbcType=INTEGER},
      old_jobs = #{oldJobs,jdbcType=VARCHAR},
      old_lvl = #{oldLvl,jdbcType=VARCHAR},
      new_jobs = #{newJobs,jdbcType=VARCHAR},
      new_lvl = #{newLvl,jdbcType=VARCHAR},
      promotion_time = #{promotionTime,jdbcType=TIMESTAMP},
      promotion_remarks = #{promotionRemarks,jdbcType=VARCHAR},
      annex_url = #{annexUrl,jdbcType=VARCHAR},
      annex_name = #{annexName,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>
   <select id="selectBypdId" parameterType="java.lang.Integer" resultType="com.goafanti.personnel.bo.PersonnelPromotionBo">
    select a.id,a.pd_id pdId, a.old_jobs oldJobs, a.old_lvl oldLvl, a.new_jobs newJobs, a.new_lvl newLvl, a.promotion_time promotionTime,
    date_format(a.promotion_time,'%Y-%m-%d') promotionTimes, a.promotion_remarks promotionRemarks, a.annex_url annexUrl, a.annex_name annexName,
     a.create_time createTime ,b.jobs_name oldJobsName,b.lvl_name oldLvlName,c.jobs_name newJobsName,c.lvl_name newLvlName
     from personnel_promotion a left join  admin_level b  on a.old_jobs=b.jobs and a.old_lvl=b.lvl
     left join admin_level c on a.new_jobs=c.jobs and a.new_lvl=c.lvl
     where a.pd_id = #{id}
  </select>
 
</mapper>