From 744594ef1a2f530fc3e86ea9dc48b62247f79420 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 19 五月 2020 17:13:23 +0800 Subject: [PATCH] 饿了么绘图,添加口碑 --- fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopGoodsServiceImpl.java | 31 ++++++++++++++++++++++++++++++- 1 files changed, 30 insertions(+), 1 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopGoodsServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopGoodsServiceImpl.java index ca5fce5..ced65cf 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopGoodsServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopGoodsServiceImpl.java @@ -22,6 +22,7 @@ import com.yeshi.fanli.service.inter.shop.BanLiShopGoodsImgService; import com.yeshi.fanli.service.inter.shop.BanLiShopGoodsService; import com.yeshi.fanli.service.inter.shop.BanLiShopGoodsSetService; +import com.yeshi.fanli.util.FilePathEnum; import com.yeshi.fanli.util.StringUtil; @Service @@ -185,6 +186,31 @@ } } + + @Override + public void switchState(Long id) throws BanLiShopGoodsException { + if (id == null) { + throw new BanLiShopGoodsException(1, "璇蜂紶閫掓纭弬鏁�"); + } + BanLiShopGoods resultObj = banLiShopGoodsMapper.selectByPrimaryKey(id); + if (resultObj == null) { + throw new BanLiShopGoodsException(1, "姝ゅ唴瀹瑰凡涓嶅瓨鍦�"); + } + + Integer state = resultObj.getState(); + if (state == null || state == 0) { + state = 1; + } else { + state = 0; + } + + BanLiShopGoods updateObj = new BanLiShopGoods(); + updateObj.setId(id); + updateObj.setState(state); + banLiShopGoodsMapper.updateByPrimaryKeySelective(updateObj); + } + + /** * 涓婁紶鍥剧墖 @@ -198,7 +224,7 @@ String contentType = file.getContentType(); String type = contentType.substring(contentType.indexOf("/") + 1); // 鏂囦欢璺緞 - String filePath="/img/BanLiShopGoods/"+UUID.randomUUID().toString().replace("-", "") + "." + type; + String filePath=FilePathEnum.banLiShopGoods.getPath() +UUID.randomUUID().toString().replace("-", "") + "." + type; // 鎵ц涓婁紶 String fileLink= COSManager.getInstance().uploadFile(inputStream, filePath).getUrl(); return fileLink; @@ -235,6 +261,9 @@ deleteByPrimaryKey(id); } + + + @Transactional @Override -- Gitblit v1.8.0