提交 fcd08cc4 编写于 作者: yubinCloud's avatar yubinCloud

11-9 后端增加获取近30天统计数据的接口

上级 a2d7c247
......@@ -23,9 +23,16 @@ public class EbookSnapshotController {
private EbookSnapshotService ebookSnapshotService;
@GetMapping("/get-statistic")
@ApiOperation(value = "从电子书快照中获取统计数据")
@ApiOperation(value = "从电子书快照中昨天和今天的获取统计数据")
public RestfulModel<List<StatisticRespDto>> getStatistic() {
List<StatisticRespDto> statisticRespDtoList = ebookSnapshotService.getStatistic();
return new RestfulModel<>(ErrorCode.SUCCESS, "", statisticRespDtoList);
}
@GetMapping("/get-30-statistic")
@ApiOperation(value = "从电子书快照中获取近30天的统计数据")
public RestfulModel<List<StatisticRespDto>> get30DayStatistic() {
List<StatisticRespDto> statisticRespDtoList = ebookSnapshotService.get30DayStatistic();
return new RestfulModel<>(ErrorCode.SUCCESS, "", statisticRespDtoList);
}
}
......@@ -8,4 +8,6 @@ public interface EbookSnapshotMapperCustom {
void genSnapshot();
List<StatisticRespDto> getStatistic();
List<StatisticRespDto> get30DayStatistic();
}
......@@ -32,4 +32,11 @@ public class EbookSnapshotService {
}
return statisticDataList;
}
/**
* 30天数值统计
*/
public List<StatisticRespDto> get30DayStatistic() {
return ebookSnapshotMapperCustom.get30DayStatistic();
}
}
......@@ -54,4 +54,20 @@
t1.`date` ASC;
</select>
<select id="get30DayStatistic" resultType="io.github.yubincloud.fairywiki.dto.resp.StatisticRespDto">
SELECT
t1.`date` AS `date`,
SUM(t1.view_count) AS viewCount,
SUM(t1.vote_count) AS voteCount
FROM
ebook_snapshot t1
WHERE
t1.`date` >= date_sub(curdate(), INTERVAL 30 DAY)
GROUP BY
t1.`date`
ORDER BY
t1.`date` ASC;
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册