<?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.SysReLocationAreaMapper">

    <resultMap type="com.vctgo.system.api.domain.SysReLocationArea" id="SysReLocationAreaResult">
        <result property="id"    column="id"    />
        <result property="locationId"    column="location_id"    />
        <result property="areaId"    column="area_id"    />
        <result property="remark"    column="remark"    />
        <result property="isDeleted"    column="is_deleted"    />
        <result property="createById"    column="create_by_id"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateById"    column="update_by_id"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="tenantId"    column="tenant_id"    />
    </resultMap>

    <sql id="selectSysReLocationAreaVo">
        select id, location_id, area_id, remark, is_deleted, create_by_id, create_by, create_time, update_by_id, update_by, update_time, tenant_id from sys_re_location_area
    </sql>

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

    <select id="selectSysReLocationAreaList"   resultMap="SysReLocationAreaResult">
        <include refid="selectSysReLocationAreaVo"/>
        <where>
            <include refid="defaultDeleteCondition"/>
            <if test="query.locationId != null "> and location_id = #{query.locationId}</if>
            <if test="query.areaId != null "> and area_id = #{query.areaId}</if>
            <if test="query.isDeleted != null  and query.isDeleted != ''"> and is_deleted = #{query.isDeleted}</if>
            <if test="query.createById != null "> and create_by_id = #{query.createById}</if>
            <if test="query.updateById != null "> and update_by_id = #{query.updateById}</if>
            <if test="query.tenantId != null "> and tenant_id = #{query.tenantId}</if>
        </where>
    </select>

    <select id="selectRelInfoListByParams"   resultMap="SysReLocationAreaResult">
        <include refid="selectSysReLocationAreaVo"/>
        <where>
            <include refid="defaultDeleteCondition"/>
            <if test="params.locationId != null  and params.locationId != ''"> and location_id = #{params.locationId}</if>
            <if test="params.areaId != null  and params.areaId != ''"> and area_id = #{params.areaId}</if>
        </where>
    </select>

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