<?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.sqx.modules.baseDate.dao.RegionDao">
    <select id="selectRegion" resultType="Map">
     select region_id,parent_id,region_name,status,ischildren,idtree from tb_region where isdelete=0
        <if test ='0 != parentId'>
            and parent_id=#{parentId}
        </if>
        <if test ='0 == parentId'>
            and parent_id=0
        </if>
    </select>

    <!--<insert id="insertRegion" useGeneratedKeys="true" keyColumn="regionId" keyProperty="regionId" parameterType="com.sqx.modules.app.order.entity.Order">
        insert into tb_region
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test ='null != regionName'>
                region_name,
            </if>
            <if test ='null != status'>
                status,
            </if>
            <if test ='null != ischildren'>
                ischildren
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test ='null != regionName'>
                #{regionName},
            </if>
            <if test ='null != status'>
                #{status},
            </if>
            <if test ='null != ischildren'>
                #{ischildren}
            </if>
        </trim>
    </insert>-->

    <update id="updateIschildren">
        update tb_region set ischildren=1 where 1=1
    <if test ='null != id'>
        and region_id=#{id}
    </if>
    </update>

    <update id="updateStatus">
        update tb_region set
            status= #{status}
            where 1=1
        <if test ='null != id'>
            and idtree like #{id}
        </if>
    </update>

    <update id="deleteRegion">
        update tb_region set isdelete =1 where idtree like #{id}
    </update>
</mapper>