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

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.pluss.platform.entity.ImgReflect">
        <id column="id" property="id" />
        <result column="localUrl" property="localUrl" />
        <result column="ossUrl" property="ossUrl" />
        <result column="createTime" property="createTime" />
        <result column="updateTime" property="updateTime" />
    </resultMap>

    <select id="selectIdCardUrl" resultType="java.util.Map">
        SELECT ic.id, ic.imgPositive, ic.imgNegative, ir.ossUrl imgPositiveOSS, ir2.ossUrl imgNegativeOSS
        FROM tb_pluss_id_card ic
        LEFT JOIN tb_pluss_img_reflect ir ON ir.localUrl = ic.imgPositive
        LEFT JOIN tb_pluss_img_reflect ir2 ON ir2.localUrl = ic.imgNegative
        WHERE NOT ((
            INSTR(imgPositive, "C:/") > 0
            AND imgPositive IS NOT NULL
        ) OR (
            INSTR(imgNegative, "C:/") > 0
            AND imgNegative IS NOT NULL
        ))
        AND NOT (INSTR(imgPositive, "https://syb-resource") > 0 AND INSTR(imgNegative, "https://syb-resource") > 0)
        AND (ir.ossUrl IS NULL OR ir2.ossUrl IS NULL)
    </select>

    <select id="selectBankCardUrl" resultType="java.util.Map">
        SELECT
            bc.id,
            bc.imgUrl,
            ir.ossUrl imgUrlOSS
        FROM
            tb_pluss_bank_card bc
            LEFT JOIN tb_pluss_img_reflect ir ON ir.localUrl = bc.imgUrl
        WHERE
            NOT (
                INSTR( bc.imgUrl, "C:/" ) > 0
                AND bc.imgUrl IS NOT NULL
            ) AND (
                INSTR( bc.imgUrl, "https://syb-resource" ) = 0
                AND bc.imgUrl IS NOT NULL
                AND bc.imgUrl != ''
            ) AND ir.ossUrl IS NULL
        UNION
        SELECT
            bc.id,
            bc.licenseUrl imgUrl,
            ir.ossUrl imgUrlOSS
        FROM
            tb_pluss_bank_card bc
            LEFT JOIN tb_pluss_img_reflect ir ON ir.localUrl = bc.licenseUrl
        WHERE
            NOT (
                INSTR( bc.licenseUrl, "C:/" ) > 0
                AND bc.licenseUrl IS NOT NULL
            )
            AND (
                INSTR( bc.licenseUrl, "https://syb-resource" ) = 0
                AND bc.licenseUrl IS NOT NULL
                AND bc.licenseUrl != ''
            ) AND ir.ossUrl IS NULL
    </select>

    <select id="selectStoreImgUrl" resultType="java.util.Map">
        SELECT
            mi.id,
            mi.picUrl imgUrl,
            ir.ossUrl imgUrlOSS
        FROM
            tb_pluss_merchant_image mi
            LEFT JOIN tb_pluss_img_reflect ir ON ir.localUrl = mi.picUrl
        WHERE
            NOT (
                INSTR( mi.picUrl, "C:/" ) > 0
                AND mi.picUrl IS NOT NULL
            ) AND (
                INSTR( mi.picUrl, "https://syb-resource" ) = 0
                AND mi.picUrl IS NOT NULL
                AND mi.picUrl != ''
            ) AND ir.ossUrl IS NULL
    </select>

    <select id="selectUserLogo" resultType="java.util.Map">
        SELECT
            ua.id,
            ua.logo imgUrl,
            ir.ossUrl imgUrlOSS
        FROM
            tb_pluss_user_app ua
            LEFT JOIN tb_pluss_img_reflect ir ON ir.localUrl = ua.logo
        WHERE
            NOT (
                INSTR( ua.logo, "C:/" ) > 0
                AND ua.logo IS NOT NULL
            ) AND (
                INSTR( ua.logo, "https://syb-resource" ) = 0
                AND ua.logo IS NOT NULL
                AND ua.logo != ''
            ) AND ir.ossUrl IS NULL
    </select>
</mapper>
