【优化】产品接口

This commit is contained in:
MichaelWin
2026-01-28 11:50:44 +08:00
parent 7d51a13dd7
commit 3ae7b9ac52
7 changed files with 20 additions and 20 deletions

View File

@@ -25,8 +25,12 @@ public class BizProduct extends CommonEntity {
private String hotStatus; private String hotStatus;
private String showType;
private String content; private String content;
private String tag;
private String detailUrl; private String detailUrl;
private BigDecimal amount; private BigDecimal amount;
@@ -42,6 +46,4 @@ public class BizProduct extends CommonEntity {
@TableField(exist = false) @TableField(exist = false)
private String categoryId; private String categoryId;
} }

View File

@@ -8,6 +8,8 @@ import com.corewing.app.common.base.CommonEntity;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.util.List;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Data @Data
@TableName("biz_product_category") @TableName("biz_product_category")
@@ -34,5 +36,4 @@ public class BizProductCategory extends CommonEntity {
@TableField(exist = false) @TableField(exist = false)
Page<BizProduct> productPage; Page<BizProduct> productPage;
} }

View File

@@ -11,5 +11,5 @@ import java.util.List;
@Mapper @Mapper
public interface BizProductCategoryMapper extends BaseMapper<BizProductCategory> { public interface BizProductCategoryMapper extends BaseMapper<BizProductCategory> {
List<BizProductCategory> list(@Param("productCategoryRequest") ProductCategoryRequest productCategoryRequest);
} }

View File

@@ -1,5 +1,7 @@
package com.corewing.app.service.impl; package com.corewing.app.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.corewing.app.dto.website.ProductCategoryRequest; import com.corewing.app.dto.website.ProductCategoryRequest;
@@ -25,13 +27,17 @@ public class BizProductCategroyServiceImpl extends ServiceImpl<BizProductCategor
@Override @Override
public List<BizProductCategory> list(ProductCategoryRequest productCategoryRequest) { public List<BizProductCategory> list(ProductCategoryRequest productCategoryRequest) {
List<BizProductCategory> bizProductCategory = bizProductCategoryMapper.list(productCategoryRequest); LambdaQueryWrapper<BizProductCategory> queryWrapper = new LambdaQueryWrapper<>();
bizProductCategory.forEach(item -> { queryWrapper.like(StrUtil.isNotBlank(productCategoryRequest.getSearchKey()), BizProductCategory::getCategoryTitle, productCategoryRequest.getSearchKey());
ProductPageRequest query = new ProductPageRequest(); List<BizProductCategory> bizProductCategories = bizProductCategoryMapper.selectList(queryWrapper);
query.setCategoryId(item.getId());
Page<BizProduct> page = bizProductService.page(query); bizProductCategories.forEach(item -> {
ProductPageRequest productPageRequest = new ProductPageRequest();
productPageRequest.setCategoryId(item.getId());
Page<BizProduct> page = bizProductService.page(productPageRequest);
item.setProductPage(page); item.setProductPage(page);
}); });
return bizProductCategory;
return bizProductCategories;
} }
} }

View File

@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.corewing.app.common.page.PageContext; import com.corewing.app.common.page.PageContext;
import com.corewing.app.dto.website.ProductPageRequest; import com.corewing.app.dto.website.ProductPageRequest;
import com.corewing.app.entity.AppModel;
import com.corewing.app.entity.BizProduct; import com.corewing.app.entity.BizProduct;
import com.corewing.app.mapper.BizProductMapper; import com.corewing.app.mapper.BizProductMapper;
import com.corewing.app.service.BizProductService; import com.corewing.app.service.BizProductService;

View File

@@ -9,15 +9,6 @@
FROM biz_product_category pc FROM biz_product_category pc
</sql> </sql>
<!-- 分页查询 -->
<select id="list" resultType="com.corewing.app.entity.BizProductCategory">
<include refid="selectVOSql"/>
<where>
<if test="productCategoryRequest.searchKey != null and productCategoryRequest.searchKey != ''">
and pc.category_title like CONCAT('%', #{productCategoryRequest.searchKey}, '%')
</if>
</where>
</select>
</mapper> </mapper>

View File

@@ -21,6 +21,7 @@
<if test="productPageRequest.searchKey != null and productPageRequest.searchKey != ''"> <if test="productPageRequest.searchKey != null and productPageRequest.searchKey != ''">
and p.title like CONCAT('%', #{productPageRequest.searchKey}, '%') and p.title like CONCAT('%', #{productPageRequest.searchKey}, '%')
</if> </if>
and delete_flag = 'NOT_DELETE'
</where> </where>
</select> </select>