<?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.vctgo.system.mapper.SysReTenantKindergartenMapper">

    <resultMap type="com.vctgo.system.domain.SysReTenantKindergarten" id="SysReTenantKindergartenResult">
        <result property="id"    column="id"    />
        <result property="tenantId"    column="tenant_id"    />
        <result property="branchId"    column="branch_id"    />
        <result property="gardenId"    column="garden_id"    />
        <result property="isDeleted"    column="is_deleted"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectSysReTenantKindergartenVo">
        select id, tenant_id, branch_id, garden_id, is_deleted, create_by, create_time, update_by, update_time from sys_re_tenant_kindergarten
    </sql>

    <sql id="defaultDeleteCondition">
        is_deleted = 0
    </sql>

    <select id="selectSysReTenantKindergartenList"   resultMap="SysReTenantKindergartenResult">
        <include refid="selectSysReTenantKindergartenVo"/>
        <where>
            <include refid="defaultDeleteCondition"/>
            <if test="query.tenantId != null "> and tenant_id = #{query.tenantId}</if>
            <if test="query.branchId != null "> and branch_id = #{query.branchId}</if>
            <if test="query.gardenId != null "> and garden_id = #{query.gardenId}</if>
            <if test="query.isDeleted != null  and query.isDeleted != ''"> and is_deleted = #{query.isDeleted}</if>
        </where>
    </select>

    <delete id="updateReTenantAccount">
        update sys_re_tenant_kindergarten set branch_id = #{query.branchId},
        update_by = #{query.updateBy}, update_time = #{query.updateTime}
        where tenant_id = #{query.tenantId}
    </delete>

    <delete id="logicalDeleteSysReTenantKindergartenByIds" parameterType="String">
        update sys_re_tenant_kindergarten set is_deleted = #{query.isDeleted},
        update_by = #{query.updateBy},
        update_time = #{query.updateTime} where id in
        <foreach item="id" collection="ids" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

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