<?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="shop.alien.mapper.StoreQualificationMapper">

    <!-- 根据门店id和图片类型查询图片列表 -->
    <select id="selectStoreImgsByType" resultType="shop.alien.entity.store.StoreImg">
        SELECT
            id,
            store_id AS storeId,
            img_type AS imgType,
            img_description AS imgDescription,
            img_sort AS imgSort,
            img_url AS imgUrl,
            is_extract AS isExtract,
            color_code AS colorCode,
            delete_flag AS deleteFlag,
            created_time AS createdTime,
            created_user_id AS createdUserId,
            updated_time AS updatedTime,
            updated_user_id AS updatedUserId,
            business_id AS businessId
        FROM
            store_img
        WHERE
            store_id = #{storeId}
            AND img_type = #{imgType}
            AND delete_flag = 0
        ORDER BY
            img_sort ASC,
            created_time DESC
    </select>

    <!-- 根据门店id和多个图片类型查询图片列表 -->
    <select id="selectStoreImgsByTypes" resultType="shop.alien.entity.store.StoreImg">
        SELECT
            id,
            store_id AS storeId,
            img_type AS imgType,
            img_description AS imgDescription,
            img_sort AS imgSort,
            img_url AS imgUrl,
            is_extract AS isExtract,
            color_code AS colorCode,
            delete_flag AS deleteFlag,
            created_time AS createdTime,
            created_user_id AS createdUserId,
            updated_time AS updatedTime,
            updated_user_id AS updatedUserId,
            business_id AS businessId
        FROM
            store_img
        WHERE
            store_id = #{storeId}
            AND img_type IN
            <foreach collection="imgTypes" item="imgType" open="(" separator="," close=")">
                #{imgType}
            </foreach>
            AND delete_flag = 0
        ORDER BY
            img_type ASC,
            img_sort ASC,
            created_time DESC
    </select>

</mapper>
