mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-06-27 15:42:41 +08:00
课程附件-资源上传及查询改造
This commit is contained in:
parent
1edc205e9f
commit
295992e4d4
@ -35,6 +35,10 @@ public class BackendConstant {
|
||||
public static final String RESOURCE_TYPE_PDF = "PDF";
|
||||
public static final String RESOURCE_TYPE_WORD = "WORD";
|
||||
public static final String RESOURCE_TYPE_PPT = "PPT";
|
||||
public static final String RESOURCE_TYPE_EXCEL = "EXCEL";
|
||||
public static final String RESOURCE_TYPE_ZIP= "ZIP";
|
||||
public static final String RESOURCE_TYPE_RAR = "RAR";
|
||||
public static final String RESOURCE_TYPE_TXT = "TXT";
|
||||
|
||||
public static final HashMap<String, String> RESOURCE_EXT_2_CONTENT_TYPE =
|
||||
new HashMap<>() {
|
||||
@ -46,13 +50,14 @@ public class BackendConstant {
|
||||
put("pdf", "application/pdf");
|
||||
put("mp4", "video/mp4");
|
||||
put("doc", "application/msword");
|
||||
put(
|
||||
"docx",
|
||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.document");
|
||||
put("docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
|
||||
put("ppt", "application/vnd.ms-powerpoint");
|
||||
put(
|
||||
"pptx",
|
||||
"application/vnd.openxmlformats-officedocument.presentationml.presentation");
|
||||
put("pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation");
|
||||
put("xls", "application/vnd.ms-excel");
|
||||
put("xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
put("txt", "text/plain");
|
||||
put("zip", "application/zip");
|
||||
put("rar", "application/x-rar");
|
||||
}
|
||||
};
|
||||
public static final HashMap<String, String> RESOURCE_EXT_2_TYPE =
|
||||
@ -68,6 +73,11 @@ public class BackendConstant {
|
||||
put("docx", RESOURCE_TYPE_WORD);
|
||||
put("ppt", RESOURCE_TYPE_PPT);
|
||||
put("pptx", RESOURCE_TYPE_PPT);
|
||||
put("xls", RESOURCE_TYPE_EXCEL);
|
||||
put("xlsx", RESOURCE_TYPE_EXCEL);
|
||||
put("txt", RESOURCE_TYPE_TXT);
|
||||
put("zip", RESOURCE_TYPE_ZIP);
|
||||
put("rar", RESOURCE_TYPE_RAR);
|
||||
}
|
||||
};
|
||||
public static final HashMap<String, String> RESOURCE_TYPE_2_DIR =
|
||||
@ -78,6 +88,10 @@ public class BackendConstant {
|
||||
put(RESOURCE_TYPE_PDF, UPLOAD_PDF_DIR);
|
||||
put(RESOURCE_TYPE_WORD, UPLOAD_WORD_DIR);
|
||||
put(RESOURCE_TYPE_PPT, UPLOAD_PPT_DIR);
|
||||
put(RESOURCE_TYPE_EXCEL, UPLOAD_EXCEL_DIR);
|
||||
put(RESOURCE_TYPE_TXT, UPLOAD_TXT_DIR);
|
||||
put(RESOURCE_TYPE_ZIP, UPLOAD_ZIP_DIR);
|
||||
put(RESOURCE_TYPE_RAR, UPLOAD_RAR_DIR);
|
||||
}
|
||||
};
|
||||
|
||||
@ -91,6 +105,10 @@ public class BackendConstant {
|
||||
public static final String UPLOAD_PDF_DIR = "pdf/";
|
||||
public static final String UPLOAD_WORD_DIR = "word/";
|
||||
public static final String UPLOAD_PPT_DIR = "word/";
|
||||
public static final String UPLOAD_EXCEL_DIR = "excel/";
|
||||
public static final String UPLOAD_TXT_DIR = "txt/";
|
||||
public static final String UPLOAD_ZIP_DIR = "zip/";
|
||||
public static final String UPLOAD_RAR_DIR = "rar/";
|
||||
|
||||
public static final String PRIVACY_FIELD_TYPE_EMAIL = "email";
|
||||
public static final String PRIVACY_FIELD_TYPE_PHONE = "phone";
|
||||
|
@ -27,7 +27,7 @@ import xyz.playedu.api.BCtx;
|
||||
import xyz.playedu.api.constant.BackendConstant;
|
||||
import xyz.playedu.api.domain.Resource;
|
||||
import xyz.playedu.api.exception.ServiceException;
|
||||
import xyz.playedu.api.request.backend.UploadVideoMergeRequest;
|
||||
import xyz.playedu.api.request.backend.UploadFileMergeRequest;
|
||||
import xyz.playedu.api.service.MinioService;
|
||||
import xyz.playedu.api.service.ResourceService;
|
||||
import xyz.playedu.api.service.UploadService;
|
||||
@ -92,8 +92,8 @@ public class UploadController {
|
||||
return JsonResponse.data(data);
|
||||
}
|
||||
|
||||
@PostMapping("/minio/merge-video")
|
||||
public JsonResponse minioMergeVideo(@RequestBody @Validated UploadVideoMergeRequest req)
|
||||
@PostMapping("/minio/merge-file")
|
||||
public JsonResponse minioMergeFile(@RequestBody @Validated UploadFileMergeRequest req)
|
||||
throws ServiceException {
|
||||
String type = BackendConstant.RESOURCE_EXT_2_TYPE.get(req.getExtension());
|
||||
if (type == null) {
|
||||
@ -102,10 +102,10 @@ public class UploadController {
|
||||
String extension = req.getExtension();
|
||||
String originalFilename = req.getOriginalFilename().replaceAll("(?i)." + extension, "");
|
||||
|
||||
// 合并视频文件
|
||||
// 合并资源文件
|
||||
String url = minioService.merge(req.getFilename(), req.getUploadId());
|
||||
|
||||
// 视频素材保存
|
||||
// 资源素材保存
|
||||
Resource videoResource =
|
||||
resourceService.create(
|
||||
BCtx.getId(),
|
||||
@ -118,14 +118,16 @@ public class UploadController {
|
||||
"",
|
||||
req.getFilename(),
|
||||
url);
|
||||
// 视频封面素材保存
|
||||
Resource posterResource =
|
||||
uploadService.storeBase64Image(BCtx.getId(), req.getPoster(), null);
|
||||
// 视频的封面素材改为[隐藏 && 属于视频的子素材]
|
||||
resourceService.changeParentId(posterResource.getId(), videoResource.getId());
|
||||
// 视频信息
|
||||
resourceService.storeResourceVideo(
|
||||
videoResource.getId(), req.getDuration(), posterResource.getUrl());
|
||||
|
||||
// 视频资源特殊处理--视频封面资源
|
||||
if(BackendConstant.RESOURCE_TYPE_VIDEO.equals(type)){
|
||||
// 视频封面素材保存
|
||||
Resource posterResource = uploadService.storeBase64Image(BCtx.getId(), req.getPoster(), null);
|
||||
// 视频的封面素材改为[隐藏 && 属于视频的子素材]
|
||||
resourceService.changeParentId(posterResource.getId(), videoResource.getId());
|
||||
// 视频信息
|
||||
resourceService.storeResourceVideo(videoResource.getId(), req.getDuration(), posterResource.getUrl());
|
||||
}
|
||||
|
||||
HashMap<String, Object> data = new HashMap<>();
|
||||
data.put("url", url);
|
||||
|
@ -28,7 +28,7 @@ import lombok.Data;
|
||||
* @create 2023/3/8 14:49
|
||||
*/
|
||||
@Data
|
||||
public class UploadVideoMergeRequest {
|
||||
public class UploadFileMergeRequest {
|
||||
|
||||
@NotBlank(message = "请输入课程标题")
|
||||
private String filename;
|
@ -61,7 +61,10 @@
|
||||
AND `resources`.`extension` = #{extension}
|
||||
</if>
|
||||
<if test="type != null and type != ''">
|
||||
AND `resources`.`type` = #{type}
|
||||
AND `resources`.`type` IN
|
||||
<foreach item="item" collection="type.split(',')" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="adminId != null and adminId != 0">
|
||||
AND `resources`.`admin_id` = #{adminId}
|
||||
@ -127,7 +130,10 @@
|
||||
AND `resources`.`extension` = #{extension}
|
||||
</if>
|
||||
<if test="type != null and type != ''">
|
||||
AND `resources`.`type` = #{type}
|
||||
AND `resources`.`type` IN
|
||||
<foreach item="item" collection="type.split(',')" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="adminId != null and adminId != 0">
|
||||
AND `resources`.`admin_id` = #{adminId}
|
||||
|
Loading…
x
Reference in New Issue
Block a user