| | |
| | |
|
| | | 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;
|
| | |
| | | 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;
|
| | |
|
| | |
| | | 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();
|
| | |
|
| | |
| | | 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) {
|
| | | return articleOfficialDao.query(start, count, key, state);
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | @Cacheable(value = "dynamicCache", key = "'queryValid-'+#start+'-'+#key")
|
| | | public List<ArticleVO> queryValid(int start, int count, String key) {
|
| | | return articleOfficialDao.queryValid(start, count, key);
|
| | | }
|