Authored by mali

图片采用相对路径存储

@@ -5,6 +5,8 @@ import com.yoho.core.common.utils.DateUtil; @@ -5,6 +5,8 @@ import com.yoho.core.common.utils.DateUtil;
5 import com.yoho.ufo.dal.BrandMapper; 5 import com.yoho.ufo.dal.BrandMapper;
6 import com.yoho.ufo.model.brand.Brand; 6 import com.yoho.ufo.model.brand.Brand;
7 import com.yoho.ufo.service.IBrandService; 7 import com.yoho.ufo.service.IBrandService;
  8 +import com.yoho.ufo.util.ImagesConstant;
  9 +import com.yoho.ufo.util.ImagesHelper;
8 import com.yoho.ufo.util.OrikaUtils; 10 import com.yoho.ufo.util.OrikaUtils;
9 import com.yohobuy.ufo.model.common.PageModel; 11 import com.yohobuy.ufo.model.common.PageModel;
10 import com.yohobuy.ufo.model.common.PageResponseBO; 12 import com.yohobuy.ufo.model.common.PageResponseBO;
@@ -36,6 +38,7 @@ public class BrandServiceImpl implements IBrandService { @@ -36,6 +38,7 @@ public class BrandServiceImpl implements IBrandService {
36 Brand brand = OrikaUtils.map(brandRequestBo, Brand.class); 38 Brand brand = OrikaUtils.map(brandRequestBo, Brand.class);
37 brand.setEditTime(DateUtil.currentTimeSeconds()); 39 brand.setEditTime(DateUtil.currentTimeSeconds());
38 brand.setEditPid(getUserId()); 40 brand.setEditPid(getUserId());
  41 + brand.setBrandLogo(ImagesHelper.getImageRelativeUrl(brand.getBrandLogo(), ImagesConstant.BUCKET_BRAND_LOGO));
39 if (brand.getId() == null || brand.getId() == 0) { 42 if (brand.getId() == null || brand.getId() == 0) {
40 // 默认开启状态 43 // 默认开启状态
41 brand.setStatus(1); 44 brand.setStatus(1);
@@ -64,6 +67,7 @@ public class BrandServiceImpl implements IBrandService { @@ -64,6 +67,7 @@ public class BrandServiceImpl implements IBrandService {
64 for (Brand brand1 : brands) { 67 for (Brand brand1 : brands) {
65 responseBo = OrikaUtils.map(brand1, BrandResponseBo.class); 68 responseBo = OrikaUtils.map(brand1, BrandResponseBo.class);
66 responseBo.setCreateTime(DateUtil.getDateStrBySecond(brand1.getCreateTime(), DateUtil.DATE_TIME_FORMAT)); 69 responseBo.setCreateTime(DateUtil.getDateStrBySecond(brand1.getCreateTime(), DateUtil.DATE_TIME_FORMAT));
  70 + responseBo.setBrandLogo(ImagesHelper.getImageAbsoluteUrl(brand1.getBrandLogo(), ImagesConstant.BUCKET_BRAND_LOGO));
67 brandResponseBos.add(responseBo); 71 brandResponseBos.add(responseBo);
68 } 72 }
69 return new PageResponseBO<>(count, brandResponseBos, pageModel.getCurrentPage(), pageModel.getPageSize()); 73 return new PageResponseBO<>(count, brandResponseBos, pageModel.getCurrentPage(), pageModel.getPageSize());
@@ -76,6 +80,7 @@ public class BrandServiceImpl implements IBrandService { @@ -76,6 +80,7 @@ public class BrandServiceImpl implements IBrandService {
76 Brand brand = brandMapper.selectOneById(id); 80 Brand brand = brandMapper.selectOneById(id);
77 BrandResponseBo brandResponseBo = OrikaUtils.map(brand, BrandResponseBo.class); 81 BrandResponseBo brandResponseBo = OrikaUtils.map(brand, BrandResponseBo.class);
78 brandResponseBo.setCreateTime(DateUtil.getDateStrBySecond(brand.getCreateTime(), DateUtil.DATE_TIME_FORMAT)); 82 brandResponseBo.setCreateTime(DateUtil.getDateStrBySecond(brand.getCreateTime(), DateUtil.DATE_TIME_FORMAT));
  83 + brandResponseBo.setBrandLogo(ImagesHelper.getImageAbsoluteUrl(brand.getBrandLogo(), ImagesConstant.BUCKET_BRAND_LOGO));
79 return brandResponseBo; 84 return brandResponseBo;
80 } 85 }
81 86
@@ -12,6 +12,8 @@ import com.alibaba.fastjson.JSONObject; @@ -12,6 +12,8 @@ import com.alibaba.fastjson.JSONObject;
12 import com.yoho.core.dal.datasource.annotation.Database; 12 import com.yoho.core.dal.datasource.annotation.Database;
13 import com.yoho.core.rest.client.ServiceCaller; 13 import com.yoho.core.rest.client.ServiceCaller;
14 import com.yoho.ufo.event.model.StorageNumEvent; 14 import com.yoho.ufo.event.model.StorageNumEvent;
  15 +import com.yoho.ufo.util.ImagesConstant;
  16 +import com.yoho.ufo.util.ImagesHelper;
15 import com.yohobuy.ufo.model.enums.InboxBusinessTypeEnum; 17 import com.yohobuy.ufo.model.enums.InboxBusinessTypeEnum;
16 import org.apache.commons.collections.CollectionUtils; 18 import org.apache.commons.collections.CollectionUtils;
17 import org.apache.commons.lang3.StringUtils; 19 import org.apache.commons.lang3.StringUtils;
@@ -140,7 +142,7 @@ public class ProductServiceImpl implements IProductService, ApplicationContextAw @@ -140,7 +142,7 @@ public class ProductServiceImpl implements IProductService, ApplicationContextAw
140 } else { 142 } else {
141 gi.setIsDefault("N"); 143 gi.setIsDefault("N");
142 } 144 }
143 - gi.setImageUrl(image); 145 + gi.setImageUrl(ImagesHelper.getImageRelativeUrl(image, ImagesConstant.BUCKET_GOODS_IMG));
144 gi.setOrderBy(i + 1); 146 gi.setOrderBy(i + 1);
145 goodsImagesList.add(gi); 147 goodsImagesList.add(gi);
146 } 148 }
@@ -167,7 +169,7 @@ public class ProductServiceImpl implements IProductService, ApplicationContextAw @@ -167,7 +169,7 @@ public class ProductServiceImpl implements IProductService, ApplicationContextAw
167 g.setId(bo.getGoodsId()); 169 g.setId(bo.getGoodsId());
168 g.setIsDefault("Y"); 170 g.setIsDefault("Y");
169 if (CollectionUtils.isNotEmpty(bo.getImageUrlList())) { 171 if (CollectionUtils.isNotEmpty(bo.getImageUrlList())) {
170 - g.setColorImage(bo.getImageUrlList().get(0)); 172 + g.setColorImage(ImagesHelper.getImageRelativeUrl(bo.getImageUrlList().get(0), ImagesConstant.BUCKET_GOODS_IMG));
171 } 173 }
172 return g; 174 return g;
173 } 175 }
@@ -281,7 +283,7 @@ public class ProductServiceImpl implements IProductService, ApplicationContextAw @@ -281,7 +283,7 @@ public class ProductServiceImpl implements IProductService, ApplicationContextAw
281 bo.setColorId(goods.getColorId()); 283 bo.setColorId(goods.getColorId());
282 } 284 }
283 if (CollectionUtils.isNotEmpty(goodsImages)) { 285 if (CollectionUtils.isNotEmpty(goodsImages)) {
284 - bo.setImageUrlList(CollectionUtil.map(goodsImages, GoodsImages::getImageUrl)); 286 + bo.setImageUrlList(CollectionUtil.map(goodsImages, item -> ImagesHelper.getImageAbsoluteUrl(item.getImageUrl(), ImagesConstant.BUCKET_GOODS_IMG)));
285 } 287 }
286 if (CollectionUtils.isNotEmpty(storages)) { 288 if (CollectionUtils.isNotEmpty(storages)) {
287 bo.setStorageIdList(CollectionUtil.map(storages, Storage::getId)); 289 bo.setStorageIdList(CollectionUtil.map(storages, Storage::getId));
@@ -333,7 +335,7 @@ public static void main(String[] args) { @@ -333,7 +335,7 @@ public static void main(String[] args) {
333 // 图片 335 // 图片
334 Goods goods = goodsMap.get(respBo.getId()); 336 Goods goods = goodsMap.get(respBo.getId());
335 if (goods != null) { 337 if (goods != null) {
336 - respBo.setColorImage(goods.getColorImage()); 338 + respBo.setColorImage(ImagesHelper.getImageAbsoluteUrl(goods.getColorImage(), ImagesConstant.BUCKET_GOODS_IMG));
337 } 339 }
338 // 分类 340 // 分类
339 ProductSort maxSort = productSortMap.get(respBo.getMaxSortId()); 341 ProductSort maxSort = productSortMap.get(respBo.getMaxSortId());
@@ -67,7 +67,7 @@ @@ -67,7 +67,7 @@
67 realInputName: "brandLogo", 67 realInputName: "brandLogo",
68 url: contextPath + '/fileupload/upload', 68 url: contextPath + '/fileupload/upload',
69 queryParams: { 69 queryParams: {
70 - bucket: "goodsimg" 70 + bucket: "brandLogo"
71 }, 71 },
72 onBeforeSubmit: function () { 72 onBeforeSubmit: function () {
73 $.messager.progress({ 73 $.messager.progress({