diff --git a/blossom-backend/backend/src/main/java/com/blossom/backend/server/article/draft/ArticleMapper.java b/blossom-backend/backend/src/main/java/com/blossom/backend/server/article/draft/ArticleMapper.java index 548f917..863a63b 100644 --- a/blossom-backend/backend/src/main/java/com/blossom/backend/server/article/draft/ArticleMapper.java +++ b/blossom-backend/backend/src/main/java/com/blossom/backend/server/article/draft/ArticleMapper.java @@ -50,6 +50,16 @@ public interface ArticleMapper extends BaseMapper { */ void updContentById(ArticleEntity entity); + /** + * 查询某段时间内编辑过内容的文章数 + * + * @param beginUpdTime 开始修改日期 + * @param endUpdTime 结束修改日期 + */ + ArticleStatRes statUpdArticleCount(@Param("beginUpdTime") String beginUpdTime, + @Param("endUpdTime") String endUpdTime, + @Param("userId") Long userId); + /** * 修改某段日期内修改的文章数据 * diff --git a/blossom-backend/backend/src/main/java/com/blossom/backend/server/article/draft/ArticleService.java b/blossom-backend/backend/src/main/java/com/blossom/backend/server/article/draft/ArticleService.java index fb1f895..390e5a6 100644 --- a/blossom-backend/backend/src/main/java/com/blossom/backend/server/article/draft/ArticleService.java +++ b/blossom-backend/backend/src/main/java/com/blossom/backend/server/article/draft/ArticleService.java @@ -19,6 +19,7 @@ import com.blossom.backend.server.doc.pojo.DocTreeRes; import com.blossom.backend.server.utils.ArticleUtil; import com.blossom.backend.server.utils.DocUtil; import com.blossom.common.base.exception.XzException404; +import com.blossom.common.base.util.DateUtils; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Async; @@ -188,6 +189,7 @@ public class ArticleService extends ServiceImpl { if (req.getHtml() != null) { req.setHtml(req.getHtml().replaceAll("


", "")); } + req.setUpdMarkdownTime(DateUtils.date()); baseMapper.updContentById(req); referenceService.bind(req.getUserId(), req.getId(), req.getName(), req.getReferences()); logService.insert(req.getId(), 0, req.getMarkdown()); diff --git a/blossom-backend/backend/src/main/java/com/blossom/backend/server/article/draft/pojo/ArticleEntity.java b/blossom-backend/backend/src/main/java/com/blossom/backend/server/article/draft/pojo/ArticleEntity.java index dc8557a..41cd8c7 100644 --- a/blossom-backend/backend/src/main/java/com/blossom/backend/server/article/draft/pojo/ArticleEntity.java +++ b/blossom-backend/backend/src/main/java/com/blossom/backend/server/article/draft/pojo/ArticleEntity.java @@ -118,6 +118,10 @@ public class ArticleEntity extends AbstractPOJO implements Serializable { * 用户ID */ private Long userId; + /** + * 文章内容的修改时间 + */ + private Date updMarkdownTime; //region ============================== 非数据库字段 ============================== /** diff --git a/blossom-backend/backend/src/main/java/com/blossom/backend/server/article/stat/ArticleStatJob.java b/blossom-backend/backend/src/main/java/com/blossom/backend/server/article/stat/ArticleStatJob.java index 20a9bc7..108f7e3 100644 --- a/blossom-backend/backend/src/main/java/com/blossom/backend/server/article/stat/ArticleStatJob.java +++ b/blossom-backend/backend/src/main/java/com/blossom/backend/server/article/stat/ArticleStatJob.java @@ -42,12 +42,12 @@ public class ArticleStatJob { } for (UserEntity user : users) { - ArticleStatRes statCount = statService.statCount(toDayBegin, toDayEnd, user.getId()); - statService.updByDate(1, toDay, statCount.getArticleCount(), user.getId()); + ArticleStatRes statCount = statService.statUpdArticleCount(toDayBegin, toDayEnd, user.getId()); + statService.updByDate(ArticleStatTypeEnum.ARTICLE_HEATMAP, toDay, statCount.getArticleCount(), user.getId()); String toMouth = DateUtils.format(DateUtils.beginOfMonth(DateUtils.date()), DateUtils.PATTERN_YYYYMMDD); ArticleStatRes statWord = statService.statCount(null, null, user.getId()); - statService.updByDate(2, toMouth, statWord.getArticleWords(), user.getId()); + statService.updByDate(ArticleStatTypeEnum.ARTICLE_WORDS, toMouth, statWord.getArticleWords(), user.getId()); } } } diff --git a/blossom-backend/backend/src/main/java/com/blossom/backend/server/article/stat/ArticleStatService.java b/blossom-backend/backend/src/main/java/com/blossom/backend/server/article/stat/ArticleStatService.java index ce868b7..b9fc6e8 100644 --- a/blossom-backend/backend/src/main/java/com/blossom/backend/server/article/stat/ArticleStatService.java +++ b/blossom-backend/backend/src/main/java/com/blossom/backend/server/article/stat/ArticleStatService.java @@ -140,6 +140,16 @@ public class ArticleStatService extends ServiceImpl existWhere = new LambdaQueryWrapper<>(); existWhere .eq(ArticleStatEntity::getUserId, userId) - .eq(ArticleStatEntity::getType, type) + .eq(ArticleStatEntity::getType, type.getType()) .eq(ArticleStatEntity::getStatDate, date); if (baseMapper.exists(existWhere)) { LambdaQueryWrapper updWhere = new LambdaQueryWrapper<>(); updWhere.eq(ArticleStatEntity::getUserId, userId) - .eq(ArticleStatEntity::getType, type) + .eq(ArticleStatEntity::getType, type.getType()) .eq(ArticleStatEntity::getStatDate, date); ArticleStatEntity upd = new ArticleStatEntity(); upd.setStatValue(value); baseMapper.update(upd, updWhere); } else { ArticleStatEntity ist = new ArticleStatEntity(); - ist.setType(type); + ist.setType(type.getType()); ist.setStatDate(DateUtils.parse(date, DateUtils.PATTERN_YYYYMMDD)); ist.setStatValue(value); ist.setUserId(userId); diff --git a/blossom-backend/backend/src/main/resources/mapper/ArticleMapper.xml b/blossom-backend/backend/src/main/resources/mapper/ArticleMapper.xml index 261edd5..372a6bc 100644 --- a/blossom-backend/backend/src/main/resources/mapper/ArticleMapper.xml +++ b/blossom-backend/backend/src/main/resources/mapper/ArticleMapper.xml @@ -92,12 +92,24 @@ html = #{html}, words = #{words}, toc = #{toc}, - version = version + 1 + version = version + 1, + upd_markdown_time = #{updMarkdownTime} where id = #{id} and user_id = #{userId} +