<?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="cn.superdesk.uniorder.dao.mapper.marketing.department.UnifiedAreaCityVirtMapperEx">

	<resultMap id="VirtSelectResultMap" type="cn.superdesk.uniorder.dto.vo._function.select.SelectOptionVirt">
		<id column="enterprise_id" property="virtId" jdbcType="BIGINT"/>
		<result column="enterprise_name" property="virtName" jdbcType="VARCHAR"/>
	</resultMap>

	<select id="getVirtAll" resultMap="VirtSelectResultMap">
		SELECT
			enterprise_id,enterprise_name
		FROM
			sys_enterprise
		<where>
		<if test="notinarea != '' and notinarea == 1">
			and enterprise_id not in ( SELECT virt_id from unified_area_city_virt )
		</if>
		<if test="inarea != '' and inarea == 1">
			and enterprise_id in ( SELECT virt_id from unified_area_city_virt where area_city_id = #{areaItemId} )
		</if>
		</where>
	</select>

	<delete id="deleteByAreaCityId" parameterType="java.lang.Long">
		delete
		from
			unified_area_city_virt
		<where>
			and area_city_id = #{areaItemId,jdbcType=BIGINT}
		</where>
	</delete>

</mapper>