From dd5b15229cb15459fa7c31ccea77dac28cbfafbd Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期一, 13 四月 2020 10:04:20 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/div' into div --- fanli/src/main/java/com/yeshi/fanli/service/impl/goods/GoodsClassServiceImpl.java | 26 ++++++++++++++++---------- 1 files changed, 16 insertions(+), 10 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/GoodsClassServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/GoodsClassServiceImpl.java index 3584055..c957007 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/GoodsClassServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/GoodsClassServiceImpl.java @@ -22,12 +22,13 @@ import com.yeshi.fanli.entity.bus.clazz.GoodsClass; import com.yeshi.fanli.entity.bus.clazz.GoodsSubClass; import com.yeshi.fanli.entity.bus.clazz.TaoBaoClass; -import com.yeshi.fanli.exception.GoodsClassException; +import com.yeshi.fanli.exception.goods.GoodsClassException; import com.yeshi.fanli.service.inter.goods.GoodsClassService; import com.yeshi.fanli.service.inter.goods.GoodsSubClassService; import com.yeshi.fanli.service.inter.goods.TaoBaoClassService; import com.yeshi.fanli.service.inter.lable.LabelClassService; import com.yeshi.fanli.util.Constant; +import com.yeshi.fanli.util.FilePathEnum; import com.yeshi.fanli.util.StringUtil; @Service @@ -81,9 +82,9 @@ } @Override - public List<GoodsClass> listquery() throws Exception { + public List<GoodsClass> listquery(Integer sex) throws Exception { - List<GoodsClass> list = goodsClassMapper.getGoodsClassAll(); + List<GoodsClass> list = goodsClassMapper.getGoodsClassAll(sex); if (list != null && list.size() == 0) { return list; @@ -135,18 +136,23 @@ } public List<GoodsClass> getGoodsClassAll() { - return goodsClassMapper.getGoodsClassAll(); + return goodsClassMapper.getGoodsClassAll(null); } @Override - @Transactional + @Transactional(rollbackFor=Exception.class) public void saveObject(MultipartFile file, GoodsClass record) throws GoodsClassException, Exception { String name = record.getName(); if (name == null || name.trim().length() == 0) { throw new GoodsClassException(1, "鍒嗙被鍚嶇О涓嶈兘涓虹┖"); } - + + Integer sex = record.getSex(); + if (sex == null) { + throw new GoodsClassException(1, "鎬у埆璁剧疆涓嶈兘涓虹┖"); + } + // 鍥剧墖涓婁紶 String picture = null; if (file != null) { @@ -236,7 +242,7 @@ String type = contentType.substring(contentType.indexOf("/") + 1); // 鏂囦欢璺緞 - String filePath = "/img/GoodsClass/" + UUID.randomUUID().toString().replace("-", "") + "." + type; + String filePath = FilePathEnum.goodsClass.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type; // 鎵ц涓婁紶 String fileLink = COSManager.getInstance().uploadFile(inputStream, filePath).getUrl(); @@ -263,7 +269,7 @@ String contentType = file.getContentType(); String type = contentType.substring(contentType.indexOf("/") + 1); // 涓婁紶鏂囦欢鐩稿浣嶇疆 - String fileUrl = "ClassImg/" + UUID.randomUUID().toString().replace("-", "") + "." + type; + String fileUrl = FilePathEnum.goodsClassOld.getPath()+ UUID.randomUUID().toString().replace("-", "") + "." + type; boolean deleteFile = true; @@ -309,7 +315,7 @@ @Override @Cacheable(value = "classCache", key = "'getEffectiveClassCache'") - public List<GoodsClass> getEffectiveClassCache() throws Exception { + public List<GoodsClass> getEffectiveClassCache() { return goodsClassMapper.getEffectiveClass(); } @@ -370,7 +376,7 @@ } @Override - @Transactional + @Transactional(rollbackFor=Exception.class) public void updateOrder(Long id, Integer moveType) throws GoodsClassException { if (id == null || moveType == null || (!moveType.equals(1) && !moveType.equals(-1))) { -- Gitblit v1.8.0