feat(phase-5): 后管京东数据库接口与页面+用户端采集入口——v1.4 Phase 5
This commit is contained in:
@@ -50,6 +50,40 @@
|
||||
attr_count = VALUES(attr_count),
|
||||
image_count = VALUES(image_count),
|
||||
collect_batch_id = VALUES(collect_batch_id),
|
||||
synced_at = CURRENT_TIMESTAMP
|
||||
synced_at = CURRENT_TIMESTAMP
|
||||
</insert>
|
||||
|
||||
<!-- 后管只读页(Phase 5,v1.4)过滤面:公司(物化列 eq)、店铺名/商品编码/标题关键词
|
||||
(contains LIKE)、商品状态 eq、分组 eq、同步起止(datetime 闭区间)。
|
||||
全部走 #{} 占位符;offset/limit 必须是服务侧钳制后的值(铁律 15),mapper 不做第二次换算。 -->
|
||||
<sql id="productConds">
|
||||
<if test="companyId != null and companyId > 0">AND p.company_id = #{companyId}</if>
|
||||
<if test="shopName != null and shopName != ''">AND p.shop_name LIKE CONCAT('%', #{shopName}, '%')</if>
|
||||
<if test="productCode != null and productCode != ''">AND p.product_code LIKE CONCAT('%', #{productCode}, '%')</if>
|
||||
<if test="titleKeyword != null and titleKeyword != ''">AND p.title LIKE CONCAT('%', #{titleKeyword}, '%')</if>
|
||||
<if test="saleStatus != null and saleStatus != ''">AND p.sale_status = #{saleStatus}</if>
|
||||
<if test="groupId != null and groupId > 0">AND p.group_id = #{groupId}</if>
|
||||
<if test="syncedFrom != null">AND p.synced_at >= #{syncedFrom}</if>
|
||||
<if test="syncedTo != null">AND p.synced_at <= #{syncedTo}</if>
|
||||
</sql>
|
||||
|
||||
<!-- 只读页总数(与 selectProductPage 同一过滤面)。 -->
|
||||
<select id="countProducts" resultType="long">
|
||||
SELECT COUNT(*)
|
||||
FROM biz_jd_product p
|
||||
WHERE 1=1 <include refid="productConds"/>
|
||||
</select>
|
||||
|
||||
<!-- 只读页分页查询(synced_at 倒序)。
|
||||
group_name 不在此联表:读侧按行集 group_id 批量取分组名补齐(一次查询,无逐行查询)。 -->
|
||||
<select id="selectProductPage" resultType="com.nanri.aiimage.modules.jd.model.entity.JdProductEntity">
|
||||
SELECT p.id, p.company_id, p.user_id, p.task_id, p.shop_id, p.shop_name, p.product_code, p.sku_id,
|
||||
p.title, p.brand, p.brand_id, p.category_path, p.price_min, p.price_max, p.stock_total,
|
||||
p.sale_status, p.list_tab, p.jd_created_at, p.jd_updated_at, p.main_image_url, p.detail_url,
|
||||
p.attr_json, p.attr_count, p.image_count, p.group_id, p.collect_batch_id, p.synced_at
|
||||
FROM biz_jd_product p
|
||||
WHERE 1=1 <include refid="productConds"/>
|
||||
ORDER BY p.synced_at DESC, p.id DESC
|
||||
LIMIT #{offset}, #{limit}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user