<?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.com.countrygarden.bi.main.dao.hmWygl.TbHSPRRegionAvatarInfoMapper">
    <resultMap id="BaseColumn" type="cn.com.countrygarden.bi.main.model.hmWygl.TbHSPRRegionAvatarInfo">
        <result column="OrganCode" property="organCode" jdbcType="VARCHAR"/>
        <result column="CommID" property="commID" jdbcType="VARCHAR"/>
        <result column="ImageOnePath" property="imageOnePath" jdbcType="VARCHAR"/>
        <result column="Names" property="names" jdbcType="VARCHAR"/>
        <result column="CommName" property="commName" jdbcType="VARCHAR"/>
    </resultMap>

    <select id="selectOrganList" resultMap="BaseColumn">
        SELECT OrganCode,ImageOnePath,Names
        FROM Tb_HSPR_RegionAvatarInfo
        WHERE CommID = 0
        <if test="organCodeList != null">
            AND OrganCode IN
            <foreach collection="organCodeList" item="organCode" open="(" separator="," close=")">
                #{organCode}
            </foreach>
        </if>
    </select>

    <select id="selectCommList" resultMap="BaseColumn">
        SELECT DISTINCT
        c.OrganCode,
        c.CommID,
		i. NAMES,
		c.CommName,
		i.ImageOnePath,
        c.CommName
        FROM
                Tb_HSPR_RegionAvatarInfo i
        RIGHT JOIN Tb_HSPR_Community c ON i.CommID = c.CommID AND i.OrganCode = c.OrganCode
        WHERE c.IsDelete = 0
        <if test="organCodeList != null">
            AND c.OrganCode IN
            <foreach collection="organCodeList" item="organCode" open="(" separator="," close=")">
                #{organCode}
            </foreach>
        </if>
        ORDER BY c.OrganCode
    </select>
</mapper>