feat(goods): 优化 SKU 查询逻辑,增加删除标记过滤条件在 SkuMapper.xml 的 getList 查询中,新增对 sku 和 product 表的 del_flag = '0' 过滤条件,确保查询结果仅包含未删除的数据。同时调整 SQL 格式以提升可读性。```
This commit is contained in:
huk 2025-09-20 14:09:25 +08:00
parent 4a369920df
commit b5b588eb2c

View File

@ -15,46 +15,42 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<select id="getlist" resultType="com.wzj.soopin.goods.domain.vo.SkuVO">
SELECT
s.id,
s.product_id,
s.out_sku_id,
s.price,
s.pic,
s.sp_data,
s.stock,
s.create_by,
s.create_time,
s.update_by,
s.update_time,
p.name AS productName
SELECT s.id,
s.product_id,
s.out_sku_id,
s.price,
s.pic,
s.sp_data,
s.stock,
s.create_by,
s.create_time,
s.update_by,
s.update_time,
p.name AS productName
FROM
pms_sku s
LEFT JOIN
pms_product p ON s.product_id = p.id
<where>
<if test="query.productName != null and query.productName != ''">
AND p.name LIKE CONCAT('%', #{query.productName}, '%')
</if>
<if test="query.productId != null">
AND p.id = #{query.productId}
</if>
<if test="query.outSkuId != null and query.outSkuId != ''">
AND s.out_sku_id LIKE CONCAT('%', #{query.outSkuId}, '%')
</if>
<if test="query.price != null">
AND s.price = #{query.price}
</if>
<if test="query.pic != null and query.pic != ''">
AND s.pic LIKE CONCAT('%', #{query.pic}, '%')
</if>
<if test="query.tenantId != null and query.tenantId != ''">
AND s.tenant_id = #{query.tenantId}
</if>
</where>
ORDER BY
s.create_time DESC
pms_sku s
LEFT JOIN
pms_product p ON s.product_id = p.id
and s.del_flag = '0' and p.del_flag = '0'
<if test="query.productName != null and query.productName != ''">
AND p.name LIKE CONCAT('%', #{query.productName}, '%')
</if>
<if test="query.productId != null">
AND p.id = #{query.productId}
</if>
<if test="query.outSkuId != null and query.outSkuId != ''">
AND s.out_sku_id LIKE CONCAT('%', #{query.outSkuId}, '%')
</if>
<if test="query.price != null">
AND s.price = #{query.price}
</if>
<if test="query.pic != null and query.pic != ''">
AND s.pic LIKE CONCAT('%', #{query.pic}, '%')
</if>
<if test="query.tenantId != null and query.tenantId != ''">
AND s.tenant_id = #{query.tenantId}
</if>
ORDER BY s.create_time DESC
</select>
@ -68,6 +64,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
pms_product p ON s.product_id = p.id
WHERE
s.id = #{id}
and s.del_flag = '0'
</select>
</mapper>