From 434aac7e177dc414131d87bd1b23ecfce1fc8c55 Mon Sep 17 00:00:00 2001 From: Administrator <Administrator@MS-20170306HGUF> Date: 星期日, 23 二月 2020 16:16:19 +0800 Subject: [PATCH] 素材大图 --- fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java | 57 ++++++++++++++++++++++++++++++++++----------------------- 1 files changed, 34 insertions(+), 23 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java index 572b6e3..18ed939 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java @@ -279,6 +279,11 @@ picNum = 1; } + GoodsDetailVO goodsDetailVO = getGoodsDetailVO(goodsId, goodsType);; + if (goodsDetailVO == null) { + throw new GoodsEvaluateException(1, "璇ュ晢鍝佷俊鎭笉瀛樺湪"); + } + if (listpic != null && listpic.size() > 0) { for (int i = 0; i < listpic.size(); i++) { ImgInfo imgInfo0 = new ImgInfo(); @@ -292,12 +297,6 @@ if (picNum - 1 == i) { imgInfo0.setType(ImgEnum.goods); - // 鍟嗗搧淇℃伅 - GoodsDetailVO goodsDetailVO = getGoodsDetailVO(goodsId, goodsType); - if (goodsDetailVO == null) { - throw new GoodsEvaluateException(1, "璇ュ晢鍝佷俊鎭笉瀛樺湪"); - } - SimpleGoods simpleGoods = new SimpleGoods(); simpleGoods.setGoodsId(goodsId); simpleGoods.setGoodsType(goodsType); @@ -335,6 +334,7 @@ } // 淇濆瓨鍥剧墖淇℃伅 + resultObj.setGoods(goodsDetailVO); resultObj.setMainPicNum(picNum); resultObj.setImgList(listImg); goodsEvaluateDao.save(resultObj); @@ -771,7 +771,8 @@ ImgInfo imgVideo = null; List<String> listDel = new ArrayList<String>(); List<String> listOld = new ArrayList<String>(); - + + List<ImgInfo> listOldImgInfo = new ArrayList<ImgInfo>(); // 澶勭悊鍥剧墖 List<ImgInfo> resultList = resultObj.getImgList(); if (resultList != null && resultList.size() > 0) { @@ -780,6 +781,7 @@ if (type == ImgEnum.video) { imgVideo = info; } else if (type == ImgEnum.img) { + listOldImgInfo.add(info); String url = info.getUrl(); if (!StringUtil.isNullOrEmpty(url)) { listOld.add(url); @@ -850,29 +852,38 @@ if (fileRequest != null) { MultipartFile file = fileRequest.getFile("file" + i); if (file != null) { + InputStream inputStream = file.getInputStream(); + BufferedImage sourceImg = ImageIO.read(inputStream); + int width = sourceImg.getWidth(); + int height = sourceImg.getHeight(); picLink = uploadPicture(file); + + ImgInfo imgInfo0 = new ImgInfo(); + imgInfo0.setId(UUID.randomUUID().toString().replace("-", "")); + imgInfo0.setLarge(false); + imgInfo0.setPid(pid); + imgInfo0.setUrl(listpic.get(i)); + imgInfo0.setUrlHD(listpic.get(i)); + imgInfo0.setType(ImgEnum.img); + imgVideo.setW(width); + imgVideo.setH(height); + listImg.add(imgInfo0); + continue; } } if (picLink.startsWith("http")) { - listpic.add(picLink); + if(listOldImgInfo != null) { + for (ImgInfo imgInfo:listOldImgInfo) { + String url = imgInfo.getUrl(); + if (picLink.equals(url)){ + listImg.add(imgInfo); + break; + } + } + } } } - } - } - - if (listpic != null && listpic.size() > 0) { - for (int i = 0; i < listpic.size(); i++) { - ImgInfo imgInfo0 = new ImgInfo(); - imgInfo0.setId(UUID.randomUUID().toString().replace("-", "")); - imgInfo0.setW(1); - imgInfo0.setH(1); - imgInfo0.setLarge(false); - imgInfo0.setPid(pid); - imgInfo0.setUrl(listpic.get(i)); - imgInfo0.setUrlHD(listpic.get(i)); - imgInfo0.setType(ImgEnum.img); - listImg.add(imgInfo0); } } -- Gitblit v1.8.0