<?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.engine.organization.mapper.hrmresource.HrmRelationMapper">

    <resultMap id="BaseResultMap" type="com.engine.organization.entity.hrmresource.po.HrmRelationPO">
        <result column="id" property="id"/>
        <result column="scheme_id" property="schemeId"/>
        <result column="level_id" property="levelId"/>
        <result column="grade_id" property="gradeId"/>
        <result column="sequence_id" property="sequenceId"/>
        <result column="post_id" property="postId"/>
        <result column="post_info_id" property="postInfoId"/>
        <result column="company_id" property="companyId"/>
        <result column="department_id" property="departmentId"/>
        <result column="job_id" property="jobId"/>
        <result column="creator" property="creator"/>
        <result column="delete_type" property="deleteType"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>

    <!-- 表字段 -->
    <sql id="baseColumns">
        t
        .
        id
        , t.scheme_id
        , t.level_id
        , t.grade_id
        , t.sequence_id
        , t.post_id
        , t.post_info_id
        , t.company_id
        , t.department_id
        , t.job_id
        , t.creator
        , t.delete_type
        , t.create_time
        , t.update_time
    </sql>
    <insert id="insertIgnoreNull" parameterType="com.engine.organization.entity.hrmresource.po.HrmRelationPO"
            keyProperty="id"
            keyColumn="id" useGeneratedKeys="true">
        INSERT INTO jcl_org_hrmrelation
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="creator != null">
                creator,
            </if>
            <if test="deleteType != null">
                delete_type,
            </if>
            <if test="createTime != null">
                create_time,
            </if>
            <if test="updateTime != null">
                update_time,
            </if>
            <if test="id != null ">
                id,
            </if>
            <if test="schemeId != null ">
                scheme_id,
            </if>
            <if test="levelId != null ">
                level_id,
            </if>
            <if test="gradeId != null ">
                grade_id,
            </if>
            <if test="sequenceId != null ">
                sequence_id,
            </if>
            <if test="postId != null ">
                post_id,
            </if>
            <if test="postInfoId != null ">
                post_info_id,
            </if>
            <if test="companyId != null ">
                company_id,
            </if>
            <if test="departmentId != null ">
                department_id,
            </if>
            <if test="jobId != null ">
                job_id,
            </if>
        </trim>
        <trim prefix="VALUES (" suffix=")" suffixOverrides=",">
            <if test="creator != null">
                #{creator},
            </if>
            <if test="deleteType != null">
                #{deleteType},
            </if>
            <if test="createTime != null">
                #{createTime},
            </if>
            <if test="updateTime != null">
                #{updateTime},
            </if>
            <if test="id != null">
                #{id},
            </if>
            <if test="schemeId != null">
                #{schemeId},
            </if>
            <if test="levelId != null">
                #{levelId},
            </if>
            <if test="gradeId != null">
                #{gradeId},
            </if>
            <if test="sequenceId != null">
                #{sequenceId},
            </if>
            <if test="postId != null">
                #{postId},
            </if>
            <if test="postInfoId != null">
                #{postInfoId},
            </if>
            <if test="companyId != null">
                #{companyId},
            </if>
            <if test="departmentId != null">
                #{departmentId},
            </if>
            <if test="jobId != null">
                #{jobId},
            </if>
        </trim>
    </insert>
    <update id="updateHrmRelation" parameterType="com.engine.organization.entity.hrmresource.po.HrmRelationPO">
        update jcl_org_hrmrelation
        <set>
            update_time=#{updateTime},
            scheme_id=#{schemeId},
            level_id=#{levelId},
            grade_id=#{gradeId},
            sequence_id=#{sequenceId},
            post_id=#{postId},
            post_info_id=#{postInfoId},
            company_id=#{companyId},
            department_id=#{departmentId},
            job_id=#{jobId},
        </set>
        WHERE id = #{id} AND delete_type = 0
    </update>

    <select id="getRelationById" resultMap="BaseResultMap">
        select
        <include refid="baseColumns"/>
        from jcl_org_hrmrelation t where delete_type = 0
        AND id =#{id}
    </select>

</mapper>