QueryWrapper全部升级LambdaQueryWrapper
This commit is contained in:
@ -6,7 +6,7 @@ import co.yixiang.modules.monitor.domain.Visits;
|
||||
import co.yixiang.modules.monitor.service.VisitsService;
|
||||
import co.yixiang.modules.monitor.service.mapper.VisitsMapper;
|
||||
import co.yixiang.utils.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
|
@ -230,50 +230,49 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMappe
|
||||
@Override
|
||||
public List<YxStoreProductQueryVo> getGoodsList(YxStoreProductQueryParam productQueryParam) {
|
||||
|
||||
QueryWrapper<YxStoreProduct> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().eq(YxStoreProduct::getIsShow, CommonEnum.SHOW_STATUS_1.getValue());
|
||||
LambdaQueryWrapper<YxStoreProduct> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(YxStoreProduct::getIsShow, CommonEnum.SHOW_STATUS_1.getValue());
|
||||
|
||||
//多字段模糊查询分类搜索
|
||||
if (StrUtil.isNotBlank(productQueryParam.getSid()) &&
|
||||
!ShopConstants.YSHOP_ZERO.equals(productQueryParam.getSid())) {
|
||||
wrapper.lambda().eq(YxStoreProduct::getCateId, productQueryParam.getSid());
|
||||
wrapper.eq(YxStoreProduct::getCateId, productQueryParam.getSid());
|
||||
}
|
||||
//关键字搜索
|
||||
if (StrUtil.isNotEmpty(productQueryParam.getKeyword())) {
|
||||
String blurry = "storeName,storeInfo,keyword";
|
||||
String[] blurrys = blurry.split(",");
|
||||
wrapper.and(wrapper1 -> {
|
||||
for (int i=0;i< blurrys.length;i++) {
|
||||
String column = humpToUnderline(blurrys[i]);
|
||||
wrapper1.or();
|
||||
wrapper1.like(column, productQueryParam.getKeyword());
|
||||
}
|
||||
wrapper1.like(YxStoreProduct::getStoreName, productQueryParam.getKeyword());
|
||||
wrapper1.or();
|
||||
wrapper1.like(YxStoreProduct::getStoreInfo, productQueryParam.getKeyword());
|
||||
wrapper1.or();
|
||||
wrapper1.like(YxStoreProduct::getKeyword, productQueryParam.getKeyword());
|
||||
});
|
||||
}
|
||||
//新品搜索
|
||||
if (StrUtil.isNotBlank(productQueryParam.getNews()) &&
|
||||
!ShopConstants.YSHOP_ZERO.equals(productQueryParam.getNews())) {
|
||||
wrapper.lambda().eq(YxStoreProduct::getIsNew, ShopCommonEnum.IS_NEW_1.getValue());
|
||||
wrapper.eq(YxStoreProduct::getIsNew, ShopCommonEnum.IS_NEW_1.getValue());
|
||||
}
|
||||
|
||||
//销量排序
|
||||
if (SortEnum.DESC.getValue().equals(productQueryParam.getSalesOrder())) {
|
||||
wrapper.lambda().orderByDesc(YxStoreProduct::getSales);
|
||||
wrapper.orderByDesc(YxStoreProduct::getSales);
|
||||
} else if (SortEnum.ASC.getValue().equals(productQueryParam.getSalesOrder())) {
|
||||
wrapper.lambda().orderByAsc(YxStoreProduct::getSales);
|
||||
wrapper.orderByAsc(YxStoreProduct::getSales);
|
||||
}
|
||||
|
||||
//价格排序
|
||||
if (SortEnum.DESC.getValue().equals(productQueryParam.getPriceOrder())) {
|
||||
wrapper.lambda().orderByDesc(YxStoreProduct::getPrice);
|
||||
wrapper.orderByDesc(YxStoreProduct::getPrice);
|
||||
} else if (SortEnum.ASC.getValue().equals(productQueryParam.getPriceOrder())) {
|
||||
wrapper.lambda().orderByAsc(YxStoreProduct::getPrice);
|
||||
wrapper.orderByAsc(YxStoreProduct::getPrice);
|
||||
}
|
||||
|
||||
wrapper.lambda().orderByDesc(YxStoreProduct::getSort);
|
||||
wrapper.orderByDesc(YxStoreProduct::getSort);
|
||||
//无其他排序条件时,防止因为商品排序导致商品重复
|
||||
if (StringUtils.isNullOrEmpty(productQueryParam.getPriceOrder()) && StringUtils.isNullOrEmpty(productQueryParam.getSalesOrder())) {
|
||||
wrapper.lambda().orderByDesc(YxStoreProduct::getId);
|
||||
wrapper.orderByDesc(YxStoreProduct::getId);
|
||||
}
|
||||
Page<YxStoreProduct> pageModel = new Page<>(productQueryParam.getPage(),
|
||||
productQueryParam.getLimit());
|
||||
|
@ -268,8 +268,7 @@ public class YxWechatLiveServiceImpl extends BaseServiceImpl<YxWechatLiveMapper,
|
||||
public List<YxWechatLiveDto> getList(int page, int limit, int order) {
|
||||
//todo 添加状态判断
|
||||
LambdaQueryWrapper<YxWechatLive> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper
|
||||
.orderByDesc(YxWechatLive::getStartTime);
|
||||
wrapper.orderByDesc(YxWechatLive::getStartTime);
|
||||
|
||||
|
||||
Page<YxWechatLive> pageModel = new Page<>(page, limit);
|
||||
|
Reference in New Issue
Block a user