<?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.pluss.platform.mapper.MerchantChannelImgMapper">

    <delete id="removeByMerchantCode">
        DELETE ci FROM tb_pluss_merchant_channel_img ci
        LEFT JOIN tb_pluss_merchant_image mi
        ON  ci.srcUrl = mi.picUrl
        WHERE ci.channelType = #{channelType} AND mi.merchantCode LIKE CONCAT(#{merchantCode}, '%')
    </delete>

    <select id="selectListByUserId" resultType="cn.pluss.platform.entity.MerchantImage">
        SELECT mi.id, mi.merchantCode, mi.photoType, ci.channelImgUrl photoUrl, mi.picUrl, mi.createDt, mi.updateDt FROM tb_pluss_merchant_base_info bi
        LEFT JOIN tb_pluss_merchant_image mi ON bi.merchantCode = mi.merchantCode
        LEFT JOIN tb_pluss_merchant_channel_img ci ON mi.picUrl = ci.srcUrl
        WHERE bi.userId = #{userId} AND channelType = #{channelId}
    </select>
</mapper>