Explorar o código

考试科目和试卷加入日志

wangliang %!s(int64=2) %!d(string=hai) anos
pai
achega
3c06f7d863

+ 35 - 0
themis-admin/src/main/java/com/qmth/themis/admin/api/TEExamCourseController.java

@@ -1,12 +1,17 @@
 package com.qmth.themis.admin.api;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.entity.TBUser;
 import com.qmth.themis.business.entity.TEExamCourse;
+import com.qmth.themis.business.entity.TSLog;
 import com.qmth.themis.business.enums.FieldUniqueEnum;
+import com.qmth.themis.business.enums.LogEnum;
 import com.qmth.themis.business.service.TEExamCourseService;
+import com.qmth.themis.business.service.TSLogService;
+import com.qmth.themis.business.util.JacksonUtil;
 import com.qmth.themis.business.util.ServletUtil;
 import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.exception.BusinessException;
@@ -15,14 +20,17 @@ import com.qmth.themis.common.util.ResultUtil;
 import io.swagger.annotations.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeanUtils;
 import org.springframework.dao.DuplicateKeyException;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import javax.validation.constraints.Max;
 import javax.validation.constraints.Min;
+import java.util.List;
 import java.util.Objects;
 
 /**
@@ -42,6 +50,9 @@ public class TEExamCourseController {
     @Resource
     TEExamCourseService teExamCourseService;
 
+    @Resource
+    TSLogService tsLogService;
+
     @ApiOperation(value = "考试科目修改接口")
     @RequestMapping(value = "/course/save", method = RequestMethod.POST)
     @Transactional
@@ -52,6 +63,30 @@ public class TEExamCourseController {
         }
         try {
             TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
+            QueryWrapper<TEExamCourse> teExamCourseQueryWrapper = new QueryWrapper<>();
+            teExamCourseQueryWrapper.lambda()
+                    .eq(TEExamCourse::getExamId, teExamCourse.getExamId())
+                    .eq(TEExamCourse::getCourseCode, teExamCourse.getCourseCode());
+            List<TEExamCourse> teExamCourseDbList = teExamCourseService.list(teExamCourseQueryWrapper);
+
+            if (!CollectionUtils.isEmpty(teExamCourseDbList)) {
+                teExamCourseDbList.forEach(s -> {
+                    TEExamCourse teExamCourseNew = new TEExamCourse();
+                    BeanUtils.copyProperties(s, teExamCourseNew);
+                    teExamCourseNew.setObjectiveShuffle(teExamCourse.getObjectiveShuffle());
+                    teExamCourseNew.setOptionShuffle(teExamCourse.getOptionShuffle());
+                    teExamCourseNew.setMobilePhotoUpload(teExamCourse.getMobilePhotoUpload());
+                    teExamCourseNew.setUpdateId(tbUser.getId());
+                    teExamCourseNew.setUpdateTime(System.currentTimeMillis());
+                    if (Objects.nonNull(s) && !teExamCourseNew.equals(s)) {//不一样则日志记录
+                        tsLogService.save(new TSLog(LogEnum.EXAM_COURSE, teExamCourseNew.getCourseCode(),
+                                JacksonUtil.parseJson(s),
+                                JacksonUtil.parseJson(teExamCourseNew),
+                                tbUser.getId(), teExamCourseNew.getId()));
+                    }
+                });
+            }
+
             UpdateWrapper<TEExamCourse> teExamCourseUpdateWrapper = new UpdateWrapper<>();
             teExamCourseUpdateWrapper.lambda().set(TEExamCourse::getObjectiveShuffle, teExamCourse.getObjectiveShuffle())
                     .set(TEExamCourse::getOptionShuffle, teExamCourse.getOptionShuffle())

+ 22 - 3
themis-admin/src/main/java/com/qmth/themis/admin/api/TEExamPaperController.java

@@ -9,9 +9,7 @@ import com.qmth.themis.business.dto.MqDto;
 import com.qmth.themis.business.entity.*;
 import com.qmth.themis.business.enums.*;
 import com.qmth.themis.business.service.*;
-import com.qmth.themis.business.util.MqUtil;
-import com.qmth.themis.business.util.OssUtil;
-import com.qmth.themis.business.util.ServletUtil;
+import com.qmth.themis.business.util.*;
 import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.exception.BusinessException;
 import com.qmth.themis.common.util.GsonUtil;
@@ -20,6 +18,7 @@ import com.qmth.themis.common.util.ResultUtil;
 import io.swagger.annotations.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeanUtils;
 import org.springframework.dao.DuplicateKeyException;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
@@ -69,6 +68,9 @@ public class TEExamPaperController {
     @Resource
     TOeExamRecordService tOeExamRecordService;
 
+    @Resource
+    TSLogService tsLogService;
+
     @ApiOperation(value = "考试试卷查询接口")
     @RequestMapping(value = "/query", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "考试科目信息", response = TEExamPaper.class)})
@@ -96,7 +98,24 @@ public class TEExamPaperController {
         try {
             TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
             teExamPaperList.forEach(s -> {
+                if (Objects.isNull(s.getId())) {
+                    s.setId(UidUtil.nextId());
+                    s.setCreateTime(System.currentTimeMillis());
+                } else {
+                    TEExamPaper teExamPaperDb = teExamPaperService.getById(s.getId());
+                    TEExamPaper teExamPaper = new TEExamPaper();
+                    BeanUtils.copyProperties(teExamPaperDb, teExamPaper);
+                    teExamPaper.setWeight(s.getWeight());
+                    teExamPaper.setAudioPlayCount(s.getAudioPlayCount());
+                    if (Objects.nonNull(teExamPaperDb) && !teExamPaper.equals(teExamPaperDb)) {//不一样则日志记录
+                        tsLogService.save(new TSLog(LogEnum.EXAM_PAPER, teExamPaper.getName(),
+                                JacksonUtil.parseJson(teExamPaperDb),
+                                JacksonUtil.parseJson(teExamPaper),
+                                tbUser.getId(), teExamPaper.getId()));
+                    }
+                }
                 s.setUpdateId(tbUser.getId());
+                s.setUpdateTime(System.currentTimeMillis());
                 teExamPaperService.saveOrUpdate(s);
             });
         } catch (Exception e) {

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 6 - 2
themis-business/src/main/java/com/qmth/themis/business/entity/TEExam.java


+ 6 - 2
themis-business/src/main/java/com/qmth/themis/business/entity/TEExamActivity.java

@@ -137,8 +137,12 @@ public class TEExamActivity extends BaseEntity {
 
     @Override
     public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
         TEExamActivity that = (TEExamActivity) o;
         return Objects.equals(examId, that.examId) && Objects.equals(code, that.code) && Objects.equals(prepareSeconds, that.prepareSeconds) && Objects.equals(maxDurationSeconds, that.maxDurationSeconds) && Objects.equals(enable, that.enable) && Objects.equals(openingSeconds, that.openingSeconds) && Objects.equals(startTime, that.startTime) && Objects.equals(finishTime, that.finishTime);
     }

+ 35 - 0
themis-business/src/main/java/com/qmth/themis/business/entity/TEExamCourse.java

@@ -8,6 +8,8 @@ import com.qmth.themis.business.util.UidUtil;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
+import java.util.Objects;
+
 /**
  * @Description: 考试科目
  * @Param:
@@ -155,4 +157,37 @@ public class TEExamCourse extends BaseEntity {
     public void setMobilePhotoUpload(Integer mobilePhotoUpload) {
         this.mobilePhotoUpload = mobilePhotoUpload;
     }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        TEExamCourse that = (TEExamCourse) o;
+        return Objects.equals(examId, that.examId) && Objects.equals(courseCode, that.courseCode) && Objects.equals(courseName, that.courseName) && Objects.equals(objectiveShuffle, that.objectiveShuffle) && Objects.equals(optionShuffle, that.optionShuffle) && Objects.equals(paperCount, that.paperCount) && Objects.equals(hasAnswer, that.hasAnswer) && Objects.equals(audioPlayCount, that.audioPlayCount) && Objects.equals(hasAudio, that.hasAudio) && Objects.equals(mobilePhotoUpload, that.mobilePhotoUpload);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(examId, courseCode, courseName, objectiveShuffle, optionShuffle, paperCount, hasAnswer, audioPlayCount, hasAudio, mobilePhotoUpload);
+    }
+
+    @Override
+    public String toString() {
+        return "TEExamCourse{" +
+                "examId=" + examId +
+                ", courseCode='" + courseCode + '\'' +
+                ", courseName='" + courseName + '\'' +
+                ", objectiveShuffle=" + objectiveShuffle +
+                ", optionShuffle=" + optionShuffle +
+                ", paperCount=" + paperCount +
+                ", hasAnswer=" + hasAnswer +
+                ", audioPlayCount=" + audioPlayCount +
+                ", hasAudio=" + hasAudio +
+                ", mobilePhotoUpload=" + mobilePhotoUpload +
+                '}';
+    }
 }

+ 46 - 25
themis-business/src/main/java/com/qmth/themis/business/entity/TEExamPaper.java

@@ -8,6 +8,8 @@ import com.qmth.themis.business.enums.EncryptModeEnum;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
+import java.util.Objects;
+
 /**
  * @Description: 考试试卷
  * @Param:
@@ -19,22 +21,22 @@ import io.swagger.annotations.ApiModelProperty;
 public class TEExamPaper extends BaseEntity {
 
     /**
-	 * 
-	 */
-	private static final long serialVersionUID = -3182356952124087406L;
+     *
+     */
+    private static final long serialVersionUID = -3182356952124087406L;
 
-	@ApiModelProperty(value = "试卷名称")
+    @ApiModelProperty(value = "试卷名称")
     @TableField(value = "name")
     private String name;
 
     @ApiModelProperty(value = "试卷总分")
     @TableField(value = "total_score")
     private Double totalScore;
-    
+
     @ApiModelProperty(value = "试卷客观题总分")
     @TableField(value = "total_objective_score")
     private Double totalObjectiveScore;
-    
+
     @ApiModelProperty(value = "试卷主观题总分")
     @TableField(value = "total_subjective_score")
     private Double totalSubjectiveScore;
@@ -46,7 +48,7 @@ public class TEExamPaper extends BaseEntity {
     @ApiModelProperty(value = "题干md5")
     @TableField(value = "paper_md5")
     private String paperMd5;
-    
+
     @ApiModelProperty(value = "阅卷用试卷json路径")
     @TableField(value = "paper_view_path")
     private String paperViewPath;
@@ -224,29 +226,29 @@ public class TEExamPaper extends BaseEntity {
         this.audioPlayCount = audioPlayCount;
     }
 
-	public String getPaperViewPath() {
-		return paperViewPath;
-	}
+    public String getPaperViewPath() {
+        return paperViewPath;
+    }
 
-	public void setPaperViewPath(String paperViewPath) {
-		this.paperViewPath = paperViewPath;
-	}
+    public void setPaperViewPath(String paperViewPath) {
+        this.paperViewPath = paperViewPath;
+    }
 
-	public Double getTotalObjectiveScore() {
-		return totalObjectiveScore;
-	}
+    public Double getTotalObjectiveScore() {
+        return totalObjectiveScore;
+    }
 
-	public void setTotalObjectiveScore(Double totalObjectiveScore) {
-		this.totalObjectiveScore = totalObjectiveScore;
-	}
+    public void setTotalObjectiveScore(Double totalObjectiveScore) {
+        this.totalObjectiveScore = totalObjectiveScore;
+    }
 
-	public Double getTotalSubjectiveScore() {
-		return totalSubjectiveScore;
-	}
+    public Double getTotalSubjectiveScore() {
+        return totalSubjectiveScore;
+    }
 
-	public void setTotalSubjectiveScore(Double totalSubjectiveScore) {
-		this.totalSubjectiveScore = totalSubjectiveScore;
-	}
+    public void setTotalSubjectiveScore(Double totalSubjectiveScore) {
+        this.totalSubjectiveScore = totalSubjectiveScore;
+    }
 
     public static long getSerialVersionUID() {
         return serialVersionUID;
@@ -267,4 +269,23 @@ public class TEExamPaper extends BaseEntity {
     public void setStructMd5(String structMd5) {
         this.structMd5 = structMd5;
     }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        TEExamPaper that = (TEExamPaper) o;
+        return Objects.equals(name, that.name) && Objects.equals(totalScore, that.totalScore) && Objects.equals(totalObjectiveScore, that.totalObjectiveScore) && Objects.equals(totalSubjectiveScore, that.totalSubjectiveScore) && Objects.equals(paperPath, that.paperPath) && Objects.equals(paperMd5, that.paperMd5) && Objects.equals(paperViewPath, that.paperViewPath) && Objects.equals(decryptSecret, that.decryptSecret) && encryptMode == that.encryptMode && Objects.equals(needVoiceAnswer, that.needVoiceAnswer) && Objects.equals(examId, that.examId) && Objects.equals(courseCode, that.courseCode) && Objects.equals(code, that.code) && Objects.equals(answerPath, that.answerPath) && Objects.equals(hasAudio, that.hasAudio) && Objects.equals(weight, that.weight) && Objects.equals(audioPlayCount, that.audioPlayCount) && Objects.equals(structPath, that.structPath) && Objects.equals(structMd5, that.structMd5) && Objects.equals(decryptVector, that.decryptVector);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(name, totalScore, totalObjectiveScore, totalSubjectiveScore, paperPath, paperMd5, paperViewPath, decryptSecret, encryptMode, needVoiceAnswer, examId, courseCode, code, answerPath, hasAudio, weight, audioPlayCount, structPath, structMd5, decryptVector);
+    }
+
+
 }

+ 5 - 1
themis-business/src/main/java/com/qmth/themis/business/enums/LogEnum.java

@@ -17,7 +17,11 @@ public enum LogEnum {
 
     EXAM("考试批次"),
 
-    EXAM_ACTIVITY("考试场次");
+    EXAM_ACTIVITY("考试场次"),
+
+    EXAM_PAPER("考试试卷"),
+
+    EXAM_COURSE("考试科目");
 
     private String title;
 

+ 0 - 1
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamServiceImpl.java

@@ -394,7 +394,6 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
                 return i;// 选中
             }
         }
-
         return -1;
     }
 

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio