<?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="io.renren.modules.sys.dao.ScopeCityCompanyDao">

    <resultMap type="io.renren.modules.sys.entity.ScopeCityCompanyEntity" id="scopeCityCompanyMap">
        <result property="id" column="id"/>
        <result property="scopeCityId" column="scope_city_id"/>
        <result property="companyId" column="company_id"/>
        <result property="weight" column="weight"/>
        <result property="avgPrice" column="avg_price"/>
        <result property="assignPersonCount" column="assign_person_count"/>
        <result property="status" column="status"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="deleteTime" column="delete_time"/>
    </resultMap>
    
    
    <select id="selectByAdvertiserIdAndCity" resultMap="scopeCityCompanyMap">
        select scc.* from landing_pages p inner join scope_city sc on p.id=sc.page_id
        inner join scope_city_company scc on sc.id=scope_city_id
        where p.status=1 and sc.status=1 and scc.status=1
        and p.advertiser_id=#{advertiserId} and sc.city=#{city}
    </select>

	<select id="getScopeCityIdByCompanyId" resultType="String">
		select Concat('SCOPE_CITY_LIST_',scope_city_id) from scope_city_company where status=1 and company_id=#{companyId} group by scope_city_id
	</select>

</mapper>