|
|
|
@ -1,11 +1,11 @@
|
|
|
|
|
/** |
|
|
|
|
* Copyright (C) 2018-2020 |
|
|
|
|
* All rights reserved, Designed By www.yixiang.co |
|
|
|
|
* 注意: |
|
|
|
|
* 本软件为www.yixiang.co开发研制,未经购买不得使用 |
|
|
|
|
* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) |
|
|
|
|
* 一经发现盗用、分享等行为,将追究法律责任,后果自负 |
|
|
|
|
*/ |
|
|
|
|
* Copyright (C) 2018-2020 |
|
|
|
|
* All rights reserved, Designed By www.yixiang.co |
|
|
|
|
* 注意: |
|
|
|
|
* 本软件为www.yixiang.co开发研制,未经购买不得使用 |
|
|
|
|
* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) |
|
|
|
|
* 一经发现盗用、分享等行为,将追究法律责任,后果自负 |
|
|
|
|
*/ |
|
|
|
|
package co.yixiang.modules.evaluation.service.impl; |
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
@ -14,10 +14,7 @@ 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.CommonEnum; |
|
|
|
|
import co.yixiang.enums.ShopCommonEnum; |
|
|
|
|
import co.yixiang.exception.ErrorRequestException; |
|
|
|
|
import co.yixiang.modules.entry.domain.YxStoreEntry; |
|
|
|
|
import co.yixiang.modules.evaluation.domain.YxEvaluation; |
|
|
|
|
import co.yixiang.modules.evaluation.service.YxEvaluationRelationService; |
|
|
|
|
import co.yixiang.modules.evaluation.service.YxEvaluationService; |
|
|
|
@ -28,18 +25,14 @@ import co.yixiang.modules.evaluation.vo.YxEvaluationQueryVo;
|
|
|
|
|
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.modules.product.vo.YxStoreProductQueryVo; |
|
|
|
|
import co.yixiang.utils.EntryDTO; |
|
|
|
|
import co.yixiang.utils.FileUtil; |
|
|
|
|
import co.yixiang.utils.EvaluationDTO; |
|
|
|
|
import co.yixiang.utils.FileUtil; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
|
import io.swagger.annotations.ApiImplicitParam; |
|
|
|
|
import io.swagger.annotations.ApiImplicitParams; |
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.data.domain.Pageable; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
@ -48,12 +41,15 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.LinkedHashMap; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @author sj |
|
|
|
|
* @date 2022-10-21 |
|
|
|
|
*/ |
|
|
|
|
* @author sj |
|
|
|
|
* @date 2022-10-21 |
|
|
|
|
*/ |
|
|
|
|
@Service |
|
|
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
|
|
|
|
//@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
|
|
|
@ -76,7 +72,7 @@ public class YxEvaluationServiceImpl extends BaseServiceImpl<YxEvaluationMapper,
|
|
|
|
|
getPage(pageable); |
|
|
|
|
PageInfo<YxEvaluation> page = new PageInfo<>(queryAll(criteria)); |
|
|
|
|
//根据page里面的list的商品id查询对应的商品信息,并将商品id替换为商品信息
|
|
|
|
|
page.getList().forEach(yxEvaluation->{ |
|
|
|
|
page.getList().forEach(yxEvaluation -> { |
|
|
|
|
LambdaQueryWrapper<YxStoreProduct> wrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
wrapper.eq(YxStoreProduct::getIsShow, ShopCommonEnum.SHOW_1.getValue()) |
|
|
|
|
.eq(YxStoreProduct::getId, yxEvaluation.getProduct()); |
|
|
|
@ -84,17 +80,17 @@ public class YxEvaluationServiceImpl extends BaseServiceImpl<YxEvaluationMapper,
|
|
|
|
|
if (ObjectUtil.isNull(storeProduct)) { |
|
|
|
|
// throw new ErrorRequestException("商品不存在或已下架");
|
|
|
|
|
yxEvaluation.setProduct(JSONUtil.toJsonStr(new YxStoreProduct())); |
|
|
|
|
}else { |
|
|
|
|
} else { |
|
|
|
|
yxEvaluation.setProduct(JSONUtil.toJsonStr(storeProduct)); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
return generator.convertPageInfo(page,YxEvaluationDto.class); |
|
|
|
|
return generator.convertPageInfo(page, YxEvaluationDto.class); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
//@Cacheable
|
|
|
|
|
public List<YxEvaluation> queryAll(YxEvaluationQueryCriteria criteria){ |
|
|
|
|
public List<YxEvaluation> queryAll(YxEvaluationQueryCriteria criteria) { |
|
|
|
|
return baseMapper.selectList(QueryHelpPlus.getPredicate(YxEvaluation.class, criteria)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -103,7 +99,7 @@ public class YxEvaluationServiceImpl extends BaseServiceImpl<YxEvaluationMapper,
|
|
|
|
|
public void download(List<YxEvaluationDto> all, HttpServletResponse response) throws IOException { |
|
|
|
|
List<Map<String, Object>> list = new ArrayList<>(); |
|
|
|
|
for (YxEvaluationDto yxEvaluation : all) { |
|
|
|
|
Map<String,Object> map = new LinkedHashMap<>(); |
|
|
|
|
Map<String, Object> map = new LinkedHashMap<>(); |
|
|
|
|
map.put("在列表里面的首页图", yxEvaluation.getHomeImage()); |
|
|
|
|
map.put("评测介绍", yxEvaluation.getSynopsis()); |
|
|
|
|
map.put("评测视频", yxEvaluation.getVideoInput()); |
|
|
|
@ -135,16 +131,16 @@ public class YxEvaluationServiceImpl extends BaseServiceImpl<YxEvaluationMapper,
|
|
|
|
|
LambdaQueryWrapper<YxEvaluation> wrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
wrapper.eq(YxEvaluation::getIsShow, ShopCommonEnum.SHOW_1.getValue()) |
|
|
|
|
.orderByAsc(YxEvaluation::getSort); |
|
|
|
|
List<EvaluationDTO> list = generator.convert(baseMapper.selectList(wrapper),EvaluationDTO.class); |
|
|
|
|
list.forEach(evaluationDTO->{ |
|
|
|
|
List<EvaluationDTO> list = generator.convert(baseMapper.selectList(wrapper), EvaluationDTO.class); |
|
|
|
|
list.forEach(evaluationDTO -> { |
|
|
|
|
LambdaQueryWrapper<YxStoreProduct> wrapper1 = new LambdaQueryWrapper<>(); |
|
|
|
|
wrapper1.eq(YxStoreProduct::getIsShow, ShopCommonEnum.SHOW_1.getValue()) |
|
|
|
|
.eq(YxStoreProduct::getId, evaluationDTO.getProduct()); |
|
|
|
|
YxStoreProduct yxStoreProduct = storeProductMapper.selectOne(wrapper1); |
|
|
|
|
//这里需要有一个非空判断
|
|
|
|
|
if (ObjectUtil.isNotNull(yxStoreProduct)){ |
|
|
|
|
if (ObjectUtil.isNotNull(yxStoreProduct)) { |
|
|
|
|
evaluationDTO.setProductInfo(yxStoreProduct); |
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
evaluationDTO.setProductInfo(new YxStoreProduct().setStoreName("该评测商品已删除或已下架")); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -156,7 +152,7 @@ public class YxEvaluationServiceImpl extends BaseServiceImpl<YxEvaluationMapper,
|
|
|
|
|
* @return List |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public List<YxEvaluationQueryVo> getList(int page,int limit){ |
|
|
|
|
public List<YxEvaluationQueryVo> getList(int page, int limit) { |
|
|
|
|
LambdaQueryWrapper<YxEvaluation> wrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
wrapper.eq(YxEvaluation::getIsShow, ShopCommonEnum.SHOW_1.getValue()) |
|
|
|
|
.orderByAsc(YxEvaluation::getSort); |
|
|
|
@ -173,12 +169,12 @@ public class YxEvaluationServiceImpl extends BaseServiceImpl<YxEvaluationMapper,
|
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
@ApiImplicitParams({ |
|
|
|
|
@ApiImplicitParam(name = "id", value = "词条ID", paramType = "query", dataType = "int",dataTypeClass = Integer.class) |
|
|
|
|
@ApiImplicitParam(name = "id", value = "词条ID", paramType = "query", dataType = "int", dataTypeClass = Integer.class) |
|
|
|
|
}) |
|
|
|
|
public EvaluationDTO getEvaluationById(Long uid,int id) { |
|
|
|
|
EvaluationDTO evaluationDTO=generator.convert(this.baseMapper.selectById(id), EvaluationDTO.class); |
|
|
|
|
public EvaluationDTO getEvaluationById(Long uid, int id) { |
|
|
|
|
EvaluationDTO evaluationDTO = generator.convert(this.baseMapper.selectById(id), EvaluationDTO.class); |
|
|
|
|
// YxStoreProduct yxStoreProduct = yxStoreProductService.getProductInfo(Long.valueOf(evaluationDTO.getProduct()));
|
|
|
|
|
YxStoreProduct yxStoreProduct=yxStoreProductService.getById(evaluationDTO.getProduct()); |
|
|
|
|
YxStoreProduct yxStoreProduct = yxStoreProductService.getById(evaluationDTO.getProduct()); |
|
|
|
|
evaluationDTO.setProductInfo(yxStoreProduct); |
|
|
|
|
//是否收藏
|
|
|
|
|
boolean isCollect = yxEvaluationRelationService.isEvaluationRelation(id, uid); |
|
|
|
|