<?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.codesetting.CodeRuleMapper">

    <select id="getCodeRuleId" resultType="long">
        select t.id
        from JCL_CODERULE t
        where serial_type = #{serialType}
    </select>

    <select id="getCodeRuleByType" resultType="com.engine.organization.entity.codesetting.po.CodeRulePO">
        select *
        from hrm_coderule
        where serialtype = #{serialType}
    </select>


    <update id="updateCodeRule" parameterType="com.engine.organization.entity.codesetting.po.CodeRulePO">
        update JCL_CODERULE
        <set>
            serial_enable = #{serialEnable}
            oneself_type = #{oneselfType}
            creator=#{creator},
            update_time=#{updateTime},
        </set>
        WHERE id = #{codeRuleId} AND delete_type = 0
    </update>


    <insert id="insertCodeRule" parameterType="com.engine.organization.entity.codesetting.po.CodeRulePO" >
        INSERT INTO JCL_CODERULE
        <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="serial_type != null ">
                serial_type,
            </if>
            <if test="serial_enable != null ">
                serial_enable,
            </if>
            <if test="oneself_type != null ">
                oneself_type,
            </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="serialType != null ">
                serialType,
            </if>
            <if test="serialEnable != null ">
                serialEnable,
            </if>
            <if test="oneselfType != null ">
                oneselfType,
            </if>
        </trim>
    </insert>


</mapper>