From 1d2e2ee00ed42265fc0c45688d9040701543909f Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期四, 11 六月 2020 17:50:21 +0800
Subject: [PATCH] 云发单调整
---
fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/ArticleOfficialServiceImpl.java | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 46 insertions(+), 1 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/ArticleOfficialServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/ArticleOfficialServiceImpl.java
index 11b39c6..168ad6c 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/ArticleOfficialServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/ArticleOfficialServiceImpl.java
@@ -8,6 +8,7 @@
import javax.annotation.Resource;
+import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import org.yeshi.utils.DateUtil;
@@ -17,6 +18,7 @@
import com.yeshi.fanli.entity.dynamic.ArticleOfficial;
import com.yeshi.fanli.exception.dynamic.ArticleOfficialException;
import com.yeshi.fanli.service.inter.dynamic.ArticleOfficialService;
+import com.yeshi.fanli.util.FilePathEnum;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.vo.dynamic.ArticleVO;
@@ -147,7 +149,7 @@
String type = contentType.substring(contentType.indexOf("/") + 1);
// 鏂囦欢璺緞
- String filePath = "/img/article/" + UUID.randomUUID().toString().replace("-", "") + "." + type;
+ String filePath = FilePathEnum.article.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type;
// 鎵ц涓婁紶
String fileLink = COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
@@ -167,9 +169,51 @@
@Override
+ public void switchState(String id) throws ArticleOfficialException {
+ if (StringUtil.isNullOrEmpty(id)) {
+ throw new ArticleOfficialException(1, "璇蜂紶閫掓纭弬鏁�");
+ }
+
+ ArticleOfficial resultObj = articleOfficialDao.getById(id);
+ if (resultObj == null) {
+ throw new ArticleOfficialException(1, "姝ゅ唴瀹瑰凡涓嶅瓨鍦�");
+ }
+
+ Integer state = resultObj.getState();
+ if (state == null || state == 0) {
+ state = 1;
+ } else {
+ state = 0;
+ }
+ articleOfficialDao.updateSatate(id, state);
+ }
+
+ @Override
public ArticleOfficial getById(String id) {
return articleOfficialDao.getById(id);
}
+
+
+ @Override
+ public void updateReadNum(String id) {
+ ArticleOfficial article = articleOfficialDao.getById(id);
+ if (article != null) {
+ Integer readNum = article.getReadNum();
+ if (readNum == null) {
+ readNum = 0;
+ }
+ article.setReadNum(readNum + 1);
+
+ Integer readNumReal = article.getReadNumReal();
+ if (readNumReal == null) {
+ readNumReal = 0;
+ }
+ article.setReadNumReal(readNumReal + 1);
+
+ articleOfficialDao.save(article);
+ }
+ }
+
@Override
public List<ArticleOfficial> query(int start, int count, String key,Integer state) {
@@ -182,6 +226,7 @@
}
@Override
+ @Cacheable(value = "dynamicCache", key = "'queryValid-'+#start+'-'+#key")
public List<ArticleVO> queryValid(int start, int count, String key) {
return articleOfficialDao.queryValid(start, count, key);
}
--
Gitblit v1.8.0