<?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="com.slodon.b2b2c.dao.read.api.GoodsApiMapper">
    <resultMap id="BaseResultMap" type="com.slodon.b2b2c.dto.ProductInfoDto">
        <id column="goods_id" jdbcType="BIGINT" property="productId" />
        <result column="goods_name" jdbcType="VARCHAR" property="productName" />
        <result column="goods_name_cn" jdbcType="VARCHAR" property="productNameCn" />
        <result column="main_image" jdbcType="VARCHAR" property="productImage" />
        <result column="is_self" jdbcType="INTEGER" property="self" />
        <result column="vendor_name" jdbcType="VARCHAR" property="storeName" />
    </resultMap>

    <select id="getGoodsByStoreId" resultMap="BaseResultMap">
        SELECT g.goods_id,g.goods_name,g.goods_name_cn,g.main_image,g.is_self,v.vendor_name
        FROM `goods` g left join vendor v on g.store_id = v.store_id
        where g.store_id = #{storeId} and g.is_delete = 0 and v.is_store_admin = '1'
        order by g.update_time desc
    </select>

</mapper>