<?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.ruoyi.interfaces.mapper.PtTreeCateMapper">

    <resultMap type="com.ruoyi.interfaces.domain.PtTreeCate" id="PtTreeCateResult">
        <result property="treeId"    column="TREE_ID"    />
        <result property="treeType"    column="TREE_TYPE"    />
        <result property="treePid"    column="TREE_PID"    />
        <result property="itemName"    column="ITEM_NAME"    />
        <result property="itemNo"    column="ITEM_NO"    />
        <result property="itemNotes"    column="ITEM_NOTES"    />
        <result property="createby"    column="CREATEBY"    />
        <result property="modifyby"    column="MODIFYBY"    />
    </resultMap>

    <sql id="selectPtTreeCateVo">
        select TREE_ID, TREE_TYPE, TREE_PID, ITEM_NAME, ITEM_NO, ITEM_NOTES, CREATEBY, MODIFYBY from pt_tree_cate
    </sql>

    <select id="selectPtTreeCateList" parameterType="com.ruoyi.interfaces.domain.PtTreeCate" resultMap="PtTreeCateResult">
        <include refid="selectPtTreeCateVo"/>
        <where>
            <if test="treeType != null  and treeType != ''"> and TREE_TYPE = #{treeType}</if>
            <if test="treePid != null  and treePid != ''"> and TREE_PID = #{treePid}</if>
            <if test="itemName != null  and itemName != ''"> and ITEM_NAME like concat('%', #{itemName}, '%')</if>
            <if test="itemNo != null "> and ITEM_NO = #{itemNo}</if>
            <if test="itemNotes != null  and itemNotes != ''"> and ITEM_NOTES = #{itemNotes}</if>
            <if test="createby != null  and createby != ''"> and CREATEBY = #{createby}</if>
            <if test="modifyby != null  and modifyby != ''"> and MODIFYBY = #{modifyby}</if>
        </where>
        order by ITEM_NO
    </select>

    <select id="selectPtTreeCateByTreeId" parameterType="String" resultMap="PtTreeCateResult">
        <include refid="selectPtTreeCateVo"/>
        where TREE_ID = #{treeId}
    </select>

    <insert id="insertPtTreeCate" parameterType="com.ruoyi.interfaces.domain.PtTreeCate">
        insert into pt_tree_cate
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="treeId != null">TREE_ID,</if>
            <if test="treeType != null and treeType != ''">TREE_TYPE,</if>
            <if test="treePid != null">TREE_PID,</if>
            <if test="itemName != null">ITEM_NAME,</if>
            <if test="itemNo != null">ITEM_NO,</if>
            <if test="itemNotes != null">ITEM_NOTES,</if>
            <if test="createby != null">CREATEBY,</if>
            <if test="modifyby != null">MODIFYBY,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="treeId != null">#{treeId},</if>
            <if test="treeType != null and treeType != ''">#{treeType},</if>
            <if test="treePid != null">#{treePid},</if>
            <if test="itemName != null">#{itemName},</if>
            <if test="itemNo != null">#{itemNo},</if>
            <if test="itemNotes != null">#{itemNotes},</if>
            <if test="createby != null">#{createby},</if>
            <if test="modifyby != null">#{modifyby},</if>
        </trim>
    </insert>

    <update id="updatePtTreeCate" parameterType="com.ruoyi.interfaces.domain.PtTreeCate">
        update pt_tree_cate
        <trim prefix="SET" suffixOverrides=",">
            <if test="treeType != null and treeType != ''">TREE_TYPE = #{treeType},</if>
            <if test="treePid != null">TREE_PID = #{treePid},</if>
            <if test="itemName != null">ITEM_NAME = #{itemName},</if>
            <if test="itemNo != null">ITEM_NO = #{itemNo},</if>
            <if test="itemNotes != null">ITEM_NOTES = #{itemNotes},</if>
            <if test="createby != null">CREATEBY = #{createby},</if>
            <if test="modifyby != null">MODIFYBY = #{modifyby},</if>
        </trim>
        where TREE_ID = #{treeId}
    </update>

    <delete id="deletePtTreeCateByTreeId" parameterType="String">
        delete from pt_tree_cate where TREE_ID = #{treeId}
    </delete>

    <delete id="deletePtTreeCateByTreeIds" parameterType="String">
        delete from pt_tree_cate where TREE_ID in
        <foreach item="treeId" collection="array" open="(" separator="," close=")">
            #{treeId}
        </foreach>
    </delete>
</mapper>