Pārlūkot izejas kodu

3.4.1 工具管理

xiaofei 10 mēneši atpakaļ
vecāks
revīzija
d174f29240

+ 2 - 2
distributed-print-business/pom.xml

@@ -4,7 +4,7 @@
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.qmth.distributed.print.business</groupId>
     <artifactId>distributed-print-business</artifactId>
-    <version>3.4.0</version>
+    <version>3.4.1</version>
     <build>
         <plugins>
             <plugin>
@@ -22,7 +22,7 @@
     <parent>
         <groupId>com.qmth.distributed.print.service</groupId>
         <artifactId>distributed-print-service</artifactId>
-        <version>3.4.0</version>
+        <version>3.4.1</version>
     </parent>
 
     <dependencies>

+ 7 - 0
distributed-print-business/src/main/resources/db/log/xf.sql

@@ -0,0 +1,7 @@
+CREATE TABLE `sys_tools` (
+    `type` VARCHAR(20) NOT NULL COMMENT '类型',
+    `path` MEDIUMTEXT NOT NULL COMMENT '文件地址信息',
+    `create_id` BIGINT(20) NULL,
+    `create_time` BIGINT(20) NULL,
+    PRIMARY KEY (`type`))
+    COMMENT = '工具管理';

+ 2 - 0
distributed-print/install/mysql/upgrade/3.4.1.sql

@@ -0,0 +1,2 @@
+USE teachcloud_db;
+

+ 2 - 2
distributed-print/pom.xml

@@ -4,13 +4,13 @@
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.qmth.distributed.print</groupId>
     <artifactId>distributed-print</artifactId>
-    <version>3.4.0</version>
+    <version>3.4.1</version>
     <packaging>jar</packaging>
 
     <parent>
         <groupId>com.qmth.distributed.print.service</groupId>
         <artifactId>distributed-print-service</artifactId>
-        <version>3.4.0</version>
+        <version>3.4.1</version>
     </parent>
 
     <dependencies>

+ 49 - 0
distributed-print/src/main/java/com/qmth/distributed/print/api/admin/SysToolsController.java

@@ -0,0 +1,49 @@
+package com.qmth.distributed.print.api.admin;
+
+import com.qmth.boot.api.annotation.Aac;
+import com.qmth.boot.api.constant.ApiConstant;
+import com.qmth.teachcloud.common.contant.SystemConstant;
+import com.qmth.teachcloud.common.enums.ToolsTypeEnum;
+import com.qmth.teachcloud.common.service.SysToolsService;
+import com.qmth.teachcloud.common.util.Result;
+import com.qmth.teachcloud.common.util.ResultUtil;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+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 org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+
+/**
+ * 工具管理 前端控制器
+ */
+@Api(tags = "超管-工具管理Controller")
+@RestController
+@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_SYS + "/tools")
+@Aac(auth = false)
+public class SysToolsController {
+
+    @Resource
+    private SysToolsService sysToolsService;
+
+    @ApiOperation(value = "上传")
+    @RequestMapping(value = "/upload", method = RequestMethod.POST)
+    public Result upload(@ApiParam(value = "上传文件", required = true) @RequestParam(value = "file") MultipartFile file,
+                        @ApiParam(value = "文件MD5", required = true) @RequestParam(value = "md5") String md5,
+                        @ApiParam(value = "工具类型", required = true) @RequestParam(value = "type") ToolsTypeEnum type) {
+        sysToolsService.upload(file, md5, type);
+        return ResultUtil.ok(true);
+    }
+
+    @ApiOperation(value = "访问链接")
+    @RequestMapping(value = "/external", method = RequestMethod.POST)
+    public Result external(@ApiParam(value = "工具类型", required = true) @RequestParam(value = "type") ToolsTypeEnum type) {
+        return ResultUtil.ok(sysToolsService.getExternalByType(type));
+    }
+
+}
+

+ 1 - 1
pom.xml

@@ -4,7 +4,7 @@
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.qmth.distributed.print.service</groupId>
     <artifactId>distributed-print-service</artifactId>
-    <version>3.4.0</version>
+    <version>3.4.1</version>
     <packaging>pom</packaging>
 
     <modules>

+ 2 - 2
teachcloud-common-api/pom.xml

@@ -4,13 +4,13 @@
 	<modelVersion>4.0.0</modelVersion>
 	<groupId>com.qmth.teachcloud.common.api</groupId>
 	<artifactId>teachcloud-common-api</artifactId>
-	<version>3.4.0</version>
+	<version>3.4.1</version>
 	<packaging>jar</packaging>
 
 	<parent>
 		<groupId>com.qmth.distributed.print.service</groupId>
 		<artifactId>distributed-print-service</artifactId>
-		<version>3.4.0</version>
+		<version>3.4.1</version>
 	</parent>
 
 	<dependencies>

+ 2 - 2
teachcloud-common/pom.xml

@@ -4,13 +4,13 @@
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.qmth.teachcloud.common</groupId>
     <artifactId>teachcloud-common</artifactId>
-    <version>3.4.0</version>
+    <version>3.4.1</version>
     <packaging>jar</packaging>
 
     <parent>
         <groupId>com.qmth.distributed.print.service</groupId>
         <artifactId>distributed-print-service</artifactId>
-        <version>3.4.0</version>
+        <version>3.4.1</version>
     </parent>
 
     <dependencies>

+ 1 - 1
teachcloud-common/src/main/java/com/qmth/teachcloud/common/contant/SystemConstant.java

@@ -264,7 +264,7 @@ public class SystemConstant {
     public static final String ID = "id";
     public static final String MODEL = "model";
     public static final String VERSION = "version";
-    public static final String VERSION_VALUE = "3.4.0.1";
+    public static final String VERSION_VALUE = "3.4.1.1";
     public static final String FLOW_ENTITY_ID = "flowEntityId";
     public static final String CUSTOM_FLOW_ID = "customFlowId";
     public static final String ACT_FLOW_ID = "actFlowId";

+ 83 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/entity/SysTools.java

@@ -0,0 +1,83 @@
+package com.qmth.teachcloud.common.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.io.Serializable;
+
+import com.qmth.teachcloud.common.enums.ToolsTypeEnum;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * <p>
+ * 工具管理
+ * </p>
+ *
+ * @author xf
+ * @since 2024-08-19
+ */
+@TableName("sys_tools")
+@ApiModel(value="SysTools对象", description="工具管理")
+public class SysTools implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "类型")
+    @TableId(value = "type")
+    private ToolsTypeEnum type;
+
+    @ApiModelProperty(value = "文件地址信息")
+    private String path;
+
+    private Long createId;
+
+    private Long createTime;
+
+    public SysTools() {
+    }
+
+    public SysTools(ToolsTypeEnum type) {
+        this.type = type;
+        this.createTime = System.currentTimeMillis();
+    }
+
+    public ToolsTypeEnum getType() {
+        return type;
+    }
+
+    public void setType(ToolsTypeEnum type) {
+        this.type = type;
+    }
+    public String getPath() {
+        return path;
+    }
+
+    public void setPath(String path) {
+        this.path = path;
+    }
+    public Long getCreateId() {
+        return createId;
+    }
+
+    public void setCreateId(Long createId) {
+        this.createId = createId;
+    }
+    public Long getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Long createTime) {
+        this.createTime = createTime;
+    }
+
+    @Override
+    public String toString() {
+        return "SysTools{" +
+            "type=" + type +
+            ", path=" + path +
+            ", createId=" + createId +
+            ", createTime=" + createTime +
+        "}";
+    }
+}

+ 36 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/enums/ToolsTypeEnum.java

@@ -0,0 +1,36 @@
+package com.qmth.teachcloud.common.enums;
+
+import java.util.Objects;
+
+/**
+ * 工具类型
+ */
+public enum ToolsTypeEnum {
+
+    PICTURE_DOWNLOAD("图片下载工具");
+
+    private String name;
+
+    private ToolsTypeEnum(String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * 状态转换 toName
+     *
+     * @param name
+     * @return
+     */
+    public static String convertToName(String name) {
+        for (ToolsTypeEnum e : ToolsTypeEnum.values()) {
+            if (Objects.equals(name, e.getName())) {
+                return e.name();
+            }
+        }
+        return null;
+    }
+}

+ 16 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/mapper/SysToolsMapper.java

@@ -0,0 +1,16 @@
+package com.qmth.teachcloud.common.mapper;
+
+import com.qmth.teachcloud.common.entity.SysTools;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * 工具管理 Mapper 接口
+ * </p>
+ *
+ * @author xf
+ * @since 2024-08-19
+ */
+public interface SysToolsMapper extends BaseMapper<SysTools> {
+
+}

+ 21 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/SysToolsService.java

@@ -0,0 +1,21 @@
+package com.qmth.teachcloud.common.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.teachcloud.common.entity.SysTools;
+import com.qmth.teachcloud.common.enums.ToolsTypeEnum;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * <p>
+ * 工具管理 服务类
+ * </p>
+ *
+ * @author xf
+ * @since 2024-08-19
+ */
+public interface SysToolsService extends IService<SysTools> {
+
+    void upload(MultipartFile file, String md5, ToolsTypeEnum type);
+
+    String getExternalByType(ToolsTypeEnum type);
+}

+ 99 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/SysToolsServiceImpl.java

@@ -0,0 +1,99 @@
+package com.qmth.teachcloud.common.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.teachcloud.common.bean.vo.FilePathVo;
+import com.qmth.teachcloud.common.entity.SysTools;
+import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
+import com.qmth.teachcloud.common.enums.ToolsTypeEnum;
+import com.qmth.teachcloud.common.enums.UploadFileEnum;
+import com.qmth.teachcloud.common.mapper.SysToolsMapper;
+import com.qmth.teachcloud.common.service.FileUploadService;
+import com.qmth.teachcloud.common.service.SysToolsService;
+import com.qmth.teachcloud.common.util.FileUtil;
+import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.commons.io.FilenameUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import java.io.File;
+import java.util.Objects;
+import java.util.StringJoiner;
+
+/**
+ * <p>
+ * 工具管理 服务实现类
+ * </p>
+ *
+ * @author xf
+ * @since 2024-08-19
+ */
+@Service
+public class SysToolsServiceImpl extends ServiceImpl<SysToolsMapper, SysTools> implements SysToolsService {
+
+    @Resource
+    private FileUploadService fileUploadService;
+
+    @Override
+    public void upload(MultipartFile file, String md5, ToolsTypeEnum type) {
+        File parentDirVar = null;
+        try {
+            String fileName = FilenameUtils.getName(file.getOriginalFilename());
+
+//            if (!fileName.endsWith(".zip")) {
+//                throw ExceptionResultEnum.ERROR.exception("只能上传后缀为[.zip]的文件");
+//            }
+
+            String fileMd5 = DigestUtils.md5Hex(file.getBytes());
+            if (!Objects.equals(fileMd5, md5)) {
+                throw ExceptionResultEnum.MD5_EQUALS_FALSE.exception();
+            }
+
+            SysTools sysTools = this.getById(type);
+            if (sysTools == null) {
+                sysTools = new SysTools(type);
+            }
+            // 上传
+            String filePathName = buildPath(true, UploadFileEnum.FILE.getTitle(), type.name()) + fileName;
+            FilePathVo filePathVo = fileUploadService.uploadFile(file, UploadFileEnum.FILE, filePathName, fileMd5);
+            sysTools.setPath(JSON.toJSONString(filePathVo));
+            // 保存或更新
+            this.saveOrUpdate(sysTools);
+        } catch (Exception e) {
+            throw ExceptionResultEnum.ERROR.exception(type.getName() + "上传失败:" + e.getMessage());
+        } finally {
+            if (parentDirVar != null) {
+                FileUtil.deleteFile(parentDirVar);
+            }
+        }
+    }
+
+    @Override
+    public String getExternalByType(ToolsTypeEnum type) {
+        SysTools sysTools = this.getById(type);
+        if (sysTools != null) {
+            return fileUploadService.filePreview(sysTools.getPath());
+        }
+        return null;
+    }
+
+    /**
+     * 路径拼接
+     *
+     * @param endSeparator 结尾是否带分隔符
+     * @param paths        路径数组
+     */
+    private String buildPath(boolean endSeparator, String... paths) {
+        StringJoiner stringJoiner = new StringJoiner(File.separator);
+        for (String path : paths) {
+            stringJoiner.add(path);
+        }
+        String path = stringJoiner.toString();
+        if (endSeparator) {
+            path = path + File.separator;
+        }
+        return path;
+    }
+
+}

+ 13 - 0
teachcloud-common/src/main/resources/mapper/SysToolsMapper.xml

@@ -0,0 +1,13 @@
+<?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.teachcloud.common.mapper.SysToolsMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.qmth.teachcloud.common.entity.SysTools">
+        <id column="type" property="type" />
+        <result column="path" property="path" />
+        <result column="create_id" property="createId" />
+        <result column="create_time" property="createTime" />
+    </resultMap>
+
+</mapper>

+ 2 - 2
teachcloud-mark/pom.xml

@@ -4,7 +4,7 @@
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.qmth.teachcloud.mark</groupId>
     <artifactId>teachcloud-mark</artifactId>
-    <version>3.4.0</version>
+    <version>3.4.1</version>
     <build>
         <plugins>
             <plugin>
@@ -22,7 +22,7 @@
     <parent>
         <groupId>com.qmth.distributed.print.service</groupId>
         <artifactId>distributed-print-service</artifactId>
-        <version>3.4.0</version>
+        <version>3.4.1</version>
     </parent>
 
     <dependencies>

+ 3 - 3
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/impl/ScanRefixBatchServiceImpl.java

@@ -103,9 +103,9 @@ public class ScanRefixBatchServiceImpl extends ServiceImpl<ScanRefixBatchMapper,
                 paperService.savePaperAndPages(paper, pages);
             }
             // 更换卡格式后需要删除阅卷任务
-            if (!student.getCardNumber().equals(answerCard.getNumber())) {
-                markService.deleteMarkTaskByStudent(student);
-            }
+//            if (!student.getCardNumber().equals(answerCard.getNumber())) {
+//                markService.deleteMarkTaskByStudent(student);
+//            }
             studentService.updateStudentByPaper(userId, student.getId(), true);
             return AnswerRefixVo.create();
         } finally {

+ 2 - 2
teachcloud-obe/pom.xml

@@ -4,13 +4,13 @@
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.qmth.teachcloud.obe</groupId>
     <artifactId>teachcloud-obe</artifactId>
-    <version>3.4.0</version>
+    <version>3.4.1</version>
     <packaging>jar</packaging>
 
     <parent>
         <groupId>com.qmth.distributed.print.service</groupId>
         <artifactId>distributed-print-service</artifactId>
-        <version>3.4.0</version>
+        <version>3.4.1</version>
     </parent>
 
 

+ 2 - 2
teachcloud-report-business/pom.xml

@@ -4,7 +4,7 @@
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.qmth.teachcloud.report.business</groupId>
     <artifactId>teachcloud-report-business</artifactId>
-    <version>3.4.0</version>
+    <version>3.4.1</version>
     <build>
         <plugins>
             <plugin>
@@ -22,7 +22,7 @@
     <parent>
         <groupId>com.qmth.distributed.print.service</groupId>
         <artifactId>distributed-print-service</artifactId>
-        <version>3.4.0</version>
+        <version>3.4.1</version>
     </parent>
 
     <dependencies>

+ 0 - 0
teachcloud-report-business/src/main/resources/mapper/TBSchoolMajorMapper.xml → teachcloud-report-business/src/main/resources/mapper/SysToolsService.xml


+ 2 - 2
teachcloud-report/pom.xml

@@ -4,13 +4,13 @@
 	<modelVersion>4.0.0</modelVersion>
 	<groupId>com.qmth.teachcloud.report</groupId>
 	<artifactId>teachcloud-report</artifactId>
-	<version>3.4.0</version>
+	<version>3.4.1</version>
 	<packaging>jar</packaging>
 
 	<parent>
 		<groupId>com.qmth.distributed.print.service</groupId>
 		<artifactId>distributed-print-service</artifactId>
-		<version>3.4.0</version>
+		<version>3.4.1</version>
 	</parent>
 
 	<dependencies>

+ 2 - 2
teachcloud-task/pom.xml

@@ -4,13 +4,13 @@
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.qmth.teachcloud.task</groupId>
     <artifactId>teachcloud-task</artifactId>
-    <version>3.4.0</version>
+    <version>3.4.1</version>
     <packaging>jar</packaging>
 
     <parent>
         <groupId>com.qmth.distributed.print.service</groupId>
         <artifactId>distributed-print-service</artifactId>
-        <version>3.4.0</version>
+        <version>3.4.1</version>
     </parent>
 
     <dependencies>