inleft
2022-02-17 4d51af31b49927bf401e432138d584f9ef40ef22
commit | author | age
0613f2 1 /*
I 2 Copyright [2020] [https://www.xiaonuo.vip]
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8   http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15
16 Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
17
18 1.请不要删除和修改根目录下的LICENSE文件。
19 2.请不要删除和修改Snowy源码头部的版权声明。
20 3.请保留源码和相关描述文件的项目出处,作者声明等。
21 4.分发源码时候,请注明软件出处 https://gitee.com/xiaonuobase/snowy
22 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/xiaonuobase/snowy
23 6.若您的项目无法满足以上几点,可申请商业授权,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
24  */
25 package vip.xiaonuo.modular.blogStatistics;
26
27 import cn.hutool.core.date.DateUnit;
28 import cn.hutool.core.date.DateUtil;
29 import org.springframework.web.bind.annotation.GetMapping;
30 import org.springframework.web.bind.annotation.RequestMapping;
31 import org.springframework.web.bind.annotation.RestController;
32 import vip.xiaonuo.core.annotion.BusinessLog;
33 import vip.xiaonuo.core.enums.LogAnnotionOpTypeEnum;
34 import vip.xiaonuo.core.pojo.response.ResponseData;
35 import vip.xiaonuo.core.pojo.response.SuccessResponseData;
36 import vip.xiaonuo.modular.blogStatistics.vo.BlogStatisticsVo;
37 import vip.xiaonuo.modular.blogarticle.entity.BlogArticle;
38 import vip.xiaonuo.modular.blogarticle.service.BlogArticleService;
39
40 import javax.annotation.Resource;
41 import java.util.ArrayList;
42 import java.util.Date;
43 import java.util.List;
44
45 /**
46  * blog文章控制器 (提供给外部blog系统查询)
47  *
48  * @author inleft
49  * @date 2022-02-09 18:20:22
50  */
51 @RestController
52 @RequestMapping("/outside")
53 public class BlogStatisticsController {
54
55     @Resource
56     private BlogArticleService blogArticleService;
57
58     /**
59      * @author inleft
60      * @date 2022-02-09 18:20:22
61      */
62     @GetMapping("/blog/statistics")
63     @BusinessLog(title = "外部blog系统_统计_查询", opType = LogAnnotionOpTypeEnum.QUERY)
64     public ResponseData statistics() {
65
4d51af 66         String updateDate = "--";
I 67         BlogArticle lastUpdateBlog = blogArticleService.lambdaQuery().orderByDesc(BlogArticle::getUpdateDate).last(" limit 1 ").one();
0613f2 68         if (lastUpdateBlog != null && lastUpdateBlog.getUpdateDate() != null) {
I 69             updateDate = DateUtil.formatDate(lastUpdateBlog.getUpdateDate());
70         }
4d51af 71
0613f2 72         String startFrom = "从这开始: 2020-05-27 ";
4d51af 73         String aliveDayCount = "已稳定运行:" + DateUtil.between(DateUtil.parseDate("2022-02-14"), new Date(), DateUnit.DAY) + "天";
0613f2 74         String lastUpdateDate = "上次更新:" + updateDate;
4d51af 75         String visitCount = "累计访问:1010次"; //24小时ip 访问次数
I 76         String visitorCount = "累计访客:1001名";//所有时间ip个数
0613f2 77
I 78         List<BlogStatisticsVo.simpleVo> res = new ArrayList<>();
79         res.add(new BlogStatisticsVo.simpleVo().setName(startFrom));
80         res.add(new BlogStatisticsVo.simpleVo().setName(aliveDayCount));
81         res.add(new BlogStatisticsVo.simpleVo().setName(lastUpdateDate));
82         res.add(new BlogStatisticsVo.simpleVo().setName(visitCount));
83         res.add(new BlogStatisticsVo.simpleVo().setName(visitorCount));
84
85         BlogStatisticsVo statisticsVo = new BlogStatisticsVo();
86         statisticsVo.setList(res);
87         statisticsVo.setTitle("统计信息");
88         return new SuccessResponseData(statisticsVo);
89
90     }
91
92
93 }