Просмотр исходного кода

新增根据机构代码查询下载安装包信息

wangliang 2 лет назад
Родитель
Сommit
52092e77a2

+ 28 - 3
themis-admin/src/main/java/com/qmth/themis/admin/api/SysController.java

@@ -10,9 +10,11 @@ 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;
@@ -118,6 +120,9 @@ 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)})
@@ -255,9 +260,7 @@ public class SysController {
     @RequestMapping(value = "/org/queryByOrgCode", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "机构信息", response = TBOrg.class)})
     public Result queryByOrgCode(@ApiParam(value = "机构code", required = true) @RequestParam String code) {
-        if (Objects.isNull(code) || Objects.equals(code, "")) {
-            throw new BusinessException(ExceptionResultEnum.ORG_CODE_IS_NULL);
-        }
+        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));
@@ -270,6 +273,28 @@ 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)})

+ 32 - 0
themis-business/src/main/java/com/qmth/themis/business/dto/response/TBOrgDownloadBean.java

@@ -0,0 +1,32 @@
+package com.qmth.themis.business.dto.response;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.themis.business.bean.exam.VersionBean;
+import io.swagger.annotations.ApiModelProperty;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * @Description: 机构 bean
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2020/8/3
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class TBOrgDownloadBean extends TBOrgBean {
+
+    @ApiModelProperty(name = "版本号")
+    private VersionBean version;
+
+    public VersionBean getVersion() {
+        return version;
+    }
+
+    public void setVersion(VersionBean version) {
+        this.version = version;
+    }
+}