|
|
|
@ -1,6 +1,7 @@ |
|
|
|
|
package com.huoran.iasf.service.impl; |
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
@ -12,6 +13,7 @@ import com.huoran.iasf.service.SysContentService; |
|
|
|
|
import com.huoran.iasf.vo.req.ContentHeavyTitleReqVO; |
|
|
|
|
import com.huoran.iasf.vo.req.PageContentReqVO; |
|
|
|
|
import com.huoran.iasf.vo.resp.PageContentRespVO; |
|
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
|
|
|
@ -28,6 +30,9 @@ public class SysContentServiceImpl extends ServiceImpl<SysContentMapper, SysCont |
|
|
|
|
@Autowired |
|
|
|
|
private SysContentMapper mapper; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private StringRedisTemplate redisTemplate; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean checkIfTheTitleIsRepeat(ContentHeavyTitleReqVO content) { |
|
|
|
|
//只对已发布的标题判重
|
|
|
|
@ -58,9 +63,6 @@ public class SysContentServiceImpl extends ServiceImpl<SysContentMapper, SysCont |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public R newlyPublishedArticles(PageContentReqVO reqVO) { |
|
|
|
|
/* QueryWrapper<SysContent> queryWrapper = new QueryWrapper<>(); |
|
|
|
|
queryWrapper.eq("site_id", reqVO.getSiteId()); |
|
|
|
|
queryWrapper.eq("is_release", Constant.ARTICLE_PUBLISHED).orderByDesc("create_time");*/ |
|
|
|
|
Page<PageContentRespVO> page = new Page<PageContentRespVO>(reqVO.getPageNum(), reqVO.getPageSize()); |
|
|
|
|
IPage<PageContentRespVO> pageList = baseMapper.getPublishedArticles(page, reqVO); |
|
|
|
|
return R.success(pageList); |
|
|
|
@ -73,7 +75,6 @@ public class SysContentServiceImpl extends ServiceImpl<SysContentMapper, SysCont |
|
|
|
|
queryWrapper.eq("is_release", Constant.ARTICLE_PUBLISHED); |
|
|
|
|
queryWrapper.eq("template_status", Constant.TEMPLATE_STATUS_ENABLED); |
|
|
|
|
List<SysContent> sysContentList = mapper.selectList(queryWrapper); |
|
|
|
|
|
|
|
|
|
return R.success(sysContentList); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
@ -83,7 +84,26 @@ public class SysContentServiceImpl extends ServiceImpl<SysContentMapper, SysCont |
|
|
|
|
return R.success(mapper.useTheColumnToGetTagsForTheFullArticle(ids)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Integer statisticsOfPageViews(Integer id) { |
|
|
|
|
|
|
|
|
|
String key = "preview:contentId:" + id; |
|
|
|
|
//查看缓存是否有数据
|
|
|
|
|
String returnValue = redisTemplate.opsForValue().get(key); |
|
|
|
|
if (returnValue == null) { |
|
|
|
|
returnValue = "0"; |
|
|
|
|
} |
|
|
|
|
returnValue = Integer.valueOf(returnValue) + 1 + ""; |
|
|
|
|
//保存到缓存中
|
|
|
|
|
redisTemplate.opsForValue().set(key, returnValue + ""); |
|
|
|
|
|
|
|
|
|
SysContent sysContent = new SysContent(); |
|
|
|
|
sysContent.setId(id); |
|
|
|
|
sysContent.setTotalBrowsing(Integer.valueOf(returnValue)); |
|
|
|
|
mapper.updateById(sysContent); |
|
|
|
|
|
|
|
|
|
return Integer.valueOf(returnValue); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|