Jelajahi Sumber

路径修改

wangliang 4 tahun lalu
induk
melakukan
7fe37a64d3

+ 3 - 4
themis-backend/src/main/resources/application.properties

@@ -120,15 +120,14 @@ aliyun.oss.url=http://qmth-test.oss-cn-shenzhen.aliyuncs.com
 #\u7CFB\u7EDF\u914D\u7F6E
 sys.config.oss=false
 sys.config.attachmentType=.xlsx,.xls,.doc,.docx,.pdf,.jpg,.jpeg,.png,.html,.zip
-sys.config.serverUpload=/Users/king/git/themis-server/
+sys.config.serverUpload=/Users/king/git/themis-files/
 #\u7F51\u5173accessKey\u548Csecret,\u6D4B\u8BD5\u7528
 #sys.config.gatewayAccessKey=LTAI4FhEmrrhh27vzPGh25xe
 #sys.config.gatewayAccessSecret=lgnWDUMRAhWBIn4bvAEg2ZC9ECB0Of
 #sys.config.deviceId=1
-sys.config.fileHost=localhost:6001${server.servlet.context-path}
-sys.config.serverHost=localhost:6001${server.servlet.context-path}
+sys.config.fileHost=localhost:6001
+sys.config.serverHost=localhost:6001
 spring.resources.static-locations=file:${sys.config.serverUpload},classpath:/META-INF/resources/,classpath:/resources/
-sys.config.tempDataDir=/home/project/themis/backend/files/
 
 #============================================================================
 # \u914D\u7F6Erocketmq

+ 11 - 6
themis-business/src/main/java/com/qmth/themis/business/constant/SystemConstant.java

@@ -1,6 +1,5 @@
 package com.qmth.themis.business.constant;
 
-import com.qmth.themis.business.config.SystemConfig;
 import com.qmth.themis.common.contanst.Constants;
 import com.qmth.themis.common.enums.Platform;
 import com.qmth.themis.common.enums.Source;
@@ -71,6 +70,7 @@ public class SystemConstant {
     public static final String TXT_PREFIX = ".txt";
     public static final String GLOBAL = "global";
     public static final String OK = "ok";
+    public static String FILES_DIR;
     /**
      * session过期时间
      */
@@ -93,7 +93,7 @@ public class SystemConstant {
     public static final String REDIS_LOCK_STUDENT_PREFIX = "lock:student:student_id_";
     //计算客观分总分锁
     public static final String REDIS_LOCK_TOTAL_OBJECTIVE_SCORE_PREFIX = "lock:total_objective_score:record_id_";
-    
+
     //考试记录数据持久化锁
     public static final String REDIS_LOCK_EXAM_RECORD_PERSISTED_PREFIX = "lock:exam_record_persisted:record_id_";
     /**
@@ -136,7 +136,7 @@ public class SystemConstant {
     public static final String WEBSOCKET_ADMIN_ONLINE_COUNT = "websocket:admin:online:count";
     public static final String GET = "get";
     public static final long WEBSOCKET_MAX_TIME_OUT = 3 * 60 * 1000;
-//    public static final long WEBSOCKET_MAX_TIME_OUT = 1 * 60 * 1000;
+    //    public static final long WEBSOCKET_MAX_TIME_OUT = 1 * 60 * 1000;
     //        public static final long WEBSOCKET_MAX_TIME_OUT = 10 * 1000;
     public static final String ACK_MESSAGE = "ackMessage";
     /**
@@ -240,12 +240,17 @@ public class SystemConstant {
         return map;
     }
 
+    /**
+     * 初始化附件文件路径
+     */
     public static void initTempFiles() {
-        SystemConfig systemConfig = SpringContextHolder.getBean(SystemConfig.class);
-        String tempDir = systemConfig.getProperty("sys.config.tempDataDir");
-        File dir = new File(tempDir);
+        StringJoiner localPath = new StringJoiner("").add(
+                System.getProperty(SystemConstant.USER_DIR));
+        String mkdir = localPath.toString().substring(0, localPath.toString().lastIndexOf(File.separator));
+        File dir = new File(mkdir + File.separator + "themis-files");
         if (!dir.exists()) {
             dir.mkdirs();
         }
+        FILES_DIR = dir.getPath();
     }
 }

+ 1 - 1
themis-business/src/main/java/com/qmth/themis/business/service/impl/TBAttachmentServiceImpl.java

@@ -97,7 +97,7 @@ public class TBAttachmentServiceImpl extends ServiceImpl<TBAttachmentMapper, TBA
 
             boolean oss = (boolean) map.get(SystemConstant.OSS);
             LocalDateTime nowTime = LocalDateTime.now();
-            StringJoiner stringJoiner = new StringJoiner("");
+            StringJoiner stringJoiner = new StringJoiner("").add(SystemConstant.FILES_DIR).add(File.separator);
             String uploadType = String.valueOf(map.get(SystemConstant.UPLOAD_TYPE));
             if (Objects.isNull(uploadType)) {
                 throw new BusinessException(ExceptionResultEnum.ATTACHMENT_TYPE_IS_NULL);

+ 0 - 1
themis-business/src/main/java/com/qmth/themis/business/templete/TaskExportCommon.java

@@ -81,7 +81,6 @@ public class TaskExportCommon {
      * @throws IOException
      */
     public File createExcel(String path) throws IOException {
-        LocalDateTime nowTime = LocalDateTime.now();
         StringJoiner stringJoiner = new StringJoiner("");
         File file = new File(stringJoiner.add(path).add(File.separator).add(String.valueOf(UUID.randomUUID()).replaceAll("-", ""))
                 .add(SystemConstant.EXCEL_PREFIX).toString());

+ 1 - 2
themis-business/src/main/java/com/qmth/themis/business/templete/TaskImportCommon.java

@@ -86,8 +86,7 @@ public class TaskImportCommon {
     public File getUploadFile() {
         File file = null;
         if (Objects.nonNull(this.type) && Objects.equals(this.type, SystemConstant.LOCAL)) {
-            StringJoiner localPath = new StringJoiner("").add(
-                    System.getProperty(SystemConstant.USER_DIR)).add(File.separator).add(this.path);
+            StringJoiner localPath = new StringJoiner("").add(this.path);
             file = new File(localPath.toString());
         } else {
             try {

+ 1 - 1
themis-business/src/main/java/com/qmth/themis/business/templete/impl/TaskRoomCodeExportTemplete.java

@@ -65,7 +65,7 @@ public class TaskRoomCodeExportTemplete implements TaskExportTemplete {
             List<RoomCodeExportDto> roomCodeExportDtoList = tbExamInvigilateUserService.examInvigilateUserExport();
 
             LocalDateTime nowTime = LocalDateTime.now();
-            StringJoiner stringJoiner = new StringJoiner("");
+            StringJoiner stringJoiner = new StringJoiner("").add(SystemConstant.FILES_DIR).add(File.separator);
             String uploadType = String.valueOf(taskExportCommon.getOssEnv().get(SystemConstant.UPLOAD_TYPE));
             stringJoiner.add(uploadType).add(File.separator).add(String.valueOf(nowTime.getYear()))
                     .add(File.separator).add(String.valueOf(nowTime.getMonthValue()))

+ 5 - 4
themis-exam/src/main/java/com/qmth/themis/exam/api/SysController.java

@@ -21,10 +21,11 @@ public class SysController {
     @ApiOperation(value = "获取环境接口")
     @RequestMapping(value = "/env", method = RequestMethod.GET)
     @ApiResponses({@ApiResponse(code = 200, message = "环境信息", response = Result.class)})
-    public Result env(@ApiParam(value = "机构id", required = true) @RequestParam Long orgId) {
-        if (Objects.isNull(orgId) || Objects.equals(orgId, "")) {
-            throw new BusinessException(ExceptionResultEnum.ORG_ID_IS_NULL);
-        }
+    public Result env(@ApiParam(value = "机构id", required = false) @RequestParam(required = false) Long orgId) {
+
+//        if (Objects.isNull(orgId) || Objects.equals(orgId, "")) {
+//            throw new BusinessException(ExceptionResultEnum.ORG_ID_IS_NULL);
+//        }
 //        SchoolDto schoolDto = (SchoolDto) redisTemplate.opsForValue().get(SystemConstant.SCHOOL_CACHE + orgId);
 //        Map map = new HashMap();
 //        map.put(SystemConstant.ENV_FILEHOST, schoolDto.getFileHost());

+ 3 - 3
themis-exam/src/main/resources/application.properties

@@ -132,14 +132,14 @@ aliyun.oss.url=http://qmth-test.oss-cn-shenzhen.aliyuncs.com
 #\u7CFB\u7EDF\u914D\u7F6E
 sys.config.oss=false
 sys.config.attachmentType=.xlsx,.xls,.doc,.docx,.pdf,.jpg,.jpeg,.png,.html,.zip
-sys.config.serverUpload=/Users/king/git/themis-server/
+sys.config.serverUpload=/Users/king/git/themis-files/
 #sys.config.serverUpload=/Users/king/git/themis-service/
 #\u7F51\u5173accessKey\u548Csecret,\u6D4B\u8BD5\u7528
 #sys.config.gatewayAccessKey=LTAI4FhEmrrhh27vzPGh25xe
 #sys.config.gatewayAccessSecret=lgnWDUMRAhWBIn4bvAEg2ZC9ECB0Of
 #sys.config.deviceId=1
-sys.config.fileHost=localhost:6002${server.servlet.context-path}
-sys.config.serverHost=localhost:6002${server.servlet.context-path}
+sys.config.fileHost=localhost:6002
+sys.config.serverHost=localhost:6002
 sys.config.tempDataDir=/home/project/themis/exam/files/
 spring.resources.static-locations=file:${sys.config.serverUpload},classpath:/META-INF/resources/,classpath:/resources/
 

+ 1 - 1
themis-task/src/main/resources/application.properties

@@ -96,7 +96,7 @@ spring.jackson.time-zone=GMT+8
 #\u7CFB\u7EDF\u914D\u7F6E
 sys.config.oss=false
 sys.config.attachmentType=.xlsx,.xls,.doc,.docx,.pdf,.jpg,.jpeg,.png,.html,.zip
-sys.config.serverUpload=/Users/king/git/themis-server/
+sys.config.serverUpload=/Users/king/git/themis-files/
 spring.resources.static-locations=file:${sys.config.serverUpload},classpath:/META-INF/resources/,classpath:/resources/
 
 #\u963F\u91CC\u4E91OSS\u914D\u7F6E