<?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.post.PostInfoMapper">
    <resultMap id="BaseResultMap" type="com.engine.organization.entity.postion.po.PostInfoPO">
        <result column="id" property="id"/>
        <result column="post_info_no" property="postInfoNo"/>
        <result column="post_info_name" property="postInfoName"/>
        <result column="post_info_authority" property="postInfoAuthority"/>
        <result column="post_info_duty" property="postInfoDuty"/>
        <result column="post_info_qualification" property="postInfoQualification"/>
        <result column="post_id" property="postId"/>
        <result column="description" property="description"/>
        <result column="forbidden_tag" property="forbiddenTag"/>
        <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.post_info_no
        , t.post_info_name
        , t.post_info_authority
        , t.post_info_duty
        , t.post_info_qualification
        , t.post_id
        , t.description
        , t.forbidden_tag
        , t.creator
        , t.delete_type
        , t.create_time
        , t.update_time
    </sql>
    <select id="getPostInfoByID" parameterType="com.engine.organization.entity.postion.po.PostInfoPO"
            resultMap="BaseResultMap">
        select
        <include refid="baseColumns"/>
        from jcl_org_post_info t where id = #{id} AND delete_type = 0
    </select>

    <select id="listByNo" parameterType="com.engine.organization.entity.postion.po.PostInfoPO"
            resultMap="BaseResultMap">
        select
        <include refid="baseColumns"/>
        from jcl_org_post_info t where post_info_no = #{postInfoNo} AND delete_type = 0
    </select>

    <select id="listPostInfosByIds" resultType="java.util.Map">
        select
        id as "id",
        post_info_name as "name"
        from jcl_org_post_info t
        WHERE delete_type = 0
        AND id IN
        <foreach collection="ids" open="(" item="id" separator="," close=")">
            #{id}
        </foreach>
    </select>
    <select id="getPostInfoByNameAndPostId" resultMap="BaseResultMap">
        select
        <include refid="baseColumns"/>
        from jcl_org_post_info t where post_info_name = #{postInfoName} and post_id = #{postId} AND delete_type = 0
    </select>
    <select id="getPostInfosByIds" resultMap="BaseResultMap">
        select
        <include refid="baseColumns"/>
        from jcl_org_post_info t where delete_type = 0
        AND id IN
        <foreach collection="ids" open="(" item="id" separator="," close=")">
            #{id}
        </foreach>
    </select>
    <select id="listUsedId" resultType="java.lang.String">
        select post_info_id
        from JCL_ORG_JOBEXT_DT1
        where delete_type = 0
    </select>

    <update id="updatePostInfo" parameterType="com.engine.organization.entity.postion.po.PostInfoPO">
        update jcl_org_post_info
        <set>
            creator=#{creator},
            update_time=#{updateTime},
            post_info_no=#{postInfoNo},
            post_info_name=#{postInfoName},
            post_info_authority=#{postInfoAuthority},
            post_info_duty=#{postInfoDuty},
            post_info_qualification=#{postInfoQualification},
            post_id=#{postId},
            description=#{description},
        </set>
        WHERE id = #{id} AND delete_type = 0
    </update>

    <insert id="insertIgnoreNull" parameterType="com.engine.organization.entity.postion.po.PostInfoPO" keyProperty="id"
            keyColumn="id" useGeneratedKeys="true">
        INSERT INTO jcl_org_post_info
        <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="postInfoNo != null">
                post_info_no,
            </if>
            <if test="postInfoName != null">
                post_info_name,
            </if>
            <if test="postInfoAuthority != null">
                post_info_authority,
            </if>
            <if test="postInfoDuty != null">
                post_info_duty,
            </if>
            <if test="postInfoQualification != null">
                post_info_qualification,
            </if>
            <if test="postId != null">
                post_id,
            </if>
            <if test="description != null">
                description,
            </if>
            forbidden_tag,
        </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="postInfoNo != null">
                #{postInfoNo},
            </if>
            <if test="postInfoName != null">
                #{postInfoName},
            </if>
            <if test="postInfoAuthority != null">
                #{postInfoAuthority},
            </if>
            <if test="postInfoDuty != null">
                #{postInfoDuty},
            </if>
            <if test="postInfoQualification != null">
                #{postInfoQualification},
            </if>
            <if test="postId != null">
                #{postId},
            </if>
            <if test="description != null">
                #{description},
            </if>
            0,
        </trim>
    </insert>

    <insert id="insertIgnoreNull" parameterType="com.engine.organization.entity.postion.po.PostInfoPO"
            databaseId="oracle">
        <selectKey keyProperty="id" resultType="long" order="AFTER">
            select JCL_ORG_POST_INFO_ID.currval from dual
        </selectKey>
        INSERT INTO jcl_org_post_info
        <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="postInfoNo != null">
                post_info_no,
            </if>
            <if test="postInfoName != null">
                post_info_name,
            </if>
            <if test="postInfoAuthority != null">
                post_info_authority,
            </if>
            <if test="postInfoDuty != null">
                post_info_duty,
            </if>
            <if test="postInfoQualification != null">
                post_info_qualification,
            </if>
            <if test="postId != null">
                post_id,
            </if>
            <if test="description != null">
                description,
            </if>
            forbidden_tag,
        </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="postInfoNo != null">
                #{postInfoNo},
            </if>
            <if test="postInfoName != null">
                #{postInfoName},
            </if>
            <if test="postInfoAuthority != null">
                #{postInfoAuthority},
            </if>
            <if test="postInfoDuty != null">
                #{postInfoDuty},
            </if>
            <if test="postInfoQualification != null">
                #{postInfoQualification},
            </if>
            <if test="postId != null">
                #{postId},
            </if>
            <if test="description != null">
                #{description},
            </if>
            0,
        </trim>
    </insert>

    <update id="updateForbiddenTagById" parameterType="com.engine.organization.entity.postion.po.PostInfoPO">
        update jcl_org_post_info
        <set>
            forbidden_tag=#{forbiddenTag},
        </set>
        WHERE id = #{id} AND delete_type = 0
    </update>

    <update id="deleteByIds">
        UPDATE jcl_org_post_info
        SET delete_type = 1
        WHERE delete_type = 0
        AND id IN
        <foreach collection="ids" open="(" item="id" separator="," close=")">
            #{id}
        </foreach>
    </update>

</mapper>