Skip to content

Commit

Permalink
Fix keyword query errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Jzow committed May 27, 2024
1 parent 1e2ffc1 commit 751c34f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,26 @@
</resultMap>

<select id="getProductSkuList" resultMap="productResultMap" parameterType="com.baomidou.mybatisplus.core.metadata.IPage">
SELECT ps.id, p.id AS productId, p.product_category_id, p.product_name, p.product_model, p.product_standard, p.product_color,
sku.product_bar_code, sku.multi_attribute, sku.product_unit, sku.retail_price, sku.sale_price, sku.purchase_price, p.product_manufacturer,pc.category_name,
ps.current_stock_quantity, w.warehouse_name, ps.warehouse_id
SELECT ps.id,
p.id AS productId,
p.product_category_id,
p.product_name,
p.product_model,
p.product_standard,
p.product_color,
sku.product_bar_code,
sku.multi_attribute,
sku.product_unit,
sku.retail_price,
sku.sale_price,
sku.purchase_price,
p.product_manufacturer,
pc.category_name,
ps.current_stock_quantity,
w.warehouse_name,
ps.warehouse_id
FROM product_stock AS ps
LEFT JOIN warehouse as w ON ps.warehouse_id = w.id
LEFT JOIN warehouse AS w ON ps.warehouse_id = w.id
LEFT JOIN product_sku AS sku ON sku.id = ps.product_sku_id
LEFT JOIN product AS p ON sku.product_id = p.id
LEFT JOIN product_category AS pc ON p.product_category_id = pc.id
Expand All @@ -45,6 +60,14 @@
<if test="queryProductStockKeepUnitDTO.enableBatchNumber != null">
AND p.enable_batch_number = #{queryProductStockKeepUnitDTO.enableBatchNumber}
</if>
<if test="queryProductStockKeepUnitDTO.keywords != null">
AND (
p.product_name LIKE CONCAT('%', #{queryProductStockKeepUnitDTO.keywords}, '%')
OR p.product_standard LIKE CONCAT('%', #{queryProductStockKeepUnitDTO.keywords}, '%')
OR p.product_model LIKE CONCAT('%', #{queryProductStockKeepUnitDTO.keywords}, '%')
OR p.product_color LIKE CONCAT('%', #{queryProductStockKeepUnitDTO.keywords}, '%')
)
</if>
</where>
</select>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ public class QueryProductStockKeepUnitDTO {
private Long page;

private Long pageSize;

private String keywords;
}
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,13 @@ public Response<Page<ProductVO>> getProductInfo(QueryProductDTO queryProductDTO)
.like(StringUtils.hasLength(queryProductDTO.getExtendInfo()), Product::getOtherFieldOne, queryProductDTO.getExtendInfo())
.like(StringUtils.hasLength(queryProductDTO.getRemark()), Product::getRemark, queryProductDTO.getRemark())
.like(StringUtils.hasLength(queryProductDTO.getWarehouseShelves()), Product::getWarehouseShelves, queryProductDTO.getWarehouseShelves())
.like(StringUtils.hasLength(queryProductDTO.getKeywords()), Product::getProductName, queryProductDTO.getKeywords())
.or()
.like(StringUtils.hasLength(queryProductDTO.getKeywords()), Product::getProductStandard, queryProductDTO.getKeywords())
.or()
.like(StringUtils.hasLength(queryProductDTO.getKeywords()), Product::getProductModel, queryProductDTO.getKeywords())
.or()
.like(StringUtils.hasLength(queryProductDTO.getKeywords()), Product::getProductColor, queryProductDTO.getKeywords())
.eq(queryProductDTO.getProductCategoryId() != null, Product::getProductCategoryId, queryProductDTO.getProductCategoryId())
.eq(queryProductDTO.getStatus() != null, Product::getStatus, queryProductDTO.getStatus())
.eq(queryProductDTO.getEnableSerialNumber() != null, Product::getEnableSerialNumber, queryProductDTO.getEnableSerialNumber())
Expand Down

0 comments on commit 751c34f

Please sign in to comment.