Administrator
2020-02-23 d5dfd55f3dc45948a59cdcfef30e5fbc770f5721
图片尺寸保存
1个文件已修改
53 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java 53 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java
@@ -1,5 +1,6 @@
package com.yeshi.fanli.service.impl.dynamic;
import java.awt.image.BufferedImage;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.ArrayList;
@@ -10,6 +11,7 @@
import java.util.UUID;
import javax.annotation.Resource;
import javax.imageio.ImageIO;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.core.task.TaskExecutor;
@@ -18,8 +20,6 @@
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.yeshi.utils.tencentcloud.COSManager;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.yeshi.fanli.dao.dynamic.GoodsEvaluateDao;
import com.yeshi.fanli.dto.ConfigParamsDTO;
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
@@ -27,7 +27,6 @@
import com.yeshi.fanli.entity.dynamic.CommentInfo;
import com.yeshi.fanli.entity.dynamic.CommentInfo.CommentInfoEnum;
import com.yeshi.fanli.entity.dynamic.GoodsEvaluate;
import com.yeshi.fanli.entity.dynamic.GoodsEvaluate.EvaluateEnum;
import com.yeshi.fanli.entity.dynamic.ImgInfo;
import com.yeshi.fanli.entity.dynamic.ImgInfo.ImgEnum;
import com.yeshi.fanli.entity.dynamic.SimpleGoods;
@@ -209,7 +208,11 @@
                if (StringUtil.isNullOrEmpty(videoUrl)) {
                    throw new GoodsEvaluateException(1, "视频链接不能为空");
                }
                InputStream inputStream = filevideo.getInputStream();
                BufferedImage sourceImg = ImageIO.read(inputStream);
                int width = sourceImg.getWidth();
                int height = sourceImg.getHeight();
                String picLink = uploadPicture(filevideo);
                if (imgVideo != null) {
                    String url = imgVideo.getUrl();
@@ -221,8 +224,6 @@
                } else {
                    imgVideo = new ImgInfo();
                    imgVideo.setId(UUID.randomUUID().toString().replace("-", ""));
                    imgVideo.setW(1);
                    imgVideo.setH(1);
                    imgVideo.setLarge(true);
                    imgVideo.setPid(pid);
                    imgVideo.setUrl(picLink);
@@ -230,6 +231,8 @@
                    imgVideo.setVideoUrl(videoUrl);
                    imgVideo.setType(ImgEnum.video);
                }
                imgVideo.setW(width);
                imgVideo.setH(height);
            }
        }
@@ -301,8 +304,10 @@
                    simpleGoods.setPrice(goodsDetailVO.getCouponPrice());
                    CouponInfoVO couponInfo = goodsDetailVO.getCouponInfo();
                    if (couponInfo == null) {
                        simpleGoods.setPrice(goodsDetailVO.getZkPrice());
                        simpleGoods.setState(1);
                    } else {
                        simpleGoods.setPrice(goodsDetailVO.getCouponPrice());
                        simpleGoods.setAmount(couponInfo.getAmount());
                        simpleGoods.setState(0);
                    }
@@ -404,6 +409,11 @@
                    throw new GoodsEvaluateException(1, "视频链接不能为空");
                }
                InputStream inputStream = filevideo.getInputStream();
                BufferedImage sourceImg = ImageIO.read(inputStream);
                int width = sourceImg.getWidth();
                int height = sourceImg.getHeight();
                String picLink = uploadPicture(filevideo);
                if (imgVideo != null) {
                    String url = imgVideo.getUrl();
@@ -415,8 +425,6 @@
                } else {
                    imgVideo = new ImgInfo();
                    imgVideo.setId(UUID.randomUUID().toString().replace("-", ""));
                    imgVideo.setW(1);
                    imgVideo.setH(1);
                    imgVideo.setLarge(true);
                    imgVideo.setPid(pid);
                    imgVideo.setUrl(picLink);
@@ -424,6 +432,8 @@
                    imgVideo.setVideoUrl(videoUrl);
                    imgVideo.setType(ImgEnum.video);
                }
                imgVideo.setW(width);
                imgVideo.setH(height);
            }
        }
@@ -674,11 +684,18 @@
            }
        }
        int width = 0;
        int height = 0;
        List<ImgInfo> listImg = new ArrayList<ImgInfo>();
        if (fileRequest != null) {
            MultipartFile filevideo = fileRequest.getFile("filevideo");
            if (filevideo != null) {
                removePicture(videoPic);
                InputStream inputStream = filevideo.getInputStream();
                BufferedImage sourceImg = ImageIO.read(inputStream);
                width = sourceImg.getWidth();
                height = sourceImg.getHeight();
                String picLink = uploadPicture(filevideo);
                videoPic = picLink;
            }
@@ -699,14 +716,19 @@
            } else {
                imgVideo = new ImgInfo();
                imgVideo.setId(UUID.randomUUID().toString().replace("-", ""));
                imgVideo.setW(1);
                imgVideo.setH(1);
                imgVideo.setLarge(true);
                imgVideo.setPid(pid);
                imgVideo.setUrl(videoPic);
                imgVideo.setUrlHD(videoPic);
                imgVideo.setVideoUrl(imgInfo.getVideoUrl());
                imgVideo.setType(ImgEnum.video);
            }
            if (width > 0) {
                imgVideo.setW(width);
                imgVideo.setH(height);
            } else {
                imgVideo.setW(imgVideo.getW());
                imgVideo.setH(imgVideo.getH());
            }
            listImg.add(imgVideo);
        }
@@ -773,7 +795,11 @@
                if (StringUtil.isNullOrEmpty(videoUrl)) {
                    throw new GoodsEvaluateException(1, "视频链接不能为空");
                }
                InputStream inputStream = filevideo.getInputStream();
                BufferedImage sourceImg = ImageIO.read(inputStream);
                int width = sourceImg.getWidth();
                int height = sourceImg.getHeight();
                String picLink = uploadPicture(filevideo);
                if (imgVideo != null) {
                    String url = imgVideo.getUrl();
@@ -785,8 +811,6 @@
                } else {
                    imgVideo = new ImgInfo();
                    imgVideo.setId(UUID.randomUUID().toString().replace("-", ""));
                    imgVideo.setW(1);
                    imgVideo.setH(1);
                    imgVideo.setLarge(true);
                    imgVideo.setPid(pid);
                    imgVideo.setUrl(picLink);
@@ -794,6 +818,8 @@
                    imgVideo.setVideoUrl(videoUrl);
                    imgVideo.setType(ImgEnum.video);
                }
                imgVideo.setW(width);
                imgVideo.setH(height);
            }
        }
@@ -1125,3 +1151,4 @@
    }
}