snowy-main/pom.xml
@@ -49,7 +49,7 @@ </dependencies> <build> <finalName>snowy</finalName> <finalName>blog</finalName> <plugins> <plugin> <groupId>org.springframework.boot</groupId> snowy-main/src/main/java/vip/xiaonuo/modular/blogStatistics/BlogStatisticsController.java
@@ -30,17 +30,17 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import vip.xiaonuo.core.annotion.BusinessLog; import vip.xiaonuo.core.consts.MyConstant; import vip.xiaonuo.core.enums.LogAnnotionOpTypeEnum; import vip.xiaonuo.core.pojo.response.ResponseData; import vip.xiaonuo.core.pojo.response.SuccessResponseData; import vip.xiaonuo.modular.blogStatistics.vo.BlogArchiveVo; import vip.xiaonuo.modular.blogStatistics.vo.BlogStatisticsVo; import vip.xiaonuo.modular.blogarticle.entity.BlogArticle; import vip.xiaonuo.modular.blogarticle.service.BlogArticleService; import javax.annotation.Resource; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.*; /** * blog文章控制器 (提供给外部blog系统查询) @@ -79,8 +79,8 @@ res.add(new BlogStatisticsVo.simpleVo().setName(startFrom)); res.add(new BlogStatisticsVo.simpleVo().setName(aliveDayCount)); res.add(new BlogStatisticsVo.simpleVo().setName(lastUpdateDate)); res.add(new BlogStatisticsVo.simpleVo().setName(visitCount)); res.add(new BlogStatisticsVo.simpleVo().setName(visitorCount)); // res.add(new BlogStatisticsVo.simpleVo().setName(visitCount)); // res.add(new BlogStatisticsVo.simpleVo().setName(visitorCount)); BlogStatisticsVo statisticsVo = new BlogStatisticsVo(); statisticsVo.setList(res); @@ -89,5 +89,39 @@ } /** * 查询blog归档 * * @author inleft * @date 2022-02-09 18:20:22 */ @GetMapping("/blog/archive") @BusinessLog(title = "外部blog系统_blog归档_查询", opType = LogAnnotionOpTypeEnum.QUERY) public ResponseData archive(Integer year, Integer month) { //不考虑数据太多的情况,这里应该可以把数据全部捞出来 List<BlogArticle> articleList = blogArticleService.lambdaQuery() .eq(BlogArticle::getIsEnable, MyConstant.Yes) .eq(BlogArticle::getEditorStatus, MyConstant.Yes) // .eq(year != null,BlogArticle::getSeparateYear, year) // .eq(month != null, BlogArticle::getSeparateMonth, month) .orderByDesc(BlogArticle::getSeparateYear) .groupBy(BlogArticle::getSeparateYear) .select(BlogArticle::getSeparateYear) .list(); List<BlogArchiveVo> res = new ArrayList<>(articleList.size()); BlogArchiveVo blogArchiveVo; for (BlogArticle blogArticle : articleList) { blogArchiveVo = new BlogArchiveVo(); blogArchiveVo.setYear(blogArticle.getSeparateYear().toString()); blogArchiveVo.setList(blogArticleService.searchMonthCount(blogArticle.getSeparateYear())); res.add(blogArchiveVo); } return new SuccessResponseData(res); } } snowy-main/src/main/java/vip/xiaonuo/modular/blogStatistics/vo/BlogArchiveDetailVo.java
New file @@ -0,0 +1,41 @@ /* Copyright [2020] [https://www.xiaonuo.vip] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: 1.请不要删除和修改根目录下的LICENSE文件。 2.请不要删除和修改Snowy源码头部的版权声明。 3.请保留源码和相关描述文件的项目出处,作者声明等。 4.分发源码时候,请注明软件出处 https://gitee.com/xiaonuobase/snowy 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/xiaonuobase/snowy 6.若您的项目无法满足以上几点,可申请商业授权,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip */ package vip.xiaonuo.modular.blogStatistics.vo; import lombok.Data; /** * blog 统计信息 * * @author inleft * @date 2022-01-22 16:53:06 */ @Data public class BlogArchiveDetailVo { private String month; private String count; private String name; private String remark; } snowy-main/src/main/java/vip/xiaonuo/modular/blogStatistics/vo/BlogArchiveVo.java
New file @@ -0,0 +1,22 @@ package vip.xiaonuo.modular.blogStatistics.vo; import lombok.Data; import java.util.List; /** * blog 统计信息 * * @author inleft * @date 2022-01-22 16:53:06 */ @Data public class BlogArchiveVo { private String year; private List<BlogArchiveDetailVo> list; } snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/controller/BlogArticleOutsideController.java
@@ -78,16 +78,17 @@ Map<String, Object> param = new HashMap<>(16); param.put("pageNo", PageUtil.getStart(queryDto.getPageNo() - 1, queryDto.getPageSize())); param.put("pageSize", queryDto.getPageSize()); param.put("typeId", queryDto.getTypeId()); String fileUploadPathForLinux = ConstantContextHolder.getDefaultFileUploadPathForLinux(); List<BlogArticleVo> resList = blogArticleService.searchMediaList(param).stream().map(e -> { List<BlogArticleVo> resList = blogArticleService.searchList(param).stream().map(e -> { if (StrUtil.isNotEmpty(e.getArticleFileURL())) { e.setArticleFileURL(fileUploadPathForLinux + e.getArticleFileURL()); } return e; }).collect(Collectors.toList()); long count = blogArticleService.searchMediaListCount(param); long count = blogArticleService.searchListCount(param); Page<BlogArticleVo> queryPage = new Page<>(queryDto.getPageNo(), queryDto.getPageSize()); queryPage.setRecords(resList); @@ -132,7 +133,6 @@ } else { vo.setArticleFileURL("http://t.inleft.com/share/book/blog/es-search.md"); } return new SuccessResponseData(vo); } snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/mapper/BlogArticleMapper.java
@@ -26,6 +26,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Param; import vip.xiaonuo.modular.blogStatistics.vo.BlogArchiveDetailVo; import vip.xiaonuo.modular.blogarticle.entity.BlogArticle; import java.util.List; @@ -39,7 +40,9 @@ */ public interface BlogArticleMapper extends BaseMapper<BlogArticle> { List searchMediaList(@Param("param") Map<String, Object> param); List searchList(@Param("param") Map<String, Object> param); long searchMediaListCount(@Param("param") Map<String, Object> param); long searchListCount(@Param("param") Map<String, Object> param); List<BlogArchiveDetailVo> searchMonthCount(@Param("separateYear") Integer separateYear); } snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/mapper/mapping/BlogArticleMapper.xml
@@ -30,10 +30,13 @@ <trim prefix="WHERE" prefixOverrides="AND | OR"> a.is_enable=1 and a.editor_status=1 <if test="param.typeId != null"> AND a.article_type_id = #{param.typeId} </if> </trim> </sql> <select id="searchMediaList" resultType="vip.xiaonuo.modular.blogarticle.param.BlogArticleVo"> <select id="searchList" resultType="vip.xiaonuo.modular.blogarticle.param.BlogArticleVo"> select <include refid="Base_Column_List"/> ,CONCAT("/",f1.file_bucket,"/",f1.file_object_name) as articleFileURL @@ -41,7 +44,7 @@ ,t.type_name as articleTypeName from blog_article a inner join blog_article_type t inner join blog_article_type t on t.id =a.article_type_id left join sys_file_info f1 @@ -58,7 +61,7 @@ limit #{param.pageNo},#{param.pageSize} </select> <select id="searchMediaListCount" resultType="java.lang.Long"> <select id="searchListCount" resultType="java.lang.Long"> select count(0) from @@ -67,4 +70,22 @@ </select> <select id="searchMonthCount" resultType="vip.xiaonuo.modular.blogStatistics.vo.BlogArchiveDetailVo"> SELECT separate_month AS `month`, count(1) AS count FROM blog_article WHERE ( is_enable = 1 AND editor_status = 1 AND separate_year = #{separateYear} ) GROUP BY separate_month ORDER BY separate_month desc </select> </mapper> snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/param/BlogArticleAddDto.java
New file @@ -0,0 +1,91 @@ package vip.xiaonuo.modular.blogarticle.param; import lombok.Data; import vip.xiaonuo.core.pojo.base.param.BaseParam; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; /** * blog文章参数类 * * @author inleft * @date 2022-02-09 18:21:14 */ @Data public class BlogArticleAddDto extends BaseParam { /** * 文章标题 */ @NotBlank(message = "文章标题不能为空,请检查title参数", groups = {add.class, edit.class}) private String title; /** * 文章文件id */ @NotNull(message = "文章文件id不能为空,请检查articleFileId参数", groups = {add.class, edit.class}) private Long articleFileId; /** * 文件类型 */ private Integer articleFileType; /** * 文章分类 */ @NotNull(message = "文章分类不能为空,请检查articleTypeId参数", groups = {add.class, edit.class}) private Long articleTypeId; /** * 文章引言 */ private String introduce; /** * 封面文件 */ private Long coverFileId; /** * 上次编辑时间 */ private String lastEditorDate; /** * 发布时间 */ private String publishDate; /** * 是否置顶 */ @NotNull(message = "是否置顶不能为空,请检查isTop参数", groups = {add.class, edit.class}) private Integer isTop; /** * 置顶值 */ private Integer topValue; /** * 公开状态 */ private Integer authStatus; /** * 授权密码 */ private String authPassword; /** * 编辑状态 */ private Integer editorStatus; } snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/param/BlogArticleQueryDto.java
@@ -20,5 +20,7 @@ private Long id; private Long typeId; } snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/service/BlogArticleService.java
@@ -26,6 +26,8 @@ import com.baomidou.mybatisplus.extension.service.IService; import vip.xiaonuo.core.pojo.page.PageResult; import vip.xiaonuo.modular.blogStatistics.vo.BlogArchiveDetailVo; import vip.xiaonuo.modular.blogStatistics.vo.BlogArchiveVo; import vip.xiaonuo.modular.blogarticle.entity.BlogArticle; import vip.xiaonuo.modular.blogarticle.param.BlogArticleParam; import vip.xiaonuo.modular.blogarticle.param.BlogArticleVo; @@ -97,7 +99,10 @@ */ void export(BlogArticleParam blogArticleParam); List<BlogArticleVo> searchMediaList(Map<String,Object> param); List<BlogArticleVo> searchList(Map<String,Object> param); long searchMediaListCount(Map<String, Object> param); long searchListCount(Map<String, Object> param); List<BlogArchiveDetailVo> searchMonthCount(Integer separateYear); } snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/service/impl/BlogArticleServiceImpl.java
@@ -34,6 +34,7 @@ import vip.xiaonuo.core.factory.PageFactory; import vip.xiaonuo.core.pojo.page.PageResult; import vip.xiaonuo.core.util.PoiUtil; import vip.xiaonuo.modular.blogStatistics.vo.BlogArchiveDetailVo; import vip.xiaonuo.modular.blogarticle.entity.BlogArticle; import vip.xiaonuo.modular.blogarticle.enums.BlogArticleExceptionEnum; import vip.xiaonuo.modular.blogarticle.mapper.BlogArticleMapper; @@ -152,12 +153,18 @@ @Override public List searchMediaList(Map<String, Object> param) { return this.baseMapper.searchMediaList(param); public List searchList(Map<String, Object> param) { return this.baseMapper.searchList(param); } @Override public long searchMediaListCount(Map<String, Object> param) { return this.baseMapper.searchMediaListCount(param); public long searchListCount(Map<String, Object> param) { return this.baseMapper.searchListCount(param); } @Override public List<BlogArchiveDetailVo> searchMonthCount(Integer separateYear) { return this.baseMapper.searchMonthCount(separateYear); } }