|
|
|
@ -8,21 +8,29 @@
|
|
|
|
|
*/ |
|
|
|
|
package co.yixiang.modules.evaluation.service.impl; |
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
|
|
import co.yixiang.common.service.impl.BaseServiceImpl; |
|
|
|
|
import co.yixiang.common.utils.QueryHelpPlus; |
|
|
|
|
import co.yixiang.domain.PageResult; |
|
|
|
|
import co.yixiang.dozer.service.IGenerator; |
|
|
|
|
import co.yixiang.enums.ShopCommonEnum; |
|
|
|
|
import co.yixiang.exception.ErrorRequestException; |
|
|
|
|
import co.yixiang.modules.evaluation.domain.YxEvaluation; |
|
|
|
|
import co.yixiang.modules.evaluation.service.YxEvaluationService; |
|
|
|
|
import co.yixiang.modules.evaluation.service.dto.YxEvaluationDto; |
|
|
|
|
import co.yixiang.modules.evaluation.service.dto.YxEvaluationQueryCriteria; |
|
|
|
|
import co.yixiang.modules.evaluation.service.mapper.YxEvaluationMapper; |
|
|
|
|
import co.yixiang.modules.product.domain.YxStoreProduct; |
|
|
|
|
import co.yixiang.modules.product.service.YxStoreProductService; |
|
|
|
|
import co.yixiang.modules.product.service.mapper.StoreProductMapper; |
|
|
|
|
import co.yixiang.modules.product.vo.ProductVo; |
|
|
|
|
import co.yixiang.utils.FileUtil; |
|
|
|
|
import co.yixiang.utils.EvaluationDTO; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.data.domain.Pageable; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
@ -45,12 +53,25 @@ import java.util.Map;
|
|
|
|
|
public class YxEvaluationServiceImpl extends BaseServiceImpl<YxEvaluationMapper, YxEvaluation> implements YxEvaluationService { |
|
|
|
|
|
|
|
|
|
private final IGenerator generator; |
|
|
|
|
private StoreProductMapper storeProductMapper; |
|
|
|
|
private final YxStoreProductService yxStoreProductService; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
//@Cacheable
|
|
|
|
|
public PageResult<YxEvaluationDto> queryAll(YxEvaluationQueryCriteria criteria, Pageable pageable) { |
|
|
|
|
getPage(pageable); |
|
|
|
|
PageInfo<YxEvaluation> page = new PageInfo<>(queryAll(criteria)); |
|
|
|
|
//根据page里面的list的商品id查询对应的商品信息,并将商品id替换为商品信息
|
|
|
|
|
page.getList().forEach(yxEvaluation->{ |
|
|
|
|
LambdaQueryWrapper<YxStoreProduct> wrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
wrapper.eq(YxStoreProduct::getIsShow, ShopCommonEnum.SHOW_1.getValue()) |
|
|
|
|
.eq(YxStoreProduct::getId, yxEvaluation.getProduct()); |
|
|
|
|
YxStoreProduct storeProduct = storeProductMapper.selectOne(wrapper); |
|
|
|
|
if (ObjectUtil.isNull(storeProduct)) { |
|
|
|
|
throw new ErrorRequestException("商品不存在或已下架"); |
|
|
|
|
} |
|
|
|
|
yxEvaluation.setProduct(JSONUtil.toJsonStr(storeProduct)); |
|
|
|
|
}); |
|
|
|
|
return generator.convertPageInfo(page,YxEvaluationDto.class); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -90,7 +111,7 @@ public class YxEvaluationServiceImpl extends BaseServiceImpl<YxEvaluationMapper,
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取评测列表 |
|
|
|
|
* app获取评测列表 |
|
|
|
|
* @return List |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
@ -99,7 +120,10 @@ public class YxEvaluationServiceImpl extends BaseServiceImpl<YxEvaluationMapper,
|
|
|
|
|
wrapper.eq(YxEvaluation::getIsShow, ShopCommonEnum.SHOW_1.getValue()) |
|
|
|
|
.orderByAsc(YxEvaluation::getSort); |
|
|
|
|
List<EvaluationDTO> list = generator.convert(baseMapper.selectList(wrapper),EvaluationDTO.class); |
|
|
|
|
// return TreeUtil.list2TreeConverter(list,0);//没有父类,不需要树形
|
|
|
|
|
list.forEach(evaluationDTO->{ |
|
|
|
|
YxStoreProduct yxStoreProduct = yxStoreProductService.getProductInfo(Long.valueOf(evaluationDTO.getProduct())); |
|
|
|
|
evaluationDTO.setProductInfo(yxStoreProduct); |
|
|
|
|
}); |
|
|
|
|
return list; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|