Browse Source

加入系统日志

wangliang 2 years ago
parent
commit
9ea3b13625

+ 0 - 4
themis-admin/src/main/java/com/qmth/themis/admin/api/TEExamController.java

@@ -47,7 +47,6 @@ import java.util.stream.Collectors;
 @RequestMapping("/${prefix.url.admin}/exam")
 @Validated
 public class TEExamController {
-
     private final static Logger log = LoggerFactory.getLogger(TEExamController.class);
 
     @Resource
@@ -237,9 +236,6 @@ public class TEExamController {
                     }
                 }
             }
-//            TEExam teExamDb = teExamService.getById(teExam.getId());
-//            log.info("equals:{}", teExam.equals(teExamDb));
-//            log.info("equals str:{}", teExam.toString().equals(teExamDb.toString()));
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);
             if (Objects.nonNull(teExam) && Objects.nonNull(teExam.getId()) && Objects.nonNull(activityCode)) {

+ 29 - 0
themis-business/src/main/java/com/qmth/themis/business/entity/TEExamActivity.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:
@@ -131,4 +133,31 @@ public class TEExamActivity extends BaseEntity {
     public void setFinishTime(Long finishTime) {
         this.finishTime = finishTime;
     }
+
+    @Override
+    public boolean equals(Object o) {
+        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);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(examId, code, prepareSeconds, maxDurationSeconds, enable, openingSeconds, startTime, finishTime);
+    }
+
+    @Override
+    public String toString() {
+        return "TEExamActivity{" +
+                "examId=" + examId +
+                ", code='" + code + '\'' +
+                ", prepareSeconds=" + prepareSeconds +
+                ", maxDurationSeconds=" + maxDurationSeconds +
+                ", enable=" + enable +
+                ", openingSeconds=" + openingSeconds +
+                ", startTime=" + startTime +
+                ", finishTime=" + finishTime +
+                '}';
+    }
 }

+ 15 - 4
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamActivityServiceImpl.java

@@ -15,15 +15,14 @@ import com.qmth.themis.business.dto.response.MonitorStreamDto;
 import com.qmth.themis.business.dto.response.TEExamActivityDto;
 import com.qmth.themis.business.dto.response.TEExamActivityQueryDto;
 import com.qmth.themis.business.dto.response.TEExamActivityWaitDto;
-import com.qmth.themis.business.entity.TBUser;
-import com.qmth.themis.business.entity.TEAudio;
-import com.qmth.themis.business.entity.TEExam;
-import com.qmth.themis.business.entity.TEExamActivity;
+import com.qmth.themis.business.entity.*;
 import com.qmth.themis.business.enums.*;
 import com.qmth.themis.business.service.*;
 import com.qmth.themis.business.util.*;
 import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.exception.BusinessException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.cache.annotation.CacheEvict;
 import org.springframework.cache.annotation.CachePut;
 import org.springframework.cache.annotation.Cacheable;
@@ -48,6 +47,7 @@ import java.util.stream.Collectors;
  */
 @Service
 public class TEExamActivityServiceImpl extends ServiceImpl<TEExamActivityMapper, TEExamActivity> implements TEExamActivityService {
+    private final static Logger log = LoggerFactory.getLogger(TEExamActivityServiceImpl.class);
 
     @Resource
     private TEExamActivityMapper teExamActivityMapper;
@@ -76,6 +76,9 @@ public class TEExamActivityServiceImpl extends ServiceImpl<TEExamActivityMapper,
     @Resource
     TEAudioService teAudioService;
 
+    @Resource
+    TSLogService tsLogService;
+
     /**
      * 表是否存在
      *
@@ -358,6 +361,14 @@ public class TEExamActivityServiceImpl extends ServiceImpl<TEExamActivityMapper,
                     if (count == 0) {
                         teAudioList.add(new TEAudio(tbUser.getOrgId(), s.getId(), 2L, AudioTypeEnum.AFTER.getTitle(), AudioTypeEnum.AFTER, AudioDefaultEnum.SYS, tbUser.getId(), SystemConstant.AFTER_AUDIO_SECOND));//考试结束前语音
                     }
+                    TEExamActivity teExamActivityDb = this.getById(s.getId());
+                    s.setCode(teExamActivityDb.getCode());
+                    if (!s.equals(teExamActivityDb)) {//不一样则日志记录
+                        tsLogService.save(new TSLog(LogEnum.EXAM_ACTIVITY, s.getCode(),
+                                JacksonUtil.parseJson(teExamActivityDb),
+                                JacksonUtil.parseJson(s),
+                                tbUser.getId(), s.getId()));
+                    }
                 } else {
                     s.setId(uidUtil.getId());
                     s.setCreateId(tbUser.getId());