From 7e7db2fa55a9a3af46d4fd8ede0dee147f101d64 Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期六, 09 五月 2020 21:41:27 +0800
Subject: [PATCH] 2.1需求

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/help/HelpClassServiceImpl.java |   37 ++++++++++++++++++++++++++++++-------
 1 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/help/HelpClassServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/help/HelpClassServiceImpl.java
index df529b8..24dafdd 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/help/HelpClassServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/help/HelpClassServiceImpl.java
@@ -21,14 +21,11 @@
 import com.yeshi.fanli.entity.AppVersionInfo;
 import com.yeshi.fanli.entity.bus.help.HelpClass;
 import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl;
-import com.yeshi.fanli.entity.bus.homemodule.FloatAD;
-import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture;
 import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl.AdActivityType;
-import com.yeshi.fanli.exception.banner.SwiperPictureException;
 import com.yeshi.fanli.exception.config.HelpClassException;
-import com.yeshi.fanli.exception.homemodule.FloatADException;
 import com.yeshi.fanli.service.inter.help.HelpClassService;
 import com.yeshi.fanli.service.inter.homemodule.AdActivityVersionControlService;
+import com.yeshi.fanli.util.FilePathEnum;
 import com.yeshi.fanli.util.StringUtil;
 
 @Service
@@ -82,7 +79,7 @@
 			InputStream inputStream = file.getInputStream();
 			String contentType = file.getContentType();
 			String type = contentType.substring(contentType.indexOf("/") + 1);
-			String filePath ="/img/HelpClass/" + UUID.randomUUID().toString().replace("-", "") + "." + type;
+			String filePath =FilePathEnum.helpClass.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type;
 			picture = COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
 		}
 				
@@ -94,13 +91,14 @@
 		if (record.getId() == null) {
 			int maxOrder = helpClassMapper.getMaxOrder();
 			record.setSort(maxOrder + 1);
+			record.setPicture(picture);
 			record.setCreateTime(new Date());
 			helpClassMapper.insertSelective(record);
 		} else {
 			// 淇敼
 			HelpClass resultObj = helpClassMapper.selectByPrimaryKey(record.getId());
 			if (resultObj == null)
-				throw new FloatADException(1, "淇敼鍐呭宸蹭笉瀛樺湪");
+				throw new HelpClassException(1, "淇敼鍐呭宸蹭笉瀛樺湪");
 			
 			if (picture != null && picture.trim().length() > 0) {
 				String pictureOld = resultObj.getPicture();
@@ -117,6 +115,31 @@
 			record.setCreateTime(resultObj.getCreateTime());
 			helpClassMapper.updateByPrimaryKey(record);
 		}
+	}
+	
+	
+	@Override
+	public void switchState(Long id) throws HelpClassException {
+		if (id == null) {
+			throw new HelpClassException(1, "璇蜂紶閫掓纭弬鏁�");
+		}
+		
+		HelpClass resultObj = helpClassMapper.selectByPrimaryKey(id);
+		if (resultObj == null) {
+			throw new HelpClassException(1, "姝ゅ唴瀹瑰凡涓嶅瓨鍦�");
+		}
+		
+		Integer state = resultObj.getShowState();
+		if (state == null || state == 0) {
+			state = 1;
+		} else {
+			state = 0;
+		}
+		
+		HelpClass updateObj = new HelpClass();
+		updateObj.setId(id);
+		updateObj.setShowState(state);
+		helpClassMapper.updateByPrimaryKeySelective(updateObj);
 	}
 	
 	
@@ -194,7 +217,7 @@
 		String contentType = file.getContentType();
 		String type = contentType.substring(contentType.indexOf("/") + 1);
 		
-		String filePath ="/img/HelpClass/" + UUID.randomUUID().toString().replace("-", "") + "." + type;
+		String filePath =FilePathEnum.helpClass.getPath()+ UUID.randomUUID().toString().replace("-", "") + "." + type;
 		
 		/*  淇敼鍥剧墖鏃讹紝鍏堝垹闄ゅ凡瀛樺湪鍥剧墖  */
 		String picture = helpClass.getPicture();

--
Gitblit v1.8.0