...
|
...
|
@@ -15,14 +15,17 @@ import org.springframework.stereotype.Service; |
|
|
import com.google.common.collect.Lists;
|
|
|
import com.yoho.ufo.dal.BrandMapper;
|
|
|
import com.yoho.ufo.dal.SizePoolDetailMapper;
|
|
|
import com.yoho.ufo.dal.SizePoolImageMapper;
|
|
|
import com.yoho.ufo.dal.SizePoolMapper;
|
|
|
import com.yoho.ufo.dal.model.SizePool;
|
|
|
import com.yoho.ufo.dal.model.SizePoolDetail;
|
|
|
import com.yoho.ufo.dal.model.SizePoolImage;
|
|
|
import com.yoho.ufo.exception.PlatformException;
|
|
|
import com.yoho.ufo.model.brand.Brand;
|
|
|
import com.yoho.ufo.service.ISizePoolService;
|
|
|
import com.yoho.ufo.service.model.PageResponseBO;
|
|
|
import com.yoho.ufo.util.DateUtil;
|
|
|
import com.yohobuy.ufo.model.request.size.SizePoolImageBo;
|
|
|
import com.yohobuy.ufo.model.request.size.SizePoolRequest;
|
|
|
import com.yohobuy.ufo.model.request.size.SizePoolResp;
|
|
|
|
...
|
...
|
@@ -54,6 +57,9 @@ public class SizePoolService implements ISizePoolService{ |
|
|
|
|
|
@Autowired
|
|
|
private BrandMapper brandMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private SizePoolImageMapper sizePoolImageMapper;
|
|
|
|
|
|
@Override
|
|
|
public int addSizePool(SizePoolRequest bo) throws PlatformException {
|
...
|
...
|
@@ -68,9 +74,9 @@ public class SizePoolService implements ISizePoolService{ |
|
|
SizePool sizePool = new SizePool();
|
|
|
sizePool.setStatus(STATUS_OPEN);//默认开启
|
|
|
sizePool.setRangeType(bo.getRangeType());
|
|
|
sizePool.setImageUrl(bo.getImageUrl());
|
|
|
sizePool.setImageWidth(bo.getImageWidth());
|
|
|
sizePool.setImageHeight(bo.getImageHeight());
|
|
|
sizePool.setImageUrl(bo.getImageInfoList().get(0).getImageUrl());
|
|
|
sizePool.setImageWidth(bo.getImageInfoList().get(0).getImageWidth());
|
|
|
sizePool.setImageHeight(bo.getImageInfoList().get(0).getImageHeight());
|
|
|
sizePool.setUpdateTime(DateUtil.getCurrentTimeSeconds());
|
|
|
sizePool.setUpdateUid(new UserHelper().getUserId());
|
|
|
|
...
|
...
|
@@ -79,10 +85,26 @@ public class SizePoolService implements ISizePoolService{ |
|
|
return result;
|
|
|
}
|
|
|
|
|
|
saveSizePoolImage(bo.getImageInfoList(), sizePool.getId());
|
|
|
|
|
|
return batchAddSizePoolDetail(sizePool.getId(), bo);
|
|
|
|
|
|
}
|
|
|
|
|
|
private void saveSizePoolImage(List<SizePoolImageBo> imageInfoList, Integer sizePoolId) {
|
|
|
List<SizePoolImage> list = Lists.newArrayList();
|
|
|
for(SizePoolImageBo item : imageInfoList) {
|
|
|
SizePoolImage image = new SizePoolImage();
|
|
|
image.setId(sizePoolId);
|
|
|
image.setImageUrl(item.getImageUrl());
|
|
|
image.setImageWidth(item.getImageWidth());
|
|
|
image.setImageHeight(item.getImageHeight());
|
|
|
list.add(image);
|
|
|
}
|
|
|
|
|
|
sizePoolImageMapper.batchInsert(list);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int updateSizePool(SizePoolRequest bo) throws PlatformException {
|
|
|
Optional<SizePoolRequest> poolOptional = Optional.ofNullable(bo);
|
...
|
...
|
@@ -95,9 +117,9 @@ public class SizePoolService implements ISizePoolService{ |
|
|
|
|
|
SizePool sizePool = new SizePool();
|
|
|
sizePool.setId(bo.getId());
|
|
|
sizePool.setImageUrl(bo.getImageUrl());
|
|
|
sizePool.setImageWidth(bo.getImageWidth());
|
|
|
sizePool.setImageHeight(bo.getImageHeight());
|
|
|
sizePool.setImageUrl(bo.getImageInfoList().get(0).getImageUrl());
|
|
|
sizePool.setImageWidth(bo.getImageInfoList().get(0).getImageWidth());
|
|
|
sizePool.setImageHeight(bo.getImageInfoList().get(0).getImageHeight());
|
|
|
sizePool.setUpdateTime(DateUtil.getCurrentTimeSeconds());
|
|
|
sizePool.setUpdateUid(new UserHelper().getUserId());
|
|
|
|
...
|
...
|
@@ -125,14 +147,28 @@ public class SizePoolService implements ISizePoolService{ |
|
|
}
|
|
|
|
|
|
List<SizePoolDetail> list = sizePoolDetailMapper.queryBySizePoolId(sizePoolId);
|
|
|
List<SizePoolImage> imageList = sizePoolImageMapper.queryBySizePoolId(sizePoolId);
|
|
|
SizePoolResp resp = new SizePoolResp();
|
|
|
resp.setId(sizePoolId);
|
|
|
resp.setRangeType(sizePool.getRangeType());
|
|
|
resp.setImageUrl(sizePool.getImageUrl());
|
|
|
buildImageResp(resp, imageList);
|
|
|
buildResp(resp, list);
|
|
|
return resp;
|
|
|
}
|
|
|
|
|
|
private void buildImageResp(SizePoolResp resp, List<SizePoolImage> imageList) {
|
|
|
List<SizePoolImageBo> list = Lists.newArrayList();
|
|
|
for(SizePoolImage item : imageList) {
|
|
|
SizePoolImageBo image = new SizePoolImageBo();
|
|
|
image.setImageUrl(item.getImageUrl());
|
|
|
image.setImageWidth(item.getImageWidth());
|
|
|
image.setImageHeight(item.getImageHeight());
|
|
|
list.add(image);
|
|
|
}
|
|
|
|
|
|
resp.setImageInfoList(list);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int deleteSizePool(Integer sizePoolId) throws PlatformException{
|
|
|
if(null == sizePoolId){
|
...
|
...
|
@@ -147,6 +183,7 @@ public class SizePoolService implements ISizePoolService{ |
|
|
|
|
|
int result = sizePoolDetailMapper.deleteBySizePoolId(sizePoolId);
|
|
|
if(result > 0) {
|
|
|
sizePoolImageMapper.deleteBySizePoolId(sizePoolId);
|
|
|
return sizePoolMapper.deleteByPrimaryKey(sizePoolId);
|
|
|
}else {
|
|
|
return 0;
|
...
|
...
|
@@ -166,6 +203,8 @@ public class SizePoolService implements ISizePoolService{ |
|
|
List<Integer> poolIdList = list.stream().map(SizePool::getId).collect(Collectors.toList());
|
|
|
List<SizePoolDetail> detailList = sizePoolDetailMapper.queryBySizePoolIds(poolIdList);
|
|
|
Map<Integer, List<SizePoolDetail>> poolIdMap = detailList.stream().collect(Collectors.groupingBy(SizePoolDetail::getSizePoolId));
|
|
|
List<SizePoolImage> imageList = sizePoolImageMapper.queryBySizePoolIds(poolIdList);
|
|
|
Map<Integer, List<SizePoolImage>> poolIdImageMap = imageList.stream().collect(Collectors.groupingBy(SizePoolImage::getSizePoolId));
|
|
|
List<SizePoolResp> respList = Lists.newArrayList();
|
|
|
for(SizePool pool : list) {
|
|
|
SizePoolResp resp = new SizePoolResp();
|
...
|
...
|
@@ -173,7 +212,7 @@ public class SizePoolService implements ISizePoolService{ |
|
|
resp.setStatus(pool.getStatus());
|
|
|
resp.setStatusStr(getStatusStr(pool.getStatus()));
|
|
|
resp.setRangeTypeStr(getRangeTypeStr(pool.getRangeType()));
|
|
|
resp.setImageUrl(pool.getImageUrl());
|
|
|
buildImageResp(resp, poolIdImageMap.get(pool.getId()));
|
|
|
List<SizePoolDetail> itemList = poolIdMap.get(pool.getId());
|
|
|
if(CollectionUtils.isNotEmpty(itemList)) {
|
|
|
if(pool.getRangeType().equals(RANGE_TYPE_BRAND)) {
|
...
|
...
|
|