|
|
@ -3,14 +3,16 @@ package com.wayn.mobile.api.service.impl;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.wayn.common.core.domain.shop.GoodsAttribute;
|
|
|
|
import com.wayn.common.core.domain.shop.GoodsAttribute;
|
|
|
|
import com.wayn.common.core.domain.shop.GoodsProduct;
|
|
|
|
import com.wayn.common.core.domain.shop.GoodsProduct;
|
|
|
|
|
|
|
|
import com.wayn.common.core.domain.shop.vo.GoodsDetailResponseVO;
|
|
|
|
|
|
|
|
import com.wayn.common.core.domain.shop.vo.SpecificationVO;
|
|
|
|
import com.wayn.common.core.service.shop.IGoodsAttributeService;
|
|
|
|
import com.wayn.common.core.service.shop.IGoodsAttributeService;
|
|
|
|
import com.wayn.common.core.service.shop.IGoodsProductService;
|
|
|
|
import com.wayn.common.core.service.shop.IGoodsProductService;
|
|
|
|
import com.wayn.common.core.service.shop.IGoodsService;
|
|
|
|
import com.wayn.common.core.service.shop.IGoodsService;
|
|
|
|
import com.wayn.common.core.service.shop.IGoodsSpecificationService;
|
|
|
|
import com.wayn.common.core.service.shop.IGoodsSpecificationService;
|
|
|
|
import com.wayn.common.util.R;
|
|
|
|
|
|
|
|
import com.wayn.mobile.api.service.IGoodsDetailService;
|
|
|
|
import com.wayn.mobile.api.service.IGoodsDetailService;
|
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
|
@ -31,27 +33,29 @@ public class GoodsDetailServiceImpl implements IGoodsDetailService {
|
|
|
|
private IGoodsAttributeService iGoodsAttributeService;
|
|
|
|
private IGoodsAttributeService iGoodsAttributeService;
|
|
|
|
private ThreadPoolTaskExecutor commonThreadPoolTaskExecutor;
|
|
|
|
private ThreadPoolTaskExecutor commonThreadPoolTaskExecutor;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Cacheable(value = "goods_detail_cache_#600", unless = "#result == null")
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public R getGoodsDetailData(Long goodsId) {
|
|
|
|
public GoodsDetailResponseVO getGoodsDetailData(Long goodsId) {
|
|
|
|
R success = R.success();
|
|
|
|
GoodsDetailResponseVO responseVO = new GoodsDetailResponseVO();
|
|
|
|
Callable<Object> specificationCall = () -> iGoodsSpecificationService.getSpecificationVOList(goodsId);
|
|
|
|
Callable<List<SpecificationVO>> specificationCall = () -> iGoodsSpecificationService.getSpecificationVOList(goodsId);
|
|
|
|
Callable<List<GoodsProduct>> productCall = () -> iGoodsProductService.list(new QueryWrapper<GoodsProduct>().eq("goods_id", goodsId));
|
|
|
|
Callable<List<GoodsProduct>> productCall = () -> iGoodsProductService.list(new QueryWrapper<GoodsProduct>().eq("goods_id", goodsId));
|
|
|
|
Callable<List<GoodsAttribute>> attrCall = () -> iGoodsAttributeService.list(new QueryWrapper<GoodsAttribute>().eq("goods_id", goodsId));
|
|
|
|
Callable<List<GoodsAttribute>> attrCall = () -> iGoodsAttributeService.list(new QueryWrapper<GoodsAttribute>().eq("goods_id", goodsId));
|
|
|
|
|
|
|
|
|
|
|
|
FutureTask<Object> specificationTask = new FutureTask<>(specificationCall);
|
|
|
|
FutureTask<List<SpecificationVO>> specificationTask = new FutureTask<>(specificationCall);
|
|
|
|
FutureTask<List<GoodsProduct>> productTask = new FutureTask<>(productCall);
|
|
|
|
FutureTask<List<GoodsProduct>> productTask = new FutureTask<>(productCall);
|
|
|
|
FutureTask<List<GoodsAttribute>> attrTask = new FutureTask<>(attrCall);
|
|
|
|
FutureTask<List<GoodsAttribute>> attrTask = new FutureTask<>(attrCall);
|
|
|
|
commonThreadPoolTaskExecutor.submit(specificationTask);
|
|
|
|
commonThreadPoolTaskExecutor.submit(specificationTask);
|
|
|
|
commonThreadPoolTaskExecutor.submit(productTask);
|
|
|
|
commonThreadPoolTaskExecutor.submit(productTask);
|
|
|
|
commonThreadPoolTaskExecutor.submit(attrTask);
|
|
|
|
commonThreadPoolTaskExecutor.submit(attrTask);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
success.add("info", iGoodsService.getById(goodsId));
|
|
|
|
responseVO.setInfo(iGoodsService.getById(goodsId));
|
|
|
|
success.add("specificationList", specificationTask.get());
|
|
|
|
responseVO.setProductList(productTask.get());
|
|
|
|
success.add("productList", productTask.get());
|
|
|
|
responseVO.setSpecificationList(specificationTask.get());
|
|
|
|
success.add("attributes", attrTask.get());
|
|
|
|
responseVO.setAttributes(attrTask.get());
|
|
|
|
|
|
|
|
return responseVO;
|
|
|
|
} catch (InterruptedException | ExecutionException e) {
|
|
|
|
} catch (InterruptedException | ExecutionException e) {
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return success;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|