<?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.job.JobDTMapper">
    <resultMap id="BaseResultMap" type="com.engine.organization.entity.job.po.JobDTPO">
        <result column="id" property="id"/>
        <result column="mainid" property="mainId"/>
        <result column="level_id" property="levelId"/>
        <result column="grade_id" property="gradeId"/>
        <result column="level_id_span" property="levelIdspan"/>
        <result column="grade_id_span" property="gradeIdspan"/>
        <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.mainid,
        t.level_id,
        t.grade_id,
        t.level_id_span,
        t.grade_id_span
    </sql>
    <insert id="insertIgnoreNull">
        INSERT INTO jcl_org_jobdt
        <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="mainId != null ">
                mainid,
            </if>
            <if test="levelId != null ">
                level_id,
            </if>
            <if test="gradeId != null ">
                grade_id,
            </if>
            <if test="levelIdspan != null ">
                level_id_span,
            </if>
            <if test="gradeIdspan != null ">
                grade_id_span,
            </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="mainId != null ">
                #{mainId},
            </if>
            <if test="levelId != null ">
                #{levelId},
            </if>
            <if test="gradeId != null ">
                #{gradeId},
            </if>
            <if test="levelIdspan != null ">
                #{levelIdspan},
            </if>
            <if test="gradeIdspan != null ">
                #{gradeIdspan},
            </if>
        </trim>
    </insert>

    <delete id="deleteByIds">
        delete
        from jcl_org_jobdt
        where mainid = #{mainId}
    </delete>


    <select id="listJobDTByMainID" resultMap="BaseResultMap">
        select
        <include refid="baseColumns"/>
        from jcl_org_jobdt t
        WHERE delete_type = 0
        AND mainid = #{mainId}
    </select>


</mapper>