<?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.yunfeiyun.agmp.common.web.system.mapper.SysCusareaMapper">
    
    <resultMap type="SysCusarea" id="SysCusareaResult">
        <result property="cusareaId"    column="cusareaId"    />
        <result property="cusareaName"    column="cusareaName"    />
        <result property="cusareaParentid"    column="cusareaParentid"    />
        <result property="cusareaLevel"    column="cusareaLevel"    />
        <result property="cusareaLevelname"    column="cusareaLevelname"    />
        <result property="cusareaSeq"    column="cusareaSeq"    />
        <result property="cusareaCreateddate"    column="cusareaCreateddate"    />
    </resultMap>

    <sql id="selectSysCusareaVo">
        select cusareaId, cusareaName, cusareaParentid, cusareaLevel, cusareaLevelname, cusareaSeq, cusareaCreateddate from SysCusarea
    </sql>

    <select id="selectSysCusareaList" parameterType="SysCusarea" resultMap="SysCusareaResult">
        <include refid="selectSysCusareaVo"/>
        <where>  
            <if test="cusareaName != null  and cusareaName != ''"> and cusareaName like concat('%', #{cusareaName}, '%')</if>
            <if test="cusareaParentid != null  and cusareaParentid != ''"> and cusareaParentid = #{cusareaParentid}</if>
            <if test="cusareaLevel != null  and cusareaLevel != ''"> and cusareaLevel = #{cusareaLevel}</if>
            <if test="cusareaLevelname != null  and cusareaLevelname != ''"> and cusareaLevelname like concat('%', #{cusareaLevelname}, '%')</if>
            <if test="cusareaSeq != null  and cusareaSeq != ''"> and cusareaSeq = #{cusareaSeq}</if>
            <if test="cusareaCreateddate != null  and cusareaCreateddate != ''"> and cusareaCreateddate = #{cusareaCreateddate}</if>
        </where>
    </select>
    
    <select id="selectSysCusareaByCusareaId" parameterType="String" resultMap="SysCusareaResult">
        <include refid="selectSysCusareaVo"/>
        where cusareaId = #{cusareaId}
    </select>
        
    <insert id="insertSysCusarea" parameterType="SysCusarea">
        insert into SysCusarea
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="cusareaId != null">cusareaId,</if>
            <if test="cusareaName != null">cusareaName,</if>
            <if test="cusareaParentid != null">cusareaParentid,</if>
            <if test="cusareaLevel != null">cusareaLevel,</if>
            <if test="cusareaLevelname != null">cusareaLevelname,</if>
            <if test="cusareaSeq != null">cusareaSeq,</if>
            <if test="cusareaCreateddate != null">cusareaCreateddate,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="cusareaId != null">#{cusareaId},</if>
            <if test="cusareaName != null">#{cusareaName},</if>
            <if test="cusareaParentid != null">#{cusareaParentid},</if>
            <if test="cusareaLevel != null">#{cusareaLevel},</if>
            <if test="cusareaLevelname != null">#{cusareaLevelname},</if>
            <if test="cusareaSeq != null">#{cusareaSeq},</if>
            <if test="cusareaCreateddate != null">#{cusareaCreateddate},</if>
         </trim>
    </insert>

    <update id="updateSysCusarea" parameterType="SysCusarea">
        update SysCusarea
        <trim prefix="SET" suffixOverrides=",">
            <if test="cusareaName != null">cusareaName = #{cusareaName},</if>
            <if test="cusareaParentid != null">cusareaParentid = #{cusareaParentid},</if>
            <if test="cusareaLevel != null">cusareaLevel = #{cusareaLevel},</if>
            <if test="cusareaLevelname != null">cusareaLevelname = #{cusareaLevelname},</if>
            <if test="cusareaSeq != null">cusareaSeq = #{cusareaSeq},</if>
            <if test="cusareaCreateddate != null">cusareaCreateddate = #{cusareaCreateddate},</if>
        </trim>
        where cusareaId = #{cusareaId}
    </update>

    <delete id="deleteSysCusareaByCusareaId" parameterType="String">
        delete from SysCusarea where cusareaId = #{cusareaId}
    </delete>

    <delete id="deleteSysCusareaByCusareaIds" parameterType="String">
        delete from SysCusarea where cusareaId in 
        <foreach item="cusareaId" collection="array" open="(" separator="," close=")">
            #{cusareaId}
        </foreach>
    </delete>
</mapper>