Prechádzať zdrojové kódy

上传客户端安装包修改

wangliang 2 rokov pred
rodič
commit
c78c6d6aa5

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

@@ -55,7 +55,7 @@ public class DownloadController {
             authInfoService.appHasExpired(code);
 
             TBOrgDownloadBean tbOrgDownloadBean = GsonUtil.fromJson(GsonUtil.toJson(tbOrg), TBOrgDownloadBean.class);
-            TBClientVersion tbClientVersion = tbClientVersionService.getMaxClientVersion();
+            TBClientVersion tbClientVersion = tbClientVersionService.getLastUploadClientVersion(tbOrg.getId());
             if (Objects.nonNull(tbClientVersion)) {
                 VersionBean v = new VersionBean(tbClientVersion.getName(), tbClientVersion.getValue(), tbClientVersion.getUrl());
                 tbOrgDownloadBean.setVersion(v);

+ 0 - 16
themis-business/src/main/java/com/qmth/themis/business/dao/TBClientDownloadMapper.java

@@ -1,16 +0,0 @@
-package com.qmth.themis.business.dao;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.qmth.themis.business.entity.TBClientDownload;
-
-/**
- * <p>
- * 客户端下载管理 Mapper 接口
- * </p>
- *
- * @author wangliang
- * @since 2022-09-05
- */
-public interface TBClientDownloadMapper extends BaseMapper<TBClientDownload> {
-
-}

+ 9 - 0
themis-business/src/main/java/com/qmth/themis/business/dao/TBClientVersionMapper.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.qmth.themis.business.entity.TBClientVersion;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.Map;
 
@@ -31,4 +32,12 @@ public interface TBClientVersionMapper extends BaseMapper<TBClientVersion> {
      * @return
      */
     TBClientVersion getMaxClientVersion();
+
+    /**
+     * 根据学校id获取客户端自行上传的版本
+     *
+     * @param orgId
+     * @return
+     */
+    TBClientVersion getLastUploadClientVersion(@Param("orgId") Long orgId);
 }

+ 11 - 0
themis-business/src/main/java/com/qmth/themis/business/dto/response/TBOrgBean.java

@@ -40,6 +40,17 @@ public class TBOrgBean implements Serializable {
     @NotNull(message = "安装包地址不能为空")
     private String packagePath;
 
+    @ApiModelProperty(value = "版本号描述")
+    private String description;
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
     public String getLogo() {
         return logo;
     }

+ 0 - 94
themis-business/src/main/java/com/qmth/themis/business/entity/TBClientDownload.java

@@ -1,94 +0,0 @@
-package com.qmth.themis.business.entity;
-
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
-import com.qmth.themis.business.base.BaseEntity;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-
-import java.io.Serializable;
-
-/**
- * <p>
- * 客户端下载管理
- * </p>
- *
- * @author wangliang
- * @since 2022-09-05
- */
-@ApiModel(value = "TBClientDownload对象", description = "客户端下载管理")
-public class TBClientDownload extends BaseEntity implements Serializable {
-
-    private static final long serialVersionUID = 1L;
-
-    @JsonSerialize(using = ToStringSerializer.class)
-    @ApiModelProperty(value = "机构id")
-    private Long orgId;
-
-    @JsonSerialize(using = ToStringSerializer.class)
-    @ApiModelProperty(value = "附件id")
-    private Long attachmentId;
-
-    @ApiModelProperty(value = "文件名称")
-    private String name;
-
-    @ApiModelProperty(value = "是否启用,0:停用,1:启用")
-    private Integer enable;
-
-    @ApiModelProperty(value = "更新人")
-    @TableField(exist = false)
-    private String updateName;
-
-    @ApiModelProperty(value = "附件路径")
-    @TableField(exist = false)
-    private String attachmentPath;
-
-    public Long getOrgId() {
-        return orgId;
-    }
-
-    public void setOrgId(Long orgId) {
-        this.orgId = orgId;
-    }
-
-    public Long getAttachmentId() {
-        return attachmentId;
-    }
-
-    public void setAttachmentId(Long attachmentId) {
-        this.attachmentId = attachmentId;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public Integer getEnable() {
-        return enable;
-    }
-
-    public void setEnable(Integer enable) {
-        this.enable = enable;
-    }
-
-    public String getUpdateName() {
-        return updateName;
-    }
-
-    public void setUpdateName(String updateName) {
-        this.updateName = updateName;
-    }
-
-    public String getAttachmentPath() {
-        return attachmentPath;
-    }
-
-    public void setAttachmentPath(String attachmentPath) {
-        this.attachmentPath = attachmentPath;
-    }
-}

+ 42 - 1
themis-business/src/main/java/com/qmth/themis/business/entity/TBClientVersion.java

@@ -1,7 +1,11 @@
 package com.qmth.themis.business.entity;
 
 import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.qmth.themis.business.base.BaseEntity;
+import com.qmth.themis.business.enums.ClientVersionTypeEnum;
+import com.qmth.themis.business.util.UidUtil;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
@@ -15,6 +19,10 @@ import io.swagger.annotations.ApiModelProperty;
 @ApiModel(value = "t_b_client_version", description = "客户端版本")
 public class TBClientVersion extends BaseEntity {
 
+    @JsonSerialize(using = ToStringSerializer.class)
+    @ApiModelProperty(value = "机构id")
+    private Long orgId;
+
     @ApiModelProperty(value = "版本名")
     @TableField(value = "name")
     private String name;
@@ -33,7 +41,40 @@ public class TBClientVersion extends BaseEntity {
 
     @ApiModelProperty(value = "是否启用,0:停用,1:启用")
     @TableField(value = "enable")
-    private Integer enable;
+    private Integer enable = 1;
+
+    @ApiModelProperty(value = "类型,ONLINE:线上,UPLOAD:客户端上传")
+    private ClientVersionTypeEnum type;
+
+    public TBClientVersion() {
+
+    }
+
+    public TBClientVersion(Long orgId, String url, String description, ClientVersionTypeEnum type) {
+        setId(UidUtil.nextId());
+        this.orgId = orgId;
+        this.url = url;
+        this.description = description;
+        this.name = description;
+        this.type = type;
+        this.value = 1;
+    }
+
+    public Long getOrgId() {
+        return orgId;
+    }
+
+    public void setOrgId(Long orgId) {
+        this.orgId = orgId;
+    }
+
+    public ClientVersionTypeEnum getType() {
+        return type;
+    }
+
+    public void setType(ClientVersionTypeEnum type) {
+        this.type = type;
+    }
 
     public String getName() {
         return name;

+ 0 - 13
themis-business/src/main/java/com/qmth/themis/business/entity/TBOrg.java

@@ -4,11 +4,9 @@ import com.baomidou.mybatisplus.annotation.TableField;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.qmth.themis.business.base.BaseEntity;
-import com.qmth.themis.business.util.UidUtil;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
-import javax.validation.constraints.NotNull;
 import java.util.Objects;
 
 /**
@@ -70,9 +68,6 @@ public class TBOrg extends BaseEntity {
     @TableField(value = "enable_monitor_record")
     private Integer enableMonitorRecord;
 
-    @ApiModelProperty(name = "安装包地址")
-    private String packagePath;
-
     public TBOrg() {
 
     }
@@ -186,14 +181,6 @@ public class TBOrg extends BaseEntity {
         this.accessSecret = accessSecret;
     }
 
-    public String getPackagePath() {
-        return packagePath;
-    }
-
-    public void setPackagePath(String packagePath) {
-        this.packagePath = packagePath;
-    }
-
     @Override
     public boolean equals(Object o) {
         if (this == o) return true;

+ 25 - 0
themis-business/src/main/java/com/qmth/themis/business/enums/ClientVersionTypeEnum.java

@@ -0,0 +1,25 @@
+package com.qmth.themis.business.enums;
+
+/**
+* @Description: 客户端版本类型 enum
+* @Param:
+* @return:
+* @Author: wangliang
+* @Date: 2020/8/12
+*/
+public enum ClientVersionTypeEnum {
+
+    ONLINE("线上"),
+
+    UPLOAD("客户端上传");
+
+    private String code;
+
+    private ClientVersionTypeEnum(String code){
+        this.code = code;
+    }
+
+    public String getCode() {
+        return code;
+    }
+}

+ 0 - 16
themis-business/src/main/java/com/qmth/themis/business/service/TBClientDownloadService.java

@@ -1,16 +0,0 @@
-package com.qmth.themis.business.service;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.qmth.themis.business.entity.TBClientDownload;
-
-/**
- * <p>
- * 客户端下载管理 服务类
- * </p>
- *
- * @author wangliang
- * @since 2022-09-05
- */
-public interface TBClientDownloadService extends IService<TBClientDownload> {
-
-}

+ 8 - 0
themis-business/src/main/java/com/qmth/themis/business/service/TBClientVersionService.java

@@ -29,4 +29,12 @@ public interface TBClientVersionService extends IService<TBClientVersion> {
      * @return
      */
     TBClientVersion getMaxClientVersion();
+
+    /**
+     * 根据学校id获取客户端自行上传的版本
+     *
+     * @param orgId
+     * @return
+     */
+    TBClientVersion getLastUploadClientVersion(Long orgId);
 }

+ 0 - 20
themis-business/src/main/java/com/qmth/themis/business/service/impl/TBClientDownloadServiceImpl.java

@@ -1,20 +0,0 @@
-package com.qmth.themis.business.service.impl;
-
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.qmth.themis.business.dao.TBClientDownloadMapper;
-import com.qmth.themis.business.entity.TBClientDownload;
-import com.qmth.themis.business.service.TBClientDownloadService;
-import org.springframework.stereotype.Service;
-
-/**
- * <p>
- * 客户端下载管理 服务实现类
- * </p>
- *
- * @author wangliang
- * @since 2022-09-05
- */
-@Service
-public class TBClientDownloadServiceImpl extends ServiceImpl<TBClientDownloadMapper, TBClientDownload> implements TBClientDownloadService {
-
-}

+ 11 - 0
themis-business/src/main/java/com/qmth/themis/business/service/impl/TBClientVersionServiceImpl.java

@@ -43,4 +43,15 @@ public class TBClientVersionServiceImpl extends ServiceImpl<TBClientVersionMappe
     public TBClientVersion getMaxClientVersion() {
         return tbClientVersionMapper.getMaxClientVersion();
     }
+
+    /**
+     * 根据学校id获取客户端自行上传的版本
+     *
+     * @param orgId
+     * @return
+     */
+    @Override
+    public TBClientVersion getLastUploadClientVersion(Long orgId) {
+        return tbClientVersionMapper.getLastUploadClientVersion(orgId);
+    }
 }

+ 0 - 5
themis-business/src/main/resources/mapper/TBClientDownloadMapper.xml

@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.qmth.themis.business.dao.TBClientDownloadMapper">
-
-</mapper>

+ 14 - 1
themis-business/src/main/resources/mapper/TBClientVersionMapper.xml

@@ -3,7 +3,7 @@
 <mapper namespace="com.qmth.themis.business.dao.TBClientVersionMapper">
 
     <select id="clientVersionQuery" resultType="com.qmth.themis.business.entity.TBClientVersion">
-        select * from t_b_client_version t
+        select * from t_b_client_version t where t.type = 'ONLINE'
     </select>
 
     <select id="getMaxClientVersion" resultType="com.qmth.themis.business.entity.TBClientVersion">
@@ -19,8 +19,21 @@
             t_b_client_version tbcv
             <where>
              tbcv.enable = 1
+             and tbcv.type = 'ONLINE'
             </where>
             )
         </where>
     </select>
+
+    <select id="getLastUploadClientVersion" resultType="com.qmth.themis.business.entity.TBClientVersion">
+        select t.* from t_b_client_version t
+        <where>
+            <if test="orgId != null and orgId != ''">
+                and t.org_id = #{orgId}
+            </if>
+                and t.enable = 1
+                and t.type = 'UPLOAD'
+        </where>
+        order by t.create_time desc limit 1
+    </select>
 </mapper>

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

@@ -11,6 +11,7 @@ import com.qmth.themis.business.dto.response.TBOrgBean;
 import com.qmth.themis.business.entity.SysConfig;
 import com.qmth.themis.business.entity.TBClientVersion;
 import com.qmth.themis.business.entity.TBOrg;
+import com.qmth.themis.business.enums.ClientVersionTypeEnum;
 import com.qmth.themis.business.enums.UploadFileEnum;
 import com.qmth.themis.business.service.TBClientVersionService;
 import com.qmth.themis.business.service.TBOrgService;
@@ -22,6 +23,7 @@ import com.qmth.themis.common.util.Result;
 import com.qmth.themis.common.util.ResultUtil;
 import com.qmth.themis.exam.config.DictionaryConfig;
 import io.swagger.annotations.*;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.validation.BindingResult;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -107,18 +109,13 @@ public class SysController {
     @ApiOperation(value = "上传安装包回调接口")
     @RequestMapping(value = "/upload/package/callback", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = Result.class)})
+    @Transactional
     public Result uploadPackageCallback(@Validated @ApiParam(value = "学校信息", required = true) @RequestBody TBOrgBean tbOrgBean, BindingResult bindingResult) {
         if (bindingResult.hasErrors()) {
             return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
         }
         TBOrg tbOrg = themisCacheService.addOrgCache(tbOrgBean.getId());
         Optional.ofNullable(tbOrg).orElseThrow(() -> new BusinessException(ExceptionResultEnum.ORG_NO));
-
-        tbOrg.setPackagePath(tbOrgBean.getPackagePath());
-        tbOrgService.updateById(tbOrg);
-
-        themisCacheService.updateOrgCache(tbOrgBean.getId());
-        themisCacheService.updateOrgCodeCache(tbOrgBean.getCode());
-        return ResultUtil.ok(true);
+        return ResultUtil.ok(tbClientVersionService.save(new TBClientVersion(tbOrg.getId(), tbOrgBean.getPackagePath(), tbOrgBean.getDescription(), ClientVersionTypeEnum.UPLOAD)));
     }
 }