snowy-base/snowy-core/src/main/java/vip/xiaonuo/core/consts/MyConstant.java
@@ -41,6 +41,15 @@ int status_1 = 1; } /** * 月台类型分类,暂时不考虑加入数据库 */ interface platformType { int type_1 = 1;//片刻 int type_2 = 2;//流影 int type_3 = 3;//谱库 } /** * 文件类型 snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/controller/BlogArticleOutsideController.java
@@ -25,6 +25,7 @@ package vip.xiaonuo.modular.blogarticle.controller; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.PageUtil; @@ -36,6 +37,7 @@ import org.springframework.web.bind.annotation.*; import vip.xiaonuo.core.annotion.BusinessLog; import vip.xiaonuo.core.consts.MyConstant; import vip.xiaonuo.core.consts.SymbolConstant; import vip.xiaonuo.core.context.constant.ConstantContextHolder; import vip.xiaonuo.core.enums.LogAnnotionOpTypeEnum; import vip.xiaonuo.core.exception.BlogException; @@ -53,11 +55,9 @@ import vip.xiaonuo.sys.modular.file.service.SysFileInfoService; import javax.annotation.Resource; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.*; import java.util.concurrent.Future; import java.util.function.Function; import java.util.stream.Collectors; /** @@ -186,6 +186,61 @@ return new SuccessResponseData(queryPage); } /** * 查询blog文章(月台专用列表) * * @author inleft * @date 2022-02-09 18:20:22 */ @GetMapping("/blogArticle/platform") @BusinessLog(title = "外部blog系统_blog月台_查询", opType = LogAnnotionOpTypeEnum.QUERY) public ResponseData platform(BlogArticleQueryDto queryDto) { Map<String, Object> param = new HashMap<>(16); param.put("pageNo", PageUtil.getStart(queryDto.getPageNo() - 1, queryDto.getPageSize())); param.put("pageSize", queryDto.getPageSize()); if (queryDto.getActiveKey().equals(MyConstant.platformType.type_2)) { param.put("typeIds", new Long[]{10L});//临时id,后续需要修改(前方高能分类) param.put("fileType", MyConstant.FileType.fileTypeVideo_3); } else if (queryDto.getActiveKey().equals(MyConstant.platformType.type_3)) { param.put("typeIds", new Long[]{99L});//临时id,后续需要修改 param.put("fileType", MyConstant.FileType.fileTypePhoto_9); } else { param.put("typeIds", new Long[]{4L});//临时id,后续需要修改(音乐分类) param.put("fileType", MyConstant.FileType.fileTypeVideo_3); } String blogSourcePrefix = ConstantContextHolder.getBlogSourcePrefix(); //空类型查询条件,排除笔记系列,按更新时间倒序 //含有类型查询,按发布时间倒序 List<BlogArticleVo> resList = blogArticleService.searchPlatformList(param).stream().map(e -> { if (StrUtil.isNotEmpty(e.getCoverFileURL())) { if (!e.getCoverFileURL().startsWith("http")) { //补上访问参数 e.setCoverFileURL(blogSourcePrefix + e.getCoverFileURL()); } } //补充视频组,图片组的url if (StrUtil.isNotEmpty(e.getPictureIds())) { e.setPictureUrlList(this.getBlogSourceURLBatch(Arrays.stream(e.getPictureIds().split(SymbolConstant.COMMA)).collect(Collectors.toList()))); } return e; }).collect(Collectors.toList()); long count = blogArticleService.searchPlatformListCount(param); Page<BlogArticleVo> queryPage = new Page<>(queryDto.getPageNo(), queryDto.getPageSize()); queryPage.setRecords(resList); queryPage.setTotal(count); return new SuccessResponseData(queryPage); } @GetMapping("/blogArticle/queryBlogArticleDetail") @BusinessLog(title = "外部blog系统_blog文章详情_查询", opType = LogAnnotionOpTypeEnum.QUERY) public ResponseData queryBlogArticleDetail(BlogArticleQueryDto queryDto) { @@ -256,4 +311,25 @@ } } private List<String> getBlogSourceURLBatch(List<String> fileIds) { Map<String, SysFileInfo> sysFileInfoMap = fileInfoService.listByIds(fileIds).stream().collect(Collectors.toMap(e -> e.getId().toString(), Function.identity(), (k1, k2) -> k1)); if (CollUtil.isEmpty(sysFileInfoMap)) { return null; } else { List<String> urlList = new ArrayList<>(fileIds.size()); String blogSourcePrefix = ConstantContextHolder.getBlogSourcePrefix(); SysFileInfo sysFileInfo; for (String fileId : fileIds) { sysFileInfo = sysFileInfoMap.getOrDefault(fileId, null); if (sysFileInfo == null) { urlList.add(null); } else { urlList.add(blogSourcePrefix + sysFileInfo.getFileBucket() + "/" + sysFileInfo.getFileObjectName()); } } return urlList; } } } snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/entity/BlogArticleVo.java
@@ -29,6 +29,7 @@ import lombok.Data; import java.util.Date; import java.util.List; /** * blog文章主体 @@ -83,6 +84,7 @@ @JsonIgnore private Long coverFileId; /** * 上次编辑时间 */ @@ -136,4 +138,20 @@ */ private BlogArticleVo nextRecord; /** * 图库地址列表 */ private List<String> pictureUrlList; /** * 视频地址列表 */ private List<String> videoUrlList; @JsonIgnore private String videoIds; @JsonIgnore private String pictureIds; } snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/mapper/BlogArticleMapper.java
@@ -49,4 +49,7 @@ List<BlogArticleVo> getAdjoiningRecord(@Param("param") Map<String, Object> param); List<BlogArticleVo> searchPlatformList(@Param("param") Map<String, Object> param); long searchPlatformListCount(@Param("param") Map<String, Object> param); } snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/mapper/mapping/BlogArticleMapper.xml
@@ -26,9 +26,12 @@ a.is_allowed_comment, a.jump_url as jumpURL, a.update_date, a.create_date a.create_date, a.video_ids, a.picture_ids </sql> <!--首页通用的条件查询--> <sql id="queryListCondition"> <trim prefix="WHERE" prefixOverrides="AND | OR"> a.is_enable=1 @@ -60,6 +63,7 @@ </sql> <!-- 首页查询--> <select id="searchList" resultType="vip.xiaonuo.modular.blogarticle.entity.BlogArticleVo"> select <include refid="Base_Column_List"/> @@ -70,10 +74,6 @@ inner join blog_article_type t on t.id =a.article_type_id left join sys_file_info f1 on f1.id=a.article_file_id left join sys_file_info f2 on f2.id=a.cover_file_id @@ -82,6 +82,7 @@ limit #{param.pageNo},#{param.pageSize} </select> <!-- 首页查询个数统计--> <select id="searchListCount" resultType="java.lang.Long"> select count(0) @@ -91,6 +92,7 @@ </select> <!-- 月份归档统计--> <select id="searchMonthCount" resultType="vip.xiaonuo.modular.blogStatistics.vo.BlogArchiveDetailVo"> SELECT separate_month AS `month`, @@ -110,7 +112,8 @@ </select> <select id="getAdjoiningRecord" resultType="vip.xiaonuo.modular.blogarticle.entity.BlogArticleVo"> <!-- 上下篇查询--> <select id="getAdjoiningRecord" resultType="vip.xiaonuo.modular.blogarticle.entity.BlogArticleVo"> select a.id, a.title @@ -119,4 +122,53 @@ <include refid="queryListCondition"/> limit #{param.pageNo},#{param.pageSize} </select> <sql id="queryPlatformCondition"> <trim prefix="WHERE" prefixOverrides="AND | OR"> a.is_enable=1 and a.editor_status=1 and a.publish_date < now() <if test="param.fileType != null"> and a.article_file_type = #{param.fileType} </if> AND a.article_type_id in <foreach collection="param.typeIds" item="obj" separator="," open="(" close=")"> #{obj} </foreach> order by a.is_top desc,a.top_value asc , a.publish_date desc </trim> </sql> <!--月台列表查询--> <select id="searchPlatformList" resultType="vip.xiaonuo.modular.blogarticle.entity.BlogArticleVo"> select <include refid="Base_Column_List"/> ,IF(a.cover_file_id is not null,CONCAT("/",f2.file_bucket,"/",f2.file_object_name),"") as coverFileURL ,t.type_name as articleTypeName from blog_article a inner join blog_article_type t on t.id =a.article_type_id left join sys_file_info f2 on f2.id=a.cover_file_id <include refid="queryPlatformCondition"/> limit #{param.pageNo},#{param.pageSize} </select> <select id="searchPlatformListCount" resultType="java.lang.Long"> select count(0) from blog_article a <include refid="queryPlatformCondition"/> </select> </mapper> snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/param/BlogArticleQueryDto.java
@@ -30,5 +30,10 @@ */ private Long fileType; /** * 激活查询列 */ private Integer activeKey; } snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/service/BlogArticleService.java
@@ -112,4 +112,8 @@ */ @Async Future<List<BlogArticleVo>> getAdjoiningRecord(BlogArticleQueryDto queryDto); List<BlogArticleVo> searchPlatformList(Map<String, Object> param); long searchPlatformListCount(Map<String, Object> param); } snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/service/impl/BlogArticleServiceImpl.java
@@ -237,4 +237,14 @@ return new AsyncResult<>(result); } @Override public List<BlogArticleVo> searchPlatformList(Map<String, Object> param) { return this.baseMapper.searchPlatformList(param); } @Override public long searchPlatformListCount(Map<String, Object> param) { return this.baseMapper.searchPlatformListCount(param); } } snowy-main/src/main/java/vip/xiaonuo/modular/blogarticletype/mapper/mapping/BlogArticleTypeMapper.xml
@@ -21,6 +21,8 @@ AND a.is_enable = 1 AND a.editor_status = 1 AND t.is_enable = 1 AND a.publish_date < now() GROUP BY t.id ) t2