|
|
@@ -0,0 +1,84 @@
|
|
|
+import cn.reghao.dfs.store.DfsStoreApplication;
|
|
|
+import cn.reghao.dfs.store.db.mapper.*;
|
|
|
+import cn.reghao.dfs.store.model.po.*;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.junit.Test;
|
|
|
+import org.junit.runner.RunWith;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.boot.test.context.SpringBootTest;
|
|
|
+import org.springframework.test.context.ActiveProfiles;
|
|
|
+import org.springframework.test.context.junit4.SpringRunner;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author reghao
|
|
|
+ * @date 2023-03-22 16:19:12
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@ActiveProfiles("dev")
|
|
|
+@SpringBootTest(classes = DfsStoreApplication.class)
|
|
|
+@RunWith(SpringRunner.class)
|
|
|
+public class MediaFileTest {
|
|
|
+ @Autowired
|
|
|
+ VideoFileMapper videoFileMapper;
|
|
|
+ @Autowired
|
|
|
+ VideoUrlMapper videoUrlMapper;
|
|
|
+ @Autowired
|
|
|
+ FileMetaMapper fileMetaMapper;
|
|
|
+
|
|
|
+ public void mediaTest() {
|
|
|
+ videoUrlTest();
|
|
|
+ log.info("------------------------------------------------------------");
|
|
|
+ imageFileTest();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void videoUrlTest() {
|
|
|
+ List<VideoUrl> list = videoUrlMapper.findAll();
|
|
|
+ for (VideoUrl videoUrl : list) {
|
|
|
+ process(videoUrl);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void process(VideoUrl videoUrl) {
|
|
|
+ String videoFileId = videoUrl.getVideoFileId();
|
|
|
+ VideoFile videoFile = videoFileMapper.findByVideoFileId(videoFileId);
|
|
|
+ if (videoFile == null) {
|
|
|
+ log.error("videoFileId {} not exist in video_file", videoFileId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ String objectId = videoUrl.getObjectId();
|
|
|
+ FileMeta fileMeta = fileMetaMapper.findByObjectId(objectId);
|
|
|
+ if (fileMeta == null) {
|
|
|
+ log.error("objectId {} not exist in file_meta", objectId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ImageFileMapper imageFileMapper;
|
|
|
+ @Test
|
|
|
+ public void imageFileTest() {
|
|
|
+ List<ImageFile> list = imageFileMapper.findAll();
|
|
|
+ for (ImageFile imageFile : list) {
|
|
|
+ process(imageFile);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void process(ImageFile imageFile) {
|
|
|
+ String jpegObjectId = imageFile.getJpegObjectId();
|
|
|
+ FileMeta fileMeta = fileMetaMapper.findByObjectId(jpegObjectId);
|
|
|
+ if (fileMeta == null) {
|
|
|
+ log.error("jpegObjectId {} not exist in file_meta", jpegObjectId);
|
|
|
+ }
|
|
|
+
|
|
|
+ String webpObjectId = imageFile.getWebpObjectId();
|
|
|
+ if (webpObjectId != null) {
|
|
|
+ FileMeta fileMeta1 = fileMetaMapper.findByObjectId(webpObjectId);
|
|
|
+ if (fileMeta1 == null) {
|
|
|
+ log.error("webpObjectId {} not exist in file_meta", webpObjectId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|