<?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.goldenwater.slgc.mapper.DocCateMapper">

    <resultMap type="DocCate" id="DocCateResult">
        <result property="cateId" column="CATE_ID"/>
        <result property="catePid" column="CATE_PID"/>
        <result property="cateName" column="CATE_NAME"/>
        <result property="cateMemo" column="CATE_MEMO"/>
        <result property="bizDept" column="BIZ_DEPT"/>
        <result property="cateSeq" column="CATE_SEQ"/>
    </resultMap>

    <sql id="selectDocCateVo">
        select CATE_ID, CATE_PID, CATE_NAME, CATE_MEMO, BIZ_DEPT, CATE_SEQ
        from BIZ_DOC_CATE
    </sql>

    <select id="selectDocCateList" parameterType="DocCate" resultMap="DocCateResult">
        <include refid="selectDocCateVo"/>
        <where>
            <if test="cateName != null and cateName != ''">
                and CATE_NAME like concat('%', #{cateName}, '%')
            </if>
            <if test="bizDept != null and bizDept != ''">
                and BIZ_DEPT = #{bizDept}
            </if>
        </where>
        order by CATE_SEQ
    </select>

    <select id="selectDocCateById" parameterType="String" resultMap="DocCateResult">
        <include refid="selectDocCateVo"/>
        where CATE_ID = #{cateId}
    </select>

    <select id="findSubList" parameterType="String" resultMap="DocCateResult">
        <include refid="selectDocCateVo"/>
        where CATE_PID = #{catePid}
        order by CATE_SEQ
    </select>

    <delete id="deleteDocCateById" parameterType="String">
        delete from BIZ_DOC_CATE where CATE_ID = #{cateId}
    </delete>

    <insert id="insertDocCate" parameterType="DocCate">
        insert into BIZ_DOC_CATE
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="cateId != null">CATE_ID,</if>
            <if test="catePid != null">CATE_PID,</if>
            <if test="cateName != null">CATE_NAME,</if>
            <if test="cateMemo != null">CATE_MEMO,</if>
            <if test="bizDept != null">BIZ_DEPT,</if>
            <if test="cateSeq != null">CATE_SEQ,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="cateId != null">#{cateId},</if>
            <if test="catePid != null">#{catePid},</if>
            <if test="cateName != null">#{cateName},</if>
            <if test="cateMemo != null">#{cateMemo},</if>
            <if test="bizDept != null">#{bizDept},</if>
            <if test="cateSeq != null">#{cateSeq},</if>
        </trim>
    </insert>

    <update id="updateDocCate" parameterType="DocCate">
        update BIZ_DOC_CATE
        <trim prefix="SET" suffixOverrides=",">
            <if test="catePid != null">CATE_PID = #{catePid},</if>
            <if test="cateName != null">CATE_NAME = #{cateName},</if>
            <if test="cateMemo != null">CATE_MEMO = #{cateMemo},</if>
            <if test="bizDept != null">BIZ_DEPT = #{bizDept},</if>
            <if test="cateSeq != null">CATE_SEQ = #{cateSeq},</if>
        </trim>
        where CATE_ID = #{cateId}
    </update>

</mapper>
