ソースを参照

Merge remote-tracking branch 'origin/dev' into dev

wangliang 5 年 前
コミット
df8d70038f

+ 9 - 0
themis-business/src/main/java/com/qmth/themis/business/cache/RedisKeyHelper.java

@@ -0,0 +1,9 @@
+package com.qmth.themis.business.cache;
+
+public class RedisKeyHelper {
+	private static String examActivityKeyPrefix = "exam_activity::";
+
+	public static String examActivityCacheKey(Long activityId) {
+		return examActivityKeyPrefix + activityId;
+	}
+}

+ 111 - 0
themis-business/src/main/java/com/qmth/themis/business/cache/bean/ExamActivityCacheBean.java

@@ -0,0 +1,111 @@
+package com.qmth.themis.business.cache.bean;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import io.swagger.annotations.ApiModelProperty;
+
+public class ExamActivityCacheBean implements Serializable {
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = -5888311300472703230L;
+
+	@ApiModelProperty(value = "主键")
+	private Long id;
+	@ApiModelProperty(value = "批次id")
+	private Long examId;
+
+	@ApiModelProperty(value = "场次代码")
+	private String code;
+
+	@ApiModelProperty(value = "提前多长时间开始候考(分钟)")
+	private Integer prepareSeconds;
+
+	@ApiModelProperty(value = "最大考试时长")
+	private Integer maxDurationSeconds;
+
+	@ApiModelProperty(value = "是否启用,0:停用,1:启用")
+	private Integer enable;
+
+	@ApiModelProperty(value = "允许开考时长(分钟)")
+	private Integer openingSeconds;
+
+	@ApiModelProperty(value = "开考时间")
+	private Date startTime;
+
+	@ApiModelProperty(value = "结束时间")
+	private Date finishTime;
+
+	public Long getExamId() {
+		return examId;
+	}
+
+	public void setExamId(Long examId) {
+		this.examId = examId;
+	}
+
+	public String getCode() {
+		return code;
+	}
+
+	public void setCode(String code) {
+		this.code = code;
+	}
+
+	public Integer getPrepareSeconds() {
+		return prepareSeconds;
+	}
+
+	public void setPrepareSeconds(Integer prepareSeconds) {
+		this.prepareSeconds = prepareSeconds;
+	}
+
+	public Integer getMaxDurationSeconds() {
+		return maxDurationSeconds;
+	}
+
+	public void setMaxDurationSeconds(Integer maxDurationSeconds) {
+		this.maxDurationSeconds = maxDurationSeconds;
+	}
+
+	public Integer getEnable() {
+		return enable;
+	}
+
+	public void setEnable(Integer enable) {
+		this.enable = enable;
+	}
+
+	public Integer getOpeningSeconds() {
+		return openingSeconds;
+	}
+
+	public void setOpeningSeconds(Integer openingSeconds) {
+		this.openingSeconds = openingSeconds;
+	}
+
+	public Date getStartTime() {
+		return startTime;
+	}
+
+	public void setStartTime(Date startTime) {
+		this.startTime = startTime;
+	}
+
+	public Date getFinishTime() {
+		return finishTime;
+	}
+
+	public void setFinishTime(Date finishTime) {
+		this.finishTime = finishTime;
+	}
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+}

+ 7 - 0
themis-business/src/main/java/com/qmth/themis/business/service/TEExamActivityService.java

@@ -2,6 +2,7 @@ package com.qmth.themis.business.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.themis.business.cache.bean.ExamActivityCacheBean;
 import com.qmth.themis.business.entity.TEExamActivity;
 
 import java.util.List;
@@ -77,4 +78,10 @@ public interface TEExamActivityService extends IService<TEExamActivity> {
      * @return
      */
     public List<Map> getWaitingExam(Long studentId, Long examId,Long examActivityId);
+
+	/**获取场次缓存
+	 * @param examActivityId
+	 * @return
+	 */
+	ExamActivityCacheBean getExamActivityCacheBean(Long examActivityId);
 }

+ 2 - 2
themis-business/src/main/java/com/qmth/themis/business/service/TEExamService.java

@@ -40,9 +40,9 @@ public interface TEExamService extends IService<TEExam> {
     public List<Map> getWaitingExam(Long studentId);
 
 	/** 开始候考
-	 * @param id
+	 * @param studentId
 	 * @param activityId
 	 * @return
 	 */
-	public ExamPrepareBean prepare(Long id, Long activityId);
+	public ExamPrepareBean prepare(Long studentId, Long activityId);
 }

+ 32 - 6
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamActivityServiceImpl.java

@@ -1,16 +1,19 @@
 package com.qmth.themis.business.service.impl;
 
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Resource;
+
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.stereotype.Service;
+
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.themis.business.cache.bean.ExamActivityCacheBean;
 import com.qmth.themis.business.dao.TEExamActivityMapper;
 import com.qmth.themis.business.entity.TEExamActivity;
 import com.qmth.themis.business.service.TEExamActivityService;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
 
 /**
  * @Description: 考试场次 服务实现类
@@ -107,4 +110,27 @@ public class TEExamActivityServiceImpl extends ServiceImpl<TEExamActivityMapper,
     public List<Map> getWaitingExam(Long studentId, Long examId, Long examActivityId) {
         return teExamActivityMapper.getWaitingExam(studentId, examId, examActivityId);
     }
+    
+    @Cacheable(value = "exam_activity", key = "#examActivityId",unless = "#result == null")
+    @Override
+    public ExamActivityCacheBean getExamActivityCacheBean(Long examActivityId) {
+    	ExamActivityCacheBean ret=null;
+    	TEExamActivity ac=getById(examActivityId);
+    	if(ac==null) {
+    		return ret;
+    	}
+    	if(ac.getEnable()!=null&&ac.getEnable().intValue()==0) {
+    		return ret;
+    	}
+    	ret=new ExamActivityCacheBean();
+    	ret.setId(ac.getId());
+    	ret.setCode(ac.getCode());
+    	ret.setExamId(ac.getExamId());
+    	ret.setPrepareSeconds(ac.getPrepareSeconds());
+    	ret.setMaxDurationSeconds(ac.getMaxDurationSeconds());
+    	ret.setOpeningSeconds(ac.getOpeningSeconds());
+    	ret.setStartTime(ac.getStartTime());
+    	ret.setFinishTime(ac.getFinishTime());
+        return ret;
+    }
 }

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

@@ -8,6 +8,7 @@ import com.qmth.themis.business.entity.TEExam;
 import com.qmth.themis.business.service.TEExamActivityService;
 import com.qmth.themis.business.service.TEExamService;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.util.List;
@@ -65,8 +66,9 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         return list;
     }
 
+    @Transactional
 	@Override
-	public ExamPrepareBean prepare(Long id, Long activityId) {
+	public ExamPrepareBean prepare(Long studentId, Long activityId) {
 		// TODO Auto-generated method stub
 		return null;
 	}

+ 11 - 0
themis-business/src/main/java/com/qmth/themis/business/util/RedisUtil.java

@@ -285,6 +285,17 @@ public class RedisUtil {
     public void set(String key, Object o, long time, TimeUnit timeUnit) {
         redisTemplate.opsForValue().set(key, o, time, timeUnit);
     }
+    
+    /**
+     * 设置缓存
+     *
+     * @param key
+     * @param o
+     * @param time SECONDS
+     */
+    public void set(String key, Object o, long time) {
+        set(key, o, time, TimeUnit.SECONDS);
+    }
 
     /**
      * 获取缓存