Ver Fonte

upgrade to qmth-boot 1.0.6

deason há 1 mês atrás
pai
commit
9a6f76aa8d

+ 1 - 1
pom.xml

@@ -23,7 +23,7 @@
         <maven.compiler.target>1.8</maven.compiler.target>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
-        <qmth-boot-version>1.0.4</qmth-boot-version>
+        <qmth-boot-version>1.0.6</qmth-boot-version>
     </properties>
 
     <repositories>

+ 0 - 29
src/main/java/com/qmth/exam/reserve/config/FileStoreConfig.java

@@ -1,29 +0,0 @@
-package com.qmth.exam.reserve.config;
-
-import com.qmth.boot.core.fss.config.FileStoreProperty;
-import com.qmth.boot.core.fss.service.FileService;
-import com.qmth.boot.core.fss.service.impl.DefaultFileService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-@Configuration
-public class FileStoreConfig {
-
-    @Autowired
-    private SysProperty sysProperty;
-
-    @Bean("fileService")
-    public FileService fileService() {
-        FileStoreProperty property = new FileStoreProperty();
-        property.setConfig(sysProperty.getConfig());
-        property.setServer(sysProperty.getServer());
-        Map<String,FileStoreProperty> map = new HashMap<>();
-        map.put("com.qmth.fss", property);
-        return new DefaultFileService(map);
-    }
-}

+ 1 - 1
src/main/java/com/qmth/exam/reserve/controller/admin/StudentApplyController.java

@@ -186,7 +186,7 @@ public class StudentApplyController extends BaseController {
             exportList.add(firstLineContents);
             List<String[]> avaiableList = studentApplyService.listExamSiteAvailable(examSiteList);
             exportList.addAll(avaiableList);
-            writer.writeDataArrays("考点预约情况表", null, columnNames, exportList.iterator());
+            writer.writeStringArrays("考点预约情况表", null, columnNames, exportList.iterator());
             writer.output(response.getOutputStream());
         } catch (IOException e) {
             throw new StatusException(e.getMessage());

+ 1 - 2
src/main/java/com/qmth/exam/reserve/service/FileUploadService.java

@@ -6,7 +6,6 @@ public interface FileUploadService {
 
     void uploadFile(String dirName, File file);
 
-    String uploadByText(String dirName, String text, String fileName);
-
     File downloadFile(String path, File localFile);
+
 }

+ 9 - 32
src/main/java/com/qmth/exam/reserve/service/impl/FileUploadServiceImpl.java

@@ -1,21 +1,17 @@
 package com.qmth.exam.reserve.service.impl;
 
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.time.Duration;
-
+import com.qmth.boot.core.fss.store.FileStore;
+import com.qmth.boot.tools.models.ByteArray;
+import com.qmth.exam.reserve.service.FileUploadService;
 import org.apache.commons.io.FileUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import com.qmth.boot.core.fss.store.impl.OssStore;
-import com.qmth.boot.tools.models.ByteArray;
-import com.qmth.exam.reserve.config.SysProperty;
-import com.qmth.exam.reserve.service.FileUploadService;
+import java.io.File;
+import java.io.InputStream;
+import java.nio.file.Files;
 
 @Service
 public class FileUploadServiceImpl implements FileUploadService {
@@ -23,40 +19,21 @@ public class FileUploadServiceImpl implements FileUploadService {
     private final static Logger log = LoggerFactory.getLogger(FileUploadServiceImpl.class);
 
     @Autowired
-    private SysProperty sysProperty;
+    private FileStore fileStore;
 
     @Override
     public void uploadFile(String dirName, File file) {
         try {
-            OssStore store = new OssStore(sysProperty.getServer(), sysProperty.getConfig());
-            store.write(dirName, Files.newInputStream(file.toPath()), ByteArray.md5(file).toHexString());
-            store.close();
-        } catch (Exception e) {
-            log.warn("文件上传出错", e);
-        }
-    }
-
-    @Override
-    public String uploadByText(String dirName, String text, String fileName) {
-        try {
-            OssStore store = new OssStore(sysProperty.getServer(), sysProperty.getConfig());
-            String filePath = dirName + "/" + fileName;
-            ByteArray data = ByteArray.fromString(text);
-            store.write(filePath, new ByteArrayInputStream(data.value()), ByteArray.md5(data.value()).toHexString());
-            String url = store.getPresignedUrl(filePath, Duration.ofMinutes(5));
-            store.close();
-            return url;
+            fileStore.write(dirName, Files.newInputStream(file.toPath()), ByteArray.md5(file).toHexString());
         } catch (Exception e) {
             log.warn("文件上传出错", e);
         }
-        return null;
     }
 
     @Override
     public File downloadFile(String path, File localFile) {
         try {
-            OssStore store = new OssStore(sysProperty.getServer(), sysProperty.getConfig());
-            InputStream inputStream = store.read(path);
+            InputStream inputStream = fileStore.read(path);
             FileUtils.copyInputStreamToFile(inputStream, localFile);
         } catch (Exception e) {
             log.warn("下载文件出错", e);