| | |
| | | package vip.xiaonuo.core.consts; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import static vip.xiaonuo.core.consts.MyConstant.FileType.fileTypeMp3_4; |
| | | import static vip.xiaonuo.core.consts.MyConstant.FileType.fileTypeVideo_3; |
| | | |
| | | public interface MyConstant { |
| | | Integer No = 0; |
| | |
| | | * 月台类型分类,暂时不考虑加入数据库 |
| | | */ |
| | | interface platformType { |
| | | int type_1 = 1;//片刻 |
| | | int type_2 = 2;//流影 |
| | | int type_3 = 3;//谱库 |
| | | String type_1 = "moment";//片刻 |
| | | String type_2 = "flash";//流影 |
| | | String type_3 = "store";//谱库 |
| | | } |
| | | |
| | | /** |
| | | * 首页排除文件类型id |
| | | */ |
| | | List<Integer> faceExcludeFile = new ArrayList() {{ |
| | | add(fileTypeVideo_3); |
| | | add(fileTypeMp3_4); |
| | | }}; |
| | | |
| | | /** |
| | | * 文件类型 |
| | | * 文件类型(日志主要呈现类型方式) |
| | | * 1.markdown(日志类型的一种) |
| | | * 2.html(日志类型的第二种,预留) |
| | | * 3.video(视频,也可以是音频类型) |
| | | * 4.mp3(预留) |
| | | * 5.pictures(图组,谱子等) |
| | | * 9.talking(说说,仅显示扼要,可以加表情) |
| | | */ |
| | | interface FileType { |
| | | Integer fileTypeMarkDown_1 = 1; |
| | | Integer fileTypeHtml_2 = 2; |
| | | Integer fileTypeVideo_3 = 3; |
| | | Integer fileTypeMp3_4 = 4; |
| | | Integer fileTypeShort_5 = 5; |
| | | Integer fileTypePhoto_9 = 9; |
| | | Integer fileTypePictures_5 = 5; |
| | | Integer fileTypeTalking_9 = 9; |
| | | } |
| | | |
| | | List<Integer> FileTypeList = new ArrayList(5) {{ |
| | | add(FileType.fileTypeMarkDown_1); |
| | | add(FileType.fileTypeHtml_2); |
| | | add(FileType.fileTypeVideo_3); |
| | | add(fileTypeVideo_3); |
| | | add(FileType.fileTypeMp3_4); |
| | | add(FileType.fileTypeShort_5); |
| | | add(FileType.fileTypePhoto_9); |
| | | add(FileType.fileTypePictures_5); |
| | | add(FileType.fileTypeTalking_9); |
| | | }}; |
| | | |
| | | //存储文件夹映射 |
| | | /** |
| | | * 存储文件夹映射(bucket) |
| | | * article(mark,html等文件) |
| | | * mp4(视频资源) |
| | | * mp3(音频资源) |
| | | * cover(封面) |
| | | * picture(文章引用图库) |
| | | */ |
| | | String bucket_article = "article"; |
| | | String bucket_video = "mp4"; |
| | | String bucket_mp3 = "mp3"; |
| | | String bucket_cover = "cover"; |
| | | String bucket_picture = "picture"; |
| | | |
| | | Map<Integer, String> uploadFileBucketMap = new HashMap(5) {{ |
| | | put(FileType.fileTypeMarkDown_1, bucket_article); |
| | | put(FileType.fileTypeHtml_2, bucket_article); |
| | | put(FileType.fileTypeVideo_3, bucket_video); |
| | | put(FileType.fileTypeMp3_4, bucket_mp3); |
| | | put(FileType.fileTypePhoto_9, bucket_cover); |
| | | List<String> uploadFileBucketList = new ArrayList(5) {{ |
| | | add(bucket_article); |
| | | add(bucket_video); |
| | | add(bucket_mp3); |
| | | add(bucket_picture); |
| | | add(bucket_cover); |
| | | }}; |
| | | |
| | | |
| | |
| | | import javax.validation.constraints.NotEmpty; |
| | | import javax.validation.constraints.NotNull; |
| | | |
| | | import static vip.xiaonuo.sys.config.FileConfig.DEFAULT_BUCKET; |
| | | |
| | | /** |
| | | * blog文件控制器 (提供给外部blog系统查询) |
| | | * |
| | |
| | | @PostMapping("/sysFileInfo/upload") |
| | | @BusinessLog(title = "文件信息表_上传文件", opType = LogAnnotionOpTypeEnum.OTHER) |
| | | public ResponseData upload(@RequestPart("file") MultipartFile file, |
| | | @NotNull @RequestParam Integer fileType, |
| | | @NotNull @RequestParam String bucketName, |
| | | @NotEmpty @RequestParam String authCode) { |
| | | if (!MyConstant.FileTypeList.contains(fileType)) { |
| | | throw new BlogException("错误文件类型"); |
| | | } |
| | | |
| | | if (StrUtil.isEmpty(authCode) || !authCode.equals(ConstantContextHolder.getPushCode())) { |
| | | throw new BlogException("授权码错误"); |
| | | } |
| | | |
| | | String bucket = MyConstant.uploadFileBucketMap.getOrDefault(fileType, DEFAULT_BUCKET); |
| | | if (!MyConstant.uploadFileBucketList.contains(bucketName)) { |
| | | throw new BlogException("错误bucket名称"); |
| | | } |
| | | |
| | | Long fileId = fileInfoService.uploadFileBlog(file, bucket); |
| | | Long fileId = fileInfoService.uploadFileBlog(file, bucketName); |
| | | |
| | | return new SuccessResponseData(fileId); |
| | | } |
| | |
| | | param.put("pageSize", queryDto.getPageSize()); |
| | | param.put("typeId", queryDto.getTypeId()); |
| | | param.put("fileType", queryDto.getFileType()); |
| | | param.put("faceExcludeFile", MyConstant.faceExcludeFile); |
| | | |
| | | String blogSourcePrefix = ConstantContextHolder.getBlogSourcePrefix(); |
| | | |
| | |
| | | Map<String, Object> param = new HashMap<>(16); |
| | | param.put("pageNo", PageUtil.getStart(queryDto.getPageNo() - 1, queryDto.getPageSize())); |
| | | param.put("pageSize", queryDto.getPageSize()); |
| | | param.put("id", queryDto.getId()); |
| | | |
| | | if (queryDto.getActiveKey().equals(MyConstant.platformType.type_2)) { |
| | | param.put("typeIds", new Long[]{10L});//临时id,后续需要修改(前方高能分类) |
| | | if (queryDto.getActiveKey().equals(MyConstant.platformType.type_1)) { |
| | | param.put("typeIds", new Long[]{66L});//临时id |
| | | param.put("fileType", MyConstant.FileType.fileTypeVideo_3); |
| | | } else if (queryDto.getActiveKey().equals(MyConstant.platformType.type_2)) { |
| | | param.put("typeIds", new Long[]{55L});//临时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); |
| | | param.put("typeIds", new Long[]{99L});//临时id,后续需要修改(图组) |
| | | param.put("fileType", MyConstant.FileType.fileTypePictures_5); |
| | | } else { |
| | | param.put("typeIds", new Long[]{4L});//临时id,后续需要修改(音乐分类) |
| | | param.put("typeIds", new Long[]{66L});//临时id,后续需要修改(音乐分类) |
| | | param.put("fileType", MyConstant.FileType.fileTypeVideo_3); |
| | | } |
| | | |
| | |
| | | |
| | | BeanUtil.copyProperties(find, vo); |
| | | |
| | | //补充视频组,图片组的url |
| | | if (StrUtil.isNotEmpty(vo.getPictureIds())) { |
| | | vo.setPictureUrlList(this.getBlogSourceURLBatch(Arrays.stream(vo.getPictureIds().split(SymbolConstant.COMMA)).collect(Collectors.toList()))); |
| | | } |
| | | if (StrUtil.isNotEmpty(vo.getVideoIds())) { |
| | | vo.setVideoUrlList(this.getBlogSourceURLBatch(Arrays.stream(vo.getVideoIds().split(SymbolConstant.COMMA)).collect(Collectors.toList()))); |
| | | } |
| | | |
| | | |
| | | String tempURL = this.getBlogSourceURL(find.getArticleFileId()); |
| | | |
| | |
| | | and a.editor_status=1 |
| | | and a.publish_date < now() |
| | | <choose> |
| | | <!-- 月台查询用 --> |
| | | <when test="param.fileType != null"> |
| | | and a.article_file_type = #{param.fileType} |
| | | </when> |
| | | <!-- 指定排除 视频类在首页显示,但需要在分类栏目列表显示 --> |
| | | <when test="param.fileType == null and param.typeId == null"> |
| | | and a.article_file_type not in (3,4) |
| | | </when> |
| | | </choose> |
| | | <choose> |
| | | <when test="param.typeId != null"> |
| | | AND a.article_type_id = #{param.typeId} |
| | | order by a.is_top desc,a.top_value asc , a.publish_date desc |
| | | </when> |
| | | |
| | | <!-- 指定排除 笔记类在首页显示 --> |
| | | <otherwise> |
| | | AND a.article_type_id != 4 |
| | | <!-- 首页不出现视频等文件类型--> |
| | | <if test="param.faceExcludeFile != null"> |
| | | and a.article_file_type not in |
| | | <foreach collection="param.faceExcludeFile" item="obj" separator="," open="(" close=")"> |
| | | #{obj} |
| | | </foreach> |
| | | </if> |
| | | order by a.is_top desc,a.top_value asc , a.update_date desc |
| | | </otherwise> |
| | | </choose> |
| | |
| | | blog_article a |
| | | inner join blog_article_type t |
| | | on t.id =a.article_type_id |
| | | |
| | | <!-- 排除首页不查询的分类--> |
| | | <if test="param.typeId == null"> |
| | | and t.is_show_face = 1 |
| | | </if> |
| | | |
| | | left join sys_file_info f2 |
| | | on f2.id=a.cover_file_id |
| | |
| | | and a.editor_status=1 |
| | | and a.publish_date < now() |
| | | |
| | | <if test="param.id != null"> |
| | | and a.id = #{param.id} |
| | | </if> |
| | | |
| | | <if test="param.fileType != null"> |
| | | and a.article_file_type = #{param.fileType} |
| | | </if> |
| | |
| | | /** |
| | | * 激活查询列 |
| | | */ |
| | | private Integer activeKey; |
| | | private String activeKey; |
| | | |
| | | |
| | | } |