Browse Source

新增客户端和移动端版本号

wangliang 4 years ago
parent
commit
a6e57dce12

+ 0 - 2
themis-admin/src/main/java/com/qmth/themis/admin/api/TBAppVersionController.java

@@ -1,6 +1,5 @@
 package com.qmth.themis.admin.api;
 
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.entity.TBAppVersion;
@@ -36,7 +35,6 @@ public class TBAppVersionController {
     @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
     public Result save(@ApiParam(value = "移动端版本信息", required = true) @RequestBody TBAppVersion tbAppVersion) {
         tbAppVersionService.saveOrUpdate(tbAppVersion);
-        QueryWrapper<TBAppVersion> tbAppVersionQueryWrapper = new QueryWrapper<>();
         return ResultUtil.ok(Collections.singletonMap(SystemConstant.SUCCESS, true));
     }
 

+ 52 - 0
themis-admin/src/main/java/com/qmth/themis/admin/api/TBClientVersionController.java

@@ -2,17 +2,29 @@ package com.qmth.themis.admin.api;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.qmth.themis.business.constant.SystemConstant;
+import com.qmth.themis.business.entity.TBAttachment;
 import com.qmth.themis.business.entity.TBClientVersion;
+import com.qmth.themis.business.entity.TBUser;
+import com.qmth.themis.business.enums.UploadFileEnum;
+import com.qmth.themis.business.service.TBAttachmentService;
 import com.qmth.themis.business.service.TBClientVersionService;
+import com.qmth.themis.business.util.OssUtil;
+import com.qmth.themis.business.util.ServletUtil;
+import com.qmth.themis.common.enums.ExceptionResultEnum;
+import com.qmth.themis.common.exception.BusinessException;
 import com.qmth.themis.common.util.Result;
 import com.qmth.themis.common.util.ResultUtil;
 import io.swagger.annotations.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
 import java.util.Collections;
+import java.util.Map;
+import java.util.Objects;
 
 /**
  * @Description: 客户端 前端控制器
@@ -30,6 +42,46 @@ public class TBClientVersionController {
     @Resource
     TBClientVersionService tbClientVersionService;
 
+    @Resource
+    OssUtil ossUtil;
+
+    @Resource
+    TBAttachmentService tbAttachmentService;
+
+    @ApiOperation(value = "客户端上传附件接口")
+    @RequestMapping(value = "/upload", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
+    @Transactional
+    public Result upload(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file,
+                         @ApiParam(value = "版本号", required = true) @RequestParam String version) {
+        if (Objects.isNull(file) || Objects.equals(file, "")) {
+            throw new BusinessException(ExceptionResultEnum.ATTACHMENT_IS_NULL);
+        }
+        if (Objects.isNull(version) || Objects.equals(version, "")) {
+            throw new BusinessException(ExceptionResultEnum.VERSION_IS_NULL);
+        }
+        Map<String, Object> mapParameter = ossUtil.getAliYunOssPublicDomain().getMap();
+        TBAttachment tbAttachment = null;
+        try {
+            TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
+            mapParameter.put(SystemConstant.VERSION, version);
+            tbAttachment = tbAttachmentService
+                    .saveAttachment(file, ServletUtil.getRequestMd5(), ServletUtil.getRequestPath(), mapParameter,
+                            UploadFileEnum.client, tbUser.getOrgId(), tbUser.getId());
+        } catch (Exception e) {
+            log.error("请求出错", e);
+            if (Objects.nonNull(tbAttachment)) {
+                tbAttachmentService.deleteAttachment(mapParameter, UploadFileEnum.client, tbAttachment);
+            }
+            if (e instanceof BusinessException) {
+                throw new BusinessException(e.getMessage());
+            } else {
+                throw new RuntimeException(e);
+            }
+        }
+        return ResultUtil.ok(Collections.singletonMap(SystemConstant.SUCCESS, true));
+    }
+
     @ApiOperation(value = "客户端版本新增/编辑接口")
     @RequestMapping(value = "/save", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})

+ 2 - 2
themis-admin/src/main/resources/application.properties

@@ -130,7 +130,7 @@ tencentyun.sdk.urls=https://live1.qmth.com.cn,https://live2.qmth.com.cn,https://
 #\u7CFB\u7EDF\u914D\u7F6E
 sys.config.datacenterId=1
 sys.config.oss=true
-sys.config.attachmentType=.xlsx,.xls,.doc,.docx,.pdf,.jpg,.jpeg,.png,.html,.zip,.mp3,.wav
+sys.config.attachmentType=.xlsx,.xls,.doc,.docx,.pdf,.jpg,.jpeg,.png,.html,.zip,.mp3,.wav,.dll,.exe
 sys.config.serverUpload=/Users/king/git/themis-files/
 #\u7F51\u5173accessKey\u548Csecret,\u6D4B\u8BD5\u7528
 #sys.config.gatewayAccessKey=LTAI4FhEmrrhh27vzPGh25xe
@@ -193,5 +193,5 @@ prefix.url.admin=api/admin
 prefix.url.open=api/open
 
 #\u65E0\u9700\u9274\u6743\u7684url
-no.auth.urls=/webjars/**,/druid/**,/swagger-ui.html,/doc.html,/swagger-resources/**,/v2/api-docs,/webjars/springfox-swagger-ui/**,/api/admin/user/login/account,/api/admin/sys/org/queryByOrgCode,/file/**,/upload/**,/client/**,/base_photo/**,/frontend/**
+no.auth.urls=/webjars/**,/druid/**,/swagger-ui.html,/doc.html,/swagger-resources/**,/v2/api-docs,/webjars/springfox-swagger-ui/**,/api/admin/user/login/account,/api/admin/sys/org/queryByOrgCode,/file/**,/upload/**,/client/**,/base_photo/**,/frontend/**,/api/admin/client/save,/api/admin/client/upload,/api/admin/client/query,/api/admin/app/save,/api/admin/app/query
 common.system.urls=/api/admin/sys/getMenu,/api/admin/user/logout,/api/admin/sys/env,/api/admin/sys/file/upload,/api/admin/sys/file/download,/api/admin/sys/org/query,/api/admin/sys/role/query,/api/admin/sys/examActivity/query,/api/admin/sys/exam/query,/api/admin/sys/examRoom/query,/api/admin/sys/exam/privilegeQuery,/api/admin/student/photo/upload,/api/admin/sys/getPlayUrls

+ 2 - 0
themis-business/src/main/java/com/qmth/themis/business/constant/SystemConstant.java

@@ -149,6 +149,8 @@ public class SystemConstant {
 
     public final static String REDIS_ACTIVITY_CODE_SEQUENCE = "redis:seq:activity:code:";
 
+    public static final String VERSION = "version";
+
     /**
      * session过期时间
      */

+ 6 - 1
themis-business/src/main/java/com/qmth/themis/business/enums/UploadFileEnum.java

@@ -29,7 +29,12 @@ public enum UploadFileEnum {
     /**
      * 前端资源
      */
-    frontend(4);
+    frontend(4),
+
+    /**
+     * 移动端
+     */
+    app(5);
 
     private int id;
 

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

@@ -111,6 +111,8 @@ public class TBAttachmentServiceImpl extends ServiceImpl<TBAttachmentMapper, TBA
                 throw new BusinessException(ExceptionResultEnum.ATTACHMENT_TYPE_IS_NULL);
             } else if (Objects.equals(uploadType, UploadFileEnum.base_photo.name())) {
                 stringJoiner.add(uploadType).add(File.separator).add(String.valueOf(orgId));
+            } else if (!Objects.equals(uploadType, UploadFileEnum.client.name())) {
+                stringJoiner.add(uploadType).add(map.get(SystemConstant.VERSION).toString()).add(File.separator);
             } else if (!Objects.equals(uploadType, UploadFileEnum.file.name())) {
                 stringJoiner.add(uploadType).add(File.separator);
             }

+ 2 - 0
themis-common/src/main/java/com/qmth/themis/common/enums/ExceptionResultEnum.java

@@ -173,6 +173,8 @@ public enum ExceptionResultEnum {
 
     EXAM_ACTIVITY_ID_IS_NULL(400, 400050, "考试场次id不能为空"),
 
+    VERSION_IS_NULL(400, 400051, "版本号不能为空"),
+
     /**
      * 401
      */

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

@@ -164,7 +164,7 @@ tencentyun.sdk.urls=https://live1.qmth.com.cn,https://live2.qmth.com.cn,https://
 #\u7CFB\u7EDF\u914D\u7F6E
 sys.config.datacenterId=1
 sys.config.oss=true
-sys.config.attachmentType=.xlsx,.xls,.doc,.docx,.pdf,.jpg,.jpeg,.png,.html,.zip,.mp3,.wav
+sys.config.attachmentType=.xlsx,.xls,.doc,.docx,.pdf,.jpg,.jpeg,.png,.html,.zip,.mp3,.wav,.dll,.exe
 sys.config.serverUpload=/Users/king/git/themis-files/
 #\u7F51\u5173accessKey\u548Csecret,\u6D4B\u8BD5\u7528
 #sys.config.gatewayAccessKey=LTAI4FhEmrrhh27vzPGh25xe

+ 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.datacenterId=1
 sys.config.oss=true
-sys.config.attachmentType=.xlsx,.xls,.doc,.docx,.pdf,.jpg,.jpeg,.png,.html,.zip,.mp3,.wav
+sys.config.attachmentType=.xlsx,.xls,.doc,.docx,.pdf,.jpg,.jpeg,.png,.html,.zip,.mp3,.wav,.dll,.exe
 sys.config.serverUpload=/Users/king/git/themis-files/
 spring.resources.static-locations=file:${sys.config.serverUpload},classpath:/META-INF/resources/,classpath:/resources/