Browse Source

1.0.4 优化

xiaofei 1 year ago
parent
commit
5468522b8e
17 changed files with 190 additions and 78 deletions
  1. 8 16
      paper-library-business/src/main/java/com/qmth/paper/library/business/entity/ExamCourse.java
  2. 2 2
      paper-library-business/src/main/java/com/qmth/paper/library/business/mapper/ExamCourseMapper.java
  3. 6 4
      paper-library-business/src/main/java/com/qmth/paper/library/business/service/ExamCourseService.java
  4. 2 0
      paper-library-business/src/main/java/com/qmth/paper/library/business/service/ExamStudentService.java
  5. 7 1
      paper-library-business/src/main/java/com/qmth/paper/library/business/service/PaperScanTaskService.java
  6. 26 8
      paper-library-business/src/main/java/com/qmth/paper/library/business/service/impl/ExamCourseServiceImpl.java
  7. 67 21
      paper-library-business/src/main/java/com/qmth/paper/library/business/service/impl/ExamStudentServiceImpl.java
  8. 35 1
      paper-library-business/src/main/java/com/qmth/paper/library/business/service/impl/PaperScanTaskServiceImpl.java
  9. 3 4
      paper-library-business/src/main/resources/mapper/ExamCourseMapper.xml
  10. 4 8
      paper-library-common/pom.xml
  11. 9 0
      paper-library-common/src/main/java/com/qmth/paper/library/common/bean/dto/SchoolDto.java
  12. 1 1
      paper-library-common/src/main/java/com/qmth/paper/library/common/service/impl/AuthInfoServiceImpl.java
  13. 1 1
      paper-library-common/src/main/resources/mapper/BasicSchoolMapper.xml
  14. 5 7
      paper-library/install/mysql/init/paper_library_db.sql
  15. 6 4
      paper-library/src/main/java/com/qmth/paper/library/PaperLibraryApplication.java
  16. 2 0
      paper-library/src/main/java/com/qmth/paper/library/api/BasicSchoolController.java
  17. 6 0
      pom.xml

+ 8 - 16
paper-library-business/src/main/java/com/qmth/paper/library/business/entity/ExamCourse.java

@@ -1,10 +1,9 @@
 package com.qmth.paper.library.business.entity;
 
-import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
-import com.qmth.paper.library.common.contant.SystemConstant;
+import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
@@ -24,15 +23,13 @@ public class ExamCourse implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
-    @TableId(value = "id")
-    @JsonSerialize(using = ToStringSerializer.class)
-    private Long id;
-
     @ApiModelProperty(value = "考试ID")
     @JsonSerialize(using = ToStringSerializer.class)
+    @MppMultiId(value = "exam_id")
     private Long examId;
 
     @ApiModelProperty(value = "课程代码")
+    @MppMultiId(value = "course_code")
     private String courseCode;
 
     @ApiModelProperty(value = "课程名称")
@@ -41,19 +38,15 @@ public class ExamCourse implements Serializable {
     public ExamCourse() {
     }
 
-    public ExamCourse(Long examId, String courseCode, String courseName) {
-        this.id = SystemConstant.getDbUuid();
+    public ExamCourse(Long examId, String courseCode) {
         this.examId = examId;
         this.courseCode = courseCode;
-        this.courseName = courseName;
-    }
-
-    public Long getId() {
-        return id;
     }
 
-    public void setId(Long id) {
-        this.id = id;
+    public ExamCourse(Long examId, String courseCode, String courseName) {
+        this.examId = examId;
+        this.courseCode = courseCode;
+        this.courseName = courseName;
     }
 
     public Long getExamId() {
@@ -83,7 +76,6 @@ public class ExamCourse implements Serializable {
     @Override
     public String toString() {
         return "ExamCourse{" +
-                "id=" + id +
                 ", examId=" + examId +
                 ", courseCode=" + courseCode +
                 ", courseName=" + courseName +

+ 2 - 2
paper-library-business/src/main/java/com/qmth/paper/library/business/mapper/ExamCourseMapper.java

@@ -1,7 +1,7 @@
 package com.qmth.paper.library.business.mapper;
 
+import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
 import com.qmth.paper.library.business.entity.ExamCourse;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
 /**
  * <p>
@@ -11,6 +11,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  * @author xf
  * @since 2024-03-11
  */
-public interface ExamCourseMapper extends BaseMapper<ExamCourse> {
+public interface ExamCourseMapper extends MppBaseMapper<ExamCourse> {
 
 }

+ 6 - 4
paper-library-business/src/main/java/com/qmth/paper/library/business/service/ExamCourseService.java

@@ -1,8 +1,8 @@
 package com.qmth.paper.library.business.service;
 
+import com.github.jeffreyning.mybatisplus.service.IMppService;
 import com.qmth.paper.library.business.bean.result.SelectResult;
 import com.qmth.paper.library.business.entity.ExamCourse;
-import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.paper.library.common.entity.ExamStudent;
 
 import java.util.List;
@@ -15,13 +15,15 @@ import java.util.List;
  * @author xf
  * @since 2024-03-11
  */
-public interface ExamCourseService extends IService<ExamCourse> {
+public interface ExamCourseService extends IMppService<ExamCourse> {
 
-    void saveStudentCourse(Long examId, List<ExamStudent> basicStudentList);
+    void saveBatchStudentCourse(Long examId, List<ExamStudent> basicStudentList);
 
-    void removeByExamId(Long examId);
+    void removeByExamIdAndCourseCode(Long examId, String courseCode);
 
     List<SelectResult> listConditionByExamId(Long examId);
 
     List<ExamCourse> listByExamId(Long examId);
+
+    void saveStudentCourse(Long examId, ExamStudent examStudent);
 }

+ 2 - 0
paper-library-business/src/main/java/com/qmth/paper/library/business/service/ExamStudentService.java

@@ -41,4 +41,6 @@ public interface ExamStudentService extends IService<ExamStudent> {
     void updateBindCount(Long studentId);
 
     void removeByExamId(Long examId);
+
+    int countByExamIdAndCourseCode(Long examId, String courseCode);
 }

+ 7 - 1
paper-library-business/src/main/java/com/qmth/paper/library/business/service/PaperScanTaskService.java

@@ -33,9 +33,15 @@ public interface PaperScanTaskService extends IService<PaperScanTask> {
      */
     void clearScanData(Long paperScanTaskId);
 
-    void addScanTask(Long examId, RecognitionTypeEnum recognitionType, StoreTypeEnum storeType, List<ExamStudent> basicStudentList);
+    void addBatchScanTask(Long examId, RecognitionTypeEnum recognitionType, StoreTypeEnum storeType, List<ExamStudent> basicStudentList);
 
     void removeBySchoolId(Long schoolId);
 
     List<PaperScanTask> listByExamId(Long examId);
+
+    void addScanTask(Long examId, RecognitionTypeEnum recognitionType, StoreTypeEnum storeType, ExamStudent examStudent);
+
+    PaperScanTask getByExamIdAndCourseCode(Long examId, String courseCode);
+
+    void updateStudentCount(PaperScanTask paperScanTask);
 }

+ 26 - 8
paper-library-business/src/main/java/com/qmth/paper/library/business/service/impl/ExamCourseServiceImpl.java

@@ -1,12 +1,16 @@
 package com.qmth.paper.library.business.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
 import com.qmth.paper.library.business.bean.result.SelectResult;
 import com.qmth.paper.library.business.entity.ExamCourse;
 import com.qmth.paper.library.business.mapper.ExamCourseMapper;
 import com.qmth.paper.library.business.service.ExamCourseService;
 import com.qmth.paper.library.common.entity.ExamStudent;
+import com.qmth.paper.library.common.enums.ExceptionResultEnum;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -24,30 +28,33 @@ import java.util.stream.Collectors;
  * @since 2024-03-11
  */
 @Service
-public class ExamCourseServiceImpl extends ServiceImpl<ExamCourseMapper, ExamCourse> implements ExamCourseService {
+public class ExamCourseServiceImpl extends MppServiceImpl<ExamCourseMapper, ExamCourse> implements ExamCourseService {
 
     @Transactional
     @Override
-    public void saveStudentCourse(Long examId, List<ExamStudent> basicStudentList) {
-        this.removeByExamId(examId);
+    public void saveBatchStudentCourse(Long examId, List<ExamStudent> basicStudentList) {
+        this.removeByExamIdAndCourseCode(examId, null);
         Map<String, String> stringMap = basicStudentList.stream().collect(Collectors.toMap(ExamStudent::getCourseCode, ExamStudent::getCourseName, (oldValue, newValue) -> oldValue));
         List<ExamCourse> examCourses = new ArrayList<>();
         for (Map.Entry<String, String> entry : stringMap.entrySet()) {
             examCourses.add(new ExamCourse(examId, entry.getKey(), entry.getValue()));
         }
-        this.saveBatch(examCourses);
+        this.saveOrUpdateBatchByMultiId(examCourses);
     }
 
     @Override
-    public void removeByExamId(Long examId) {
+    public void removeByExamIdAndCourseCode(Long examId, String courseCode) {
         QueryWrapper<ExamCourse> queryWrapper = new QueryWrapper<>();
-        queryWrapper.lambda().eq(ExamCourse::getExamId, examId);
+        LambdaQueryWrapper<ExamCourse> lambda = queryWrapper.lambda();
+        lambda.eq(ExamCourse::getExamId, examId);
+        if (StringUtils.isNotBlank(courseCode)) {
+            lambda.eq(ExamCourse::getCourseCode, courseCode);
+        }
         this.remove(queryWrapper);
     }
 
     @Override
     public List<SelectResult> listConditionByExamId(Long examId) {
-
         List<SelectResult> selectResults = new ArrayList<>();
         for (ExamCourse examCourse : this.listByExamId(examId)) {
             SelectResult selectResult = new SelectResult();
@@ -62,7 +69,18 @@ public class ExamCourseServiceImpl extends ServiceImpl<ExamCourseMapper, ExamCou
     public List<ExamCourse> listByExamId(Long examId) {
         QueryWrapper<ExamCourse> queryWrapper = new QueryWrapper<>();
         queryWrapper.lambda().eq(ExamCourse::getExamId, examId)
-                .orderByDesc(ExamCourse::getId);
+                .orderByDesc(ExamCourse::getCourseCode);
         return this.list(queryWrapper);
     }
+
+    @Override
+    public void saveStudentCourse(Long examId, ExamStudent examStudent) {
+        ExamCourse examCourse = this.selectByMultiId(new ExamCourse(examId, examStudent.getCourseCode()));
+        if (examCourse == null) {
+            this.save(new ExamCourse(examId, examStudent.getCourseCode(), examStudent.getCourseName()));
+        } else if (!examCourse.getCourseName().equals(examStudent.getCourseName())) {
+            throw ExceptionResultEnum.ERROR.exception(String.format("考试下已存在课程代码[%s],课程名称为[%s]", examStudent.getCourseCode(), examCourse.getCourseName()));
+        }
+
+    }
 }

+ 67 - 21
paper-library-business/src/main/java/com/qmth/paper/library/business/service/impl/ExamStudentServiceImpl.java

@@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.boot.tools.excel.ExcelReader;
 import com.qmth.boot.tools.excel.enums.ExcelType;
-import com.qmth.boot.tools.excel.model.DataMap;
+import com.qmth.paper.library.business.entity.PaperScanTask;
 import com.qmth.paper.library.business.mapper.ExamStudentMapper;
 import com.qmth.paper.library.business.service.ExamCourseService;
 import com.qmth.paper.library.business.service.ExamStudentService;
@@ -59,29 +59,50 @@ public class ExamStudentServiceImpl extends ServiceImpl<ExamStudentMapper, ExamS
         return this.baseMapper.findStudentPage(new Page<>(pageNumber, pageSize), examId, courseCode, collegeName, majorName, clazzName, queryParams);
     }
 
+    @Transactional
     @Override
-    public void saveBasicStudent(ExamStudent basicStudent) {
+    public void saveBasicStudent(ExamStudent examStudent) {
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         // 验证
-        ExamStudent byStudentCode = this.getByExamIdAndCourseCodeAndStudentCode(basicStudent.getExamId(), basicStudent.getCourseCode(), basicStudent.getStudentCode());
-        if (basicStudent.getId() == null) {
+        ExamStudent byStudentCode = this.getByExamIdAndCourseCodeAndStudentCode(examStudent.getExamId(), examStudent.getCourseCode(), examStudent.getStudentCode());
+        if (examStudent.getId() == null) {
             if (byStudentCode != null) {
-                throw ExceptionResultEnum.ERROR.exception(String.format("学号[%s]在课程%s(%s)下已存在", basicStudent.getStudentCode(), basicStudent.getCourseName(), basicStudent.getCourseCode()));
+                throw ExceptionResultEnum.ERROR.exception(String.format("学号[%s]在课程%s(%s)下已存在", examStudent.getStudentCode(), examStudent.getCourseName(), examStudent.getCourseCode()));
+            }
+            examStudent.setId(SystemConstant.getDbUuid());
+            examStudent.setSchoolId(sysUser.getSchoolId());
+            examStudent.setCreateId(sysUser.getId());
+            examStudent.setCreateTime(System.currentTimeMillis());
+            boolean save = this.save(examStudent);
+
+            if (save) {
+                // 保存课程
+                examCourseService.saveStudentCourse(examStudent.getExamId(), examStudent);
+                // 保存任务(存在则更新考生数量)
+                // 校验是否设置了存储方式
+                SimpleObject recognitionTypeSimpleObject = commonCacheService.getSysSetting(sysUser.getSchoolId()).get(SysSettingConstant.RECOGNITION_TYPE);
+                if (StringUtils.isBlank(recognitionTypeSimpleObject.getValue())) {
+                    throw ExceptionResultEnum.ERROR.exception("识别方式未设置");
+                }
+                SimpleObject storeTypeSimpleObject = commonCacheService.getSysSetting(sysUser.getSchoolId()).get(SysSettingConstant.STORE_TYPE);
+                if (StringUtils.isBlank(storeTypeSimpleObject.getValue())) {
+                    throw ExceptionResultEnum.ERROR.exception("文件存储方式未设置");
+                }
+                RecognitionTypeEnum recognitionType = RecognitionTypeEnum.valueOf(recognitionTypeSimpleObject.getValue());
+                StoreTypeEnum storeType = StoreTypeEnum.valueOf(storeTypeSimpleObject.getValue());
+                paperScanTaskService.addScanTask(examStudent.getExamId(), recognitionType, storeType, examStudent);
             }
-            byStudentCode.setId(SystemConstant.getDbUuid());
-            byStudentCode.setSchoolId(sysUser.getSchoolId());
-            byStudentCode.setCreateId(sysUser.getId());
-            byStudentCode.setCreateTime(System.currentTimeMillis());
         } else {
-            if (!basicStudent.getId().equals(byStudentCode.getId())) {
-                throw ExceptionResultEnum.ERROR.exception(String.format("学号[%s]在课程%s(%s)下已存在", basicStudent.getStudentCode(), basicStudent.getCourseName(), basicStudent.getCourseCode()));
+            if (byStudentCode != null && !examStudent.getId().equals(byStudentCode.getId())) {
+                throw ExceptionResultEnum.ERROR.exception(String.format("学号[%s]在课程%s(%s)下已存在", examStudent.getStudentCode(), examStudent.getCourseName(), examStudent.getCourseCode()));
             }
-            byStudentCode.setId(basicStudent.getId());
-            byStudentCode.setEnable(true);
-            byStudentCode.setUpdateId(sysUser.getId());
-            byStudentCode.setUpdateTime(System.currentTimeMillis());
+            examStudent.setId(examStudent.getId());
+            examStudent.setEnable(true);
+            examStudent.setUpdateId(sysUser.getId());
+            examStudent.setUpdateTime(System.currentTimeMillis());
+            this.updateById(examStudent);
         }
-        this.saveOrUpdate(byStudentCode);
+
     }
 
     @Transactional(rollbackFor = Exception.class)
@@ -98,7 +119,26 @@ public class ExamStudentServiceImpl extends ServiceImpl<ExamStudentMapper, ExamS
             }
         }
         // 删除基础学生
-        return this.removeByIds(ids);
+        this.removeByIds(ids);
+        Map<String, String> stringMap = examStudentList.stream().collect(Collectors.toMap(ExamStudent::getCourseCode, ExamStudent::getCourseName, (oldValue, newValue) -> oldValue));
+        for (Map.Entry<String, String> entry : stringMap.entrySet()) {
+            Long examId = examStudentList.get(0).getExamId();
+            int count = this.countByExamIdAndCourseCode(examId, entry.getKey());
+            PaperScanTask paperScanTask = paperScanTaskService.getByExamIdAndCourseCode(examId, entry.getKey());
+            if (count == 0) {
+                // 删除课程
+                examCourseService.removeByExamIdAndCourseCode(examId, entry.getKey());
+                // 删除任务
+                if (paperScanTask != null) {
+                    paperScanTaskService.removeById(paperScanTask.getId());
+                }
+            } else {
+                if (paperScanTask != null) {
+                    paperScanTaskService.updateStudentCount(paperScanTask);
+                }
+            }
+        }
+        return true;
     }
 
     @Override
@@ -131,9 +171,7 @@ public class ExamStudentServiceImpl extends ServiceImpl<ExamStudentMapper, ExamS
             throw ExceptionResultEnum.ERROR.exception("已开始扫描,导入失败。请清除扫描数据后重试");
         }
         try {
-            System.out.println("大小:" + file.getSize());
             ExcelReader excelReader = ExcelReader.create(ExcelType.XLSX, file.getInputStream(), 0);
-//            List<String[]> dataMapList = excelReader.getDataArrayList();
             List<ExamStudent> basicStudentList = excelReader.getObjectList(ExamStudent.class);
             // 校验excel内容
             validStudentData(semesterId, examId, basicStudentList, storeType, sysUser);
@@ -142,9 +180,9 @@ public class ExamStudentServiceImpl extends ServiceImpl<ExamStudentMapper, ExamS
             // 保存学生
             this.saveBatch(basicStudentList);
             // 保存课程
-            examCourseService.saveStudentCourse(examId, basicStudentList);
+            examCourseService.saveBatchStudentCourse(examId, basicStudentList);
             // 新建任务
-            paperScanTaskService.addScanTask(examId, recognitionType, storeType, basicStudentList);
+            paperScanTaskService.addBatchScanTask(examId, recognitionType, storeType, basicStudentList);
         } catch (IOException e) {
             throw new RuntimeException(e);
         } catch (Exception e) {
@@ -167,6 +205,14 @@ public class ExamStudentServiceImpl extends ServiceImpl<ExamStudentMapper, ExamS
         this.remove(queryWrapper);
     }
 
+    @Override
+    public int countByExamIdAndCourseCode(Long examId, String courseCode) {
+        QueryWrapper<ExamStudent> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(ExamStudent::getExamId, examId)
+                .eq(ExamStudent::getCourseCode, courseCode);
+        return this.count(queryWrapper);
+    }
+
     /**
      * 学生保存公共方法
      */

+ 35 - 1
paper-library-business/src/main/java/com/qmth/paper/library/business/service/impl/PaperScanTaskServiceImpl.java

@@ -86,7 +86,7 @@ public class PaperScanTaskServiceImpl extends ServiceImpl<PaperScanTaskMapper, P
 
     @Transactional
     @Override
-    public void addScanTask(Long examId, RecognitionTypeEnum recognitionType, StoreTypeEnum storeType, List<ExamStudent> basicStudentList) {
+    public void addBatchScanTask(Long examId, RecognitionTypeEnum recognitionType, StoreTypeEnum storeType, List<ExamStudent> basicStudentList) {
         Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
         List<ExamCourse> examCourses = examCourseService.listByExamId(examId);
         List<PaperScanTask> paperScanTaskList = new ArrayList<>();
@@ -114,4 +114,38 @@ public class PaperScanTaskServiceImpl extends ServiceImpl<PaperScanTaskMapper, P
         return this.list(queryWrapper);
     }
 
+    @Override
+    public void addScanTask(Long examId, RecognitionTypeEnum recognitionType, StoreTypeEnum storeType, ExamStudent examStudent) {
+        Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
+        ExamCourse examCourse = examCourseService.selectByMultiId(new ExamCourse(examId, examStudent.getCourseCode()));
+        if (examCourse != null) {
+            PaperScanTask paperScanTask = this.getByExamIdAndCourseCode(examId, examStudent.getCourseCode());
+            if (paperScanTask == null) {
+                String scanTaskName = String.format("%s(%s)", examCourse.getCourseName(), examCourse.getCourseCode());
+                String scanTaskCode = paperLibraryCommonService.getScanTaskCode(schoolId);
+                paperScanTask = new PaperScanTask(schoolId, examId, scanTaskCode, scanTaskName, examCourse.getCourseCode(), examCourse.getCourseName(), recognitionType, storeType, 1);
+                this.save(paperScanTask);
+            } else {
+                this.updateStudentCount(paperScanTask);
+            }
+        }
+    }
+
+    @Override
+    public PaperScanTask getByExamIdAndCourseCode(Long examId, String courseCode) {
+        QueryWrapper<PaperScanTask> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(PaperScanTask::getExamId, examId)
+                .eq(PaperScanTask::getCourseCode, courseCode);
+        return this.getOne(queryWrapper);
+    }
+
+    @Override
+    public void updateStudentCount(PaperScanTask paperScanTask) {
+        int count = examStudentService.countByExamIdAndCourseCode(paperScanTask.getExamId(), paperScanTask.getCourseCode());
+        UpdateWrapper<PaperScanTask> updateWrapper = new UpdateWrapper<>();
+        updateWrapper.lambda().set(PaperScanTask::getStudentCount, count)
+                .eq(PaperScanTask::getId, paperScanTask.getId());
+        this.update(updateWrapper);
+    }
+
 }

+ 3 - 4
paper-library-business/src/main/resources/mapper/ExamCourseMapper.xml

@@ -4,10 +4,9 @@
 
     <!-- 通用查询映射结果 -->
     <resultMap id="BaseResultMap" type="com.qmth.paper.library.business.entity.ExamCourse">
-        <id column="id" property="id" />
-        <result column="exam_id" property="examId" />
-        <result column="course_code" property="courseCode" />
-        <result column="course_name" property="courseName" />
+        <id column="exam_id" property="examId"/>
+        <id column="course_code" property="courseCode"/>
+        <result column="course_name" property="courseName"/>
     </resultMap>
 
 </mapper>

+ 4 - 8
paper-library-common/pom.xml

@@ -106,14 +106,6 @@
             <groupId>com.qmth.boot</groupId>
             <artifactId>data-mybatis-plus</artifactId>
         </dependency>
-<!--        <dependency>-->
-<!--            <groupId>io.springfox</groupId>-->
-<!--            <artifactId>springfox-swagger2</artifactId>-->
-<!--        </dependency>-->
-<!--        <dependency>-->
-<!--            <groupId>io.springfox</groupId>-->
-<!--            <artifactId>springfox-swagger-ui</artifactId>-->
-<!--        </dependency>-->
         <dependency>
             <groupId>com.github.xiaoymin</groupId>
             <artifactId>knife4j-spring-boot-starter</artifactId>
@@ -192,5 +184,9 @@
             <groupId>com.aventrix.jnanoid</groupId>
             <artifactId>jnanoid</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.github.jeffreyning</groupId>
+            <artifactId>mybatisplus-plus</artifactId>
+        </dependency>
     </dependencies>
 </project>

+ 9 - 0
paper-library-common/src/main/java/com/qmth/paper/library/common/bean/dto/SchoolDto.java

@@ -6,6 +6,7 @@ package com.qmth.paper.library.common.bean.dto;
 public class SchoolDto {
 
     private String id;
+    private String code;
     private String name;
     private Boolean enable;
     private String logo;
@@ -18,6 +19,14 @@ public class SchoolDto {
         this.id = id;
     }
 
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
     public String getName() {
         return name;
     }

+ 1 - 1
paper-library-common/src/main/java/com/qmth/paper/library/common/service/impl/AuthInfoServiceImpl.java

@@ -210,7 +210,7 @@ public class AuthInfoServiceImpl implements AuthInfoService {
             QueryWrapper<TSAuth> tsAuthQueryWrapper = new QueryWrapper<>();
             tsAuthQueryWrapper.lambda().in(TSAuth::getSchoolId, orgIdsSet);
             tsAuthService.remove(tsAuthQueryWrapper);
-            tsAuthMapper.insertBatch(tsAuthList);
+            tsAuthService.saveOrUpdateBatch(tsAuthList);
 
             if (!CollectionUtils.isEmpty(basicSchoolSet)) {
                 basicSchoolMapper.insertBatch(basicSchoolSet);

+ 1 - 1
paper-library-common/src/main/resources/mapper/BasicSchoolMapper.xml

@@ -21,7 +21,7 @@
         code, name, enable, access_key, access_secret, remark, create_time, update_time
     </sql>
     <select id="listSchool" resultType="com.qmth.paper.library.common.bean.dto.SchoolDto">
-        select id, name, enable, logo from basic_school where enable = true order by create_time desc
+        select id, code,name, enable, logo from basic_school where enable = true order by create_time desc
     </select>
 
 </mapper>

+ 5 - 7
paper-library/install/mysql/init/paper_library_db.sql

@@ -149,12 +149,10 @@ CREATE TABLE IF NOT EXISTS `basic_verify_code` (
 -- Table structure for exam_course
 -- ----------------------------
 CREATE TABLE IF NOT EXISTS `exam_course` (
-               `id` bigint NOT NULL,
-               `exam_id` bigint DEFAULT NULL COMMENT '考试ID',
-               `course_code` varchar(45) DEFAULT NULL COMMENT '课程代码',
+               `exam_id` bigint NOT NULL COMMENT '考试ID',
+               `course_code` varchar(45) NOT NULL COMMENT '课程代码',
                `course_name` varchar(100) DEFAULT NULL COMMENT '课程名称',
-               PRIMARY KEY (`id`),
-               KEY `idx_1` (`exam_id`,`course_code`)
+               PRIMARY KEY (`exam_id`, `course_code`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
 
 -- ----------------------------
@@ -179,7 +177,7 @@ CREATE TABLE IF NOT EXISTS `exam_student` (
                 `remark` varchar(200) DEFAULT NULL COMMENT '备注',
                 `enable` tinyint DEFAULT '1' COMMENT '可用状态(1:可用,0:不可用)',
                 `source` tinyint(1) DEFAULT '0' COMMENT '是否绑定时自动创建:0-导入或者新建,1-绑定时自动创建',
-                `bind_count` int DEFAULT NULL COMMENT '绑定图片张数',
+                `bind_count` int DEFAULT NULL DEFAULT 0 COMMENT '绑定图片张数',
                 `create_id` bigint DEFAULT NULL COMMENT '创建人id',
                 `create_time` bigint DEFAULT NULL COMMENT '创建时间',
                 `update_id` bigint DEFAULT NULL COMMENT '更新人id',
@@ -238,7 +236,7 @@ CREATE TABLE IF NOT EXISTS `paper_scan_task` (
            `recognition_type` varchar(45) DEFAULT NULL COMMENT '识别方式(条码、OCR、无)',
            `store_type` varchar(45) DEFAULT NULL COMMENT '存储方式(按课程、按考场、按考点)',
            `student_count` int DEFAULT '0' COMMENT '扫描量(份)',
-           `scan_student_count` int DEFAULT NULL COMMENT '扫描学生数量',
+           `scan_student_count` int DEFAULT '0' COMMENT '扫描学生数量',
            `scan_count` int DEFAULT '0' COMMENT '扫描数量',
            `enable` tinyint(1) DEFAULT '0' COMMENT '任务是否已关闭(1-是,0-否)',
            `create_id` bigint DEFAULT NULL COMMENT '创建人',

+ 6 - 4
paper-library/src/main/java/com/qmth/paper/library/PaperLibraryApplication.java

@@ -1,5 +1,6 @@
 package com.qmth.paper.library;
 
+import com.github.jeffreyning.mybatisplus.conf.EnableMPP;
 import com.qmth.boot.core.security.service.CustomizeAuthorizationService;
 import com.qmth.paper.library.auth.PaperLibraryAuthenticationService;
 import com.qmth.paper.library.common.base.CustomizedSqlInjector;
@@ -14,6 +15,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
 
 import javax.annotation.Resource;
 
+@EnableMPP
 @SpringBootApplication(scanBasePackages = "com.qmth.*")
 @MapperScan({"com.qmth.paper.library.business.mapper", "com.qmth.paper.library.common.mapper"})
 //主要就是定义扫描的路径从中找出标识了需要装配的类自动装配到spring的bean容器中,做过web开发的同学一定都有用过@Controller,@Service,@Repository注解,查看其源码你会发现,他们中有一个共同的注解@Component,没错@ComponentScan注解默认就会装配标识了@Controller,@Service,@Repository,@Component注解的类到spring容器中
@@ -38,8 +40,8 @@ public class PaperLibraryApplication {
         };
     }
 
-    @Bean
-    public CustomizedSqlInjector customizedSqlInjector() {
-        return new CustomizedSqlInjector();
-    }
+//    @Bean
+//    public CustomizedSqlInjector customizedSqlInjector() {
+//        return new CustomizedSqlInjector();
+//    }
 }

+ 2 - 0
paper-library/src/main/java/com/qmth/paper/library/api/BasicSchoolController.java

@@ -1,5 +1,6 @@
 package com.qmth.paper.library.api;
 
+import com.qmth.boot.api.annotation.Aac;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.paper.library.common.bean.dto.SchoolDto;
 import com.qmth.paper.library.common.contant.ApiPrefixConstant;
@@ -31,6 +32,7 @@ public class BasicSchoolController {
     /**
      * 学校查询
      */
+    @Aac(auth = false)
     @ApiOperation(value = "查询")
     @RequestMapping(value = "/list", method = RequestMethod.POST)
     public Result list() {

+ 6 - 0
pom.xml

@@ -51,6 +51,7 @@
         <thumbnailator.version>0.4.8</thumbnailator.version>
         <zxing.version>3.5.1</zxing.version>
         <nanoid.version>2.0.0</nanoid.version>
+        <mybatisplus-plus>1.5.1-RELEASE</mybatisplus-plus>
     </properties>
 
     <dependencyManagement>
@@ -299,6 +300,11 @@
                 <artifactId>jnanoid</artifactId>
                 <version>${nanoid.version}</version>
             </dependency>
+            <dependency>
+                <groupId>com.github.jeffreyning</groupId>
+                <artifactId>mybatisplus-plus</artifactId>
+                <version>${mybatisplus-plus}</version>
+            </dependency>
         </dependencies>
     </dependencyManagement>