|
|
|
@ -1,6 +1,9 @@
|
|
|
|
|
package com.bookstore.bookmall.product.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.mysql.cj.util.StringUtils;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
@ -31,4 +34,58 @@ public class SkuInfoServiceImpl extends ServiceImpl<SkuInfoDao, SkuInfoEntity> i
|
|
|
|
|
this.baseMapper.insert(skuInfoEntity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public PageUtils queryPageByCondition(Map<String, Object> params) {
|
|
|
|
|
QueryWrapper<SkuInfoEntity> QueryWrapper = new QueryWrapper<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//key: "华为",
|
|
|
|
|
//brandId: 9,
|
|
|
|
|
//catelogId: 225
|
|
|
|
|
//min
|
|
|
|
|
//max
|
|
|
|
|
String key = (String) params.get("key");
|
|
|
|
|
if (!StringUtils.isNullOrEmpty(key)) {
|
|
|
|
|
QueryWrapper.and((w)->{
|
|
|
|
|
w.eq("sku_id",key).or().like("sku_name", key);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String brandId = (String) params.get("brandId");
|
|
|
|
|
if (!StringUtils.isNullOrEmpty(brandId) && !"0".equals(brandId)) {
|
|
|
|
|
QueryWrapper.eq("brand_id", brandId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String catelogId = (String) params.get("catalogId");
|
|
|
|
|
if (!StringUtils.isNullOrEmpty(catelogId) && !"0".equals(catelogId)) {
|
|
|
|
|
QueryWrapper.eq("catalog_id", catelogId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String min = (String) params.get("min");
|
|
|
|
|
if (!StringUtils.isNullOrEmpty(min)) {
|
|
|
|
|
QueryWrapper.ge("price", min);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String max = (String) params.get("max");
|
|
|
|
|
if (!StringUtils.isNullOrEmpty(max)) {
|
|
|
|
|
try {
|
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(max);
|
|
|
|
|
if (bigDecimal.compareTo(new BigDecimal(0)) == 1) {
|
|
|
|
|
QueryWrapper.le("price", max);
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IPage<SkuInfoEntity> page = this.page(
|
|
|
|
|
new Query<SkuInfoEntity>().getPage(params),
|
|
|
|
|
QueryWrapper
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return new PageUtils(page);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|