Browse Source

新建保存图片目录

zhuoning 4 năm trước cách đây
mục cha
commit
e7d0453a15

+ 73 - 0
huimv-video/huimv-video-manager/src/main/java/com/huimv/manager/dao/entity/ImageCatalogEntity.java

@@ -0,0 +1,73 @@
+package com.huimv.manager.dao.entity;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+@Entity
+@Table(name = "image_catalog")
+public class ImageCatalogEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id", nullable = false)
+    private Integer id;
+
+    /**
+     * 目录名称
+     */
+    @Column(name = "catalog_name")
+    private String catalogName;
+
+    /**
+     * 目录路径
+     */
+    @Column(name = "catalog_path")
+    private String catalogPath;
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    /**
+     * 目录名称
+     */
+    public void setCatalogName(String catalogName) {
+        this.catalogName = catalogName;
+    }
+
+    /**
+     * 目录名称
+     */
+    public String getCatalogName() {
+        return catalogName;
+    }
+
+    /**
+     * 目录路径
+     */
+    public void setCatalogPath(String catalogPath) {
+        this.catalogPath = catalogPath;
+    }
+
+    /**
+     * 目录路径
+     */
+    public String getCatalogPath() {
+        return catalogPath;
+    }
+
+    @Override
+    public String toString() {
+        return "ImageCatalogEntity{" +
+                "id=" + id + '\'' +
+                "catalogName=" + catalogName + '\'' +
+                "catalogPath=" + catalogPath + '\'' +
+                '}';
+    }
+}

+ 9 - 0
huimv-video/huimv-video-manager/src/main/java/com/huimv/manager/dao/repo/ImageCatalogEntityRepository.java

@@ -0,0 +1,9 @@
+package com.huimv.manager.dao.repo;
+
+import com.huimv.manager.dao.entity.ImageCatalogEntity;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+public interface ImageCatalogEntityRepository extends JpaRepository<ImageCatalogEntity, Integer>, JpaSpecificationExecutor<ImageCatalogEntity> {
+
+}

+ 73 - 0
huimv-video/huimv-video-process/src/main/java/com/huimv/process/dao/entity/ImageCatalogEntity.java

@@ -0,0 +1,73 @@
+package com.huimv.process.dao.entity;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+@Entity
+@Table(name = "image_catalog")
+public class ImageCatalogEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id", nullable = false)
+    private Integer id;
+
+    /**
+     * 目录名称
+     */
+    @Column(name = "catalog_name")
+    private String catalogName;
+
+    /**
+     * 目录路径
+     */
+    @Column(name = "catalog_path")
+    private String catalogPath;
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    /**
+     * 目录名称
+     */
+    public void setCatalogName(String catalogName) {
+        this.catalogName = catalogName;
+    }
+
+    /**
+     * 目录名称
+     */
+    public String getCatalogName() {
+        return catalogName;
+    }
+
+    /**
+     * 目录路径
+     */
+    public void setCatalogPath(String catalogPath) {
+        this.catalogPath = catalogPath;
+    }
+
+    /**
+     * 目录路径
+     */
+    public String getCatalogPath() {
+        return catalogPath;
+    }
+
+    @Override
+    public String toString() {
+        return "ImageCatalogEntity{" +
+                "id=" + id + '\'' +
+                "catalogName=" + catalogName + '\'' +
+                "catalogPath=" + catalogPath + '\'' +
+                '}';
+    }
+}

+ 9 - 0
huimv-video/huimv-video-process/src/main/java/com/huimv/process/dao/repo/ImageCatalogRepo.java

@@ -0,0 +1,9 @@
+package com.huimv.process.dao.repo;
+
+import com.huimv.process.dao.entity.ImageCatalogEntity;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+public interface ImageCatalogRepo extends JpaRepository<ImageCatalogEntity, Integer>, JpaSpecificationExecutor<ImageCatalogEntity> {
+
+}

+ 11 - 2
huimv-video/huimv-video-process/src/main/java/com/huimv/process/service/impl/ImageServiceImpl.java

@@ -1,7 +1,9 @@
 package com.huimv.process.service.impl;
 
 import com.alibaba.fastjson.JSONObject;
+import com.huimv.process.dao.entity.ImageCatalogEntity;
 import com.huimv.process.dao.entity.ImagePathEntity;
+import com.huimv.process.dao.repo.ImageCatalogRepo;
 import com.huimv.process.dao.repo.ImagePathEntityRepository;
 import com.huimv.process.service.IImageService;
 import com.huimv.process.utils.PictureUtil;
@@ -38,6 +40,8 @@ public class ImageServiceImpl implements IImageService {
     private RestTemplate restTemplate;
     @Autowired
     private com.huimv.process.utils.utils utils;
+    @Autowired
+    private ImageCatalogRepo imageCatalogRepo;
 
     /**
      * @Method : saveImage
@@ -56,10 +60,10 @@ public class ImageServiceImpl implements IImageService {
         String userDir = System.getProperty("user.dir");
         if (os.toLowerCase().indexOf("windows") != -1) {
             // Windows
-            uploadPath = "\\" + uploadPath + "\\";
+            uploadPath = "\\" + uploadPath + "\\"+name+"\\";
         } else {
             // Linux
-            uploadPath = "/" + uploadPath + "/";
+            uploadPath = "/" + uploadPath + "/"+name+"/";
         }
         // 时间戳
         long timeMillis = System.currentTimeMillis();
@@ -67,6 +71,11 @@ public class ImageServiceImpl implements IImageService {
         File dir = new File(uploadPath);
         if (!dir.exists()) { // && dir.isDirectory()
             dir.mkdirs();
+            // 目录入库
+            ImageCatalogEntity imageCatalogEntity = new ImageCatalogEntity();
+            imageCatalogEntity.setCatalogName(name);
+            imageCatalogEntity.setCatalogPath(name);
+            imageCatalogRepo.saveAndFlush(imageCatalogEntity);
         }
         // type1
 //        String imgPath = uploadPath + name + "_"+ timeMillis + ".jpg";

+ 5 - 0
huimv-video/pom.xml

@@ -80,6 +80,11 @@
 <!--            <version>1.0</version>-->
 <!--            <scope>compile</scope>-->
 <!--        </dependency>-->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>