admin
2020-05-12 2ec42a5aacea35d2918f0e17f07685cf5b4d25c8
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