|
@@ -2,6 +2,9 @@ package com.usky.website.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
@@ -14,6 +17,7 @@ import com.usky.website.mapper.SiteArticleMapper;
|
|
|
import com.usky.website.mapper.SiteCategoryMapper;
|
|
|
import com.usky.website.service.SiteArticleService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
@@ -35,7 +39,7 @@ public class SiteArticleServiceImpl extends AbstractCrudService<SiteArticleMappe
|
|
|
private SiteCategoryMapper siteCategoryMapper;
|
|
|
|
|
|
@Override
|
|
|
- public CommonPage<SiteArticle> siteArticleList(Integer categoryid, Integer id, String title, String order, Integer pageNum, Integer pageSize) {
|
|
|
+ public CommonPage<SiteArticle> siteArticleList(Integer categoryid, Integer id, Integer articleid, String title, String order, Integer pageNum, Integer pageSize) {
|
|
|
IPage<SiteArticle> page = new Page<>(pageNum, pageSize);
|
|
|
List<Integer> categoryidList = new ArrayList<>();
|
|
|
if (categoryid != null && categoryid != 0) {
|
|
@@ -53,6 +57,10 @@ public class SiteArticleServiceImpl extends AbstractCrudService<SiteArticleMappe
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if(articleid != null){
|
|
|
+ this.updateArticleHits(articleid);
|
|
|
+ }
|
|
|
+
|
|
|
LambdaQueryWrapper<SiteCategory> queryWrapper1 = Wrappers.lambdaQuery();
|
|
|
queryWrapper1.eq(SiteCategory::getStatus, 1)
|
|
|
.in(CollectionUtil.isNotEmpty(categoryidList), SiteCategory::getId, categoryidList);
|
|
@@ -96,4 +104,16 @@ public class SiteArticleServiceImpl extends AbstractCrudService<SiteArticleMappe
|
|
|
public void delSiteArticle(Integer id) {
|
|
|
this.removeById(id);
|
|
|
}
|
|
|
+
|
|
|
+ //异步多线程调用
|
|
|
+ //更新官网_内容管理表中点击量字段值(每调用一次某个内容,就+1次对应表id的点击量字段值)
|
|
|
+ @Async("asyncServiceExecutor")
|
|
|
+ public void updateArticleHits(Integer articleid){
|
|
|
+ UpdateWrapper<SiteArticle> updateWrapper = Wrappers.update();
|
|
|
+ updateWrapper.setSql("hits = hits + 1")
|
|
|
+ .eq("id",articleid);
|
|
|
+
|
|
|
+ this.update(updateWrapper);
|
|
|
+
|
|
|
+ }
|
|
|
}
|