Browse Source

修改评测获取方法

zyj
sj 2 years ago
parent
commit
6e7adc20cb
  1. 2
      zsw-bxg/src/main/java/co/yixiang/modules/evaluation/domain/YxEvaluation.java
  2. 2
      zsw-bxg/src/main/java/co/yixiang/modules/evaluation/service/dto/YxEvaluationDto.java
  3. 28
      zsw-bxg/src/main/java/co/yixiang/modules/evaluation/service/impl/YxEvaluationServiceImpl.java
  4. 3
      zsw-bxg/src/main/java/co/yixiang/utils/EvaluationDTO.java

2
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;

2
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;

28
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<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;
}
}

3
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;

Loading…
Cancel
Save