Преглед изворни кода

下载安装包接口修改

wangliang пре 2 година
родитељ
комит
f55f22a274

+ 68 - 0
themis-admin/src/main/java/com/qmth/themis/admin/api/DownloadController.java

@@ -0,0 +1,68 @@
+package com.qmth.themis.admin.api;
+
+import com.qmth.themis.business.bean.exam.VersionBean;
+import com.qmth.themis.business.constant.SystemConstant;
+import com.qmth.themis.business.dto.response.TBOrgDownloadBean;
+import com.qmth.themis.business.entity.TBClientVersion;
+import com.qmth.themis.business.entity.TBOrg;
+import com.qmth.themis.business.service.AuthInfoService;
+import com.qmth.themis.business.service.TBClientVersionService;
+import com.qmth.themis.business.service.ThemisCacheService;
+import com.qmth.themis.common.enums.ExceptionResultEnum;
+import com.qmth.themis.common.exception.BusinessException;
+import com.qmth.themis.common.util.GsonUtil;
+import com.qmth.themis.common.util.Result;
+import com.qmth.themis.common.util.ResultUtil;
+import io.swagger.annotations.*;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.Objects;
+import java.util.Optional;
+
+/**
+ * @Description: 下载信息 前端控制器
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2023/2/8
+ */
+@Api(tags = "下载信息Controller")
+@RestController
+@RequestMapping(SystemConstant.PREFIX_URL_DOWNLOAD)
+public class DownloadController {
+
+    @Resource
+    ThemisCacheService themisCacheService;
+
+    @Resource
+    AuthInfoService authInfoService;
+
+    @Resource
+    TBClientVersionService tbClientVersionService;
+
+    @ApiOperation(value = "根据机构代码查询下载安装包信息接口")
+    @RequestMapping(value = "/package", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "机构信息", response = TBOrgDownloadBean.class)})
+    public Result downloadPackage(@ApiParam(value = "机构code", required = true) @RequestParam String code) {
+        Optional.ofNullable(code).orElseThrow(() -> new BusinessException(ExceptionResultEnum.ORG_CODE_IS_NULL));
+        if (!Objects.equals(code.toUpperCase(), SystemConstant.ADMIN)) {
+            TBOrg tbOrg = themisCacheService.addOrgCodeCache(code);
+            Optional.ofNullable(tbOrg).orElseThrow(() -> new BusinessException(ExceptionResultEnum.ORG_NO));
+            authInfoService.appHasExpired(code);
+
+            TBOrgDownloadBean tbOrgDownloadBean = GsonUtil.fromJson(GsonUtil.toJson(tbOrg), TBOrgDownloadBean.class);
+            TBClientVersion tbClientVersion = tbClientVersionService.getMaxClientVersion();
+            if (Objects.nonNull(tbClientVersion)) {
+                VersionBean v = new VersionBean(tbClientVersion.getName(), tbClientVersion.getValue(), tbClientVersion.getUrl());
+                tbOrgDownloadBean.setVersion(v);
+            }
+            return ResultUtil.ok(tbOrgDownloadBean);
+        } else {
+            throw new BusinessException("超级管理员无需下载");
+        }
+    }
+}

+ 0 - 27
themis-admin/src/main/java/com/qmth/themis/admin/api/SysController.java

@@ -10,11 +10,9 @@ import com.qmth.themis.admin.config.DictionaryConfig;
 import com.qmth.themis.business.bean.admin.DataCountBean;
 import com.qmth.themis.business.bean.admin.MapDataCountBean;
 import com.qmth.themis.business.bean.admin.OrgDataCountBean;
-import com.qmth.themis.business.bean.exam.VersionBean;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.dto.AuthDto;
 import com.qmth.themis.business.dto.response.RoomCodeQueryDto;
-import com.qmth.themis.business.dto.response.TBOrgDownloadBean;
 import com.qmth.themis.business.dto.response.TEExamQueryDto;
 import com.qmth.themis.business.entity.*;
 import com.qmth.themis.business.enums.DownloadFileEnum;
@@ -120,9 +118,6 @@ public class SysController {
     @Resource
     SolarProperties solarProperties;
 
-    @Resource
-    TBClientVersionService tbClientVersionService;
-
     @ApiOperation(value = "同步机构接口")
     @RequestMapping(value = "/sync/org", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "菜单信息", response = Result.class)})
@@ -273,28 +268,6 @@ public class SysController {
         }
     }
 
-    @ApiOperation(value = "根据机构代码查询下载安装包信息接口")
-    @RequestMapping(value = "/download/package", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "机构信息", response = TBOrgDownloadBean.class)})
-    public Result downloadPackage(@ApiParam(value = "机构code", required = true) @RequestParam String code) {
-        Optional.ofNullable(code).orElseThrow(() -> new BusinessException(ExceptionResultEnum.ORG_CODE_IS_NULL));
-        if (!Objects.equals(code.toUpperCase(), SystemConstant.ADMIN)) {
-            TBOrg tbOrg = themisCacheService.addOrgCodeCache(code);
-            Optional.ofNullable(tbOrg).orElseThrow(() -> new BusinessException(ExceptionResultEnum.ORG_NO));
-            authInfoService.appHasExpired(code);
-
-            TBOrgDownloadBean tbOrgDownloadBean = GsonUtil.fromJson(GsonUtil.toJson(tbOrg), TBOrgDownloadBean.class);
-            TBClientVersion tbClientVersion = tbClientVersionService.getMaxClientVersion();
-            if (Objects.nonNull(tbClientVersion)) {
-                VersionBean v = new VersionBean(tbClientVersion.getName(), tbClientVersion.getValue(), tbClientVersion.getUrl());
-                tbOrgDownloadBean.setVersion(v);
-            }
-            return ResultUtil.ok(tbOrgDownloadBean);
-        } else {
-            throw new BusinessException("超级管理员无需下载");
-        }
-    }
-
     @ApiOperation(value = "机构查询接口")
     @RequestMapping(value = "/org/query", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "机构信息", response = TBOrg.class)})

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

@@ -76,6 +76,7 @@ public class SystemConstant {
     public static final String PREFIX_URL_NOTIFY = "/api/notify";
     public static final String PREFIX_URL_OE = "/api/oe";
     public static final String PREFIX_URL_MOBILE = "/api/mobile";
+    public static final String PREFIX_URL_DOWNLOAD = "/api/download";
 
     public static final String ATTACHMENT_TYPE = "attachment.type";
     public static final String ADMIN_LOGO_URL = "admin.logo.url";