diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/domain/YxEvaluation.java b/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/domain/YxEvaluation.java index a4b48d9f..0d7d97f9 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/domain/YxEvaluation.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/domain/YxEvaluation.java @@ -7,6 +7,7 @@ * 一经发现盗用、分享等行为,将追究法律责任,后果自负 */ package co.yixiang.modules.evaluation.domain; +import co.yixiang.modules.product.domain.YxStoreProduct; import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; @@ -49,6 +50,7 @@ public class YxEvaluation implements Serializable { @NotNull private String product; + /** 评测总结 */ private String summary; diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/service/dto/YxEvaluationDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/service/dto/YxEvaluationDto.java index 6f820be4..8b7e84e7 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/service/dto/YxEvaluationDto.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/service/dto/YxEvaluationDto.java @@ -8,6 +8,7 @@ */ package co.yixiang.modules.evaluation.service.dto; +import co.yixiang.modules.product.domain.YxStoreProduct; import lombok.Data; import java.sql.Timestamp; import java.io.Serializable; @@ -34,6 +35,7 @@ public class YxEvaluationDto implements Serializable { /** 关联商品信息*/ private String product; + /** 评测总结 */ private String summary; diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/service/impl/YxEvaluationServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/service/impl/YxEvaluationServiceImpl.java index 4d5b4aaa..9e72222a 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/service/impl/YxEvaluationServiceImpl.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/service/impl/YxEvaluationServiceImpl.java @@ -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 implements YxEvaluationService { private final IGenerator generator; + private StoreProductMapper storeProductMapper; + private final YxStoreProductService yxStoreProductService; @Override //@Cacheable public PageResult queryAll(YxEvaluationQueryCriteria criteria, Pageable pageable) { getPage(pageable); PageInfo page = new PageInfo<>(queryAll(criteria)); + //根据page里面的list的商品id查询对应的商品信息,并将商品id替换为商品信息 + page.getList().forEach(yxEvaluation->{ + LambdaQueryWrapper 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 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; } } diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/EvaluationDTO.java b/zsw-bxg/src/main/java/co/yixiang/utils/EvaluationDTO.java index 3a8ca883..a861fcc4 100644 --- a/zsw-bxg/src/main/java/co/yixiang/utils/EvaluationDTO.java +++ b/zsw-bxg/src/main/java/co/yixiang/utils/EvaluationDTO.java @@ -1,5 +1,6 @@ package co.yixiang.utils; +import co.yixiang.modules.product.domain.YxStoreProduct; import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; @@ -93,7 +94,7 @@ public class EvaluationDTO implements Serializable { // /** 是否展示 */ // private Integer isShow; - + private YxStoreProduct productInfo; /** 排序 */ @NotNull private Integer sort;