فهرست منبع

Merge branch 'master' of http://git.qmth.com.cn/ExamCloud-3/examcloud-support.git

xiatian 5 سال پیش
والد
کامیت
5327359f3f

+ 0 - 1
.gitignore

@@ -16,7 +16,6 @@ buildNumber.properties
 target/
 .idea/
 *.iml
-*test/
 # Package Files #
 *.jar
 

+ 20 - 0
src/main/java/cn/com/qmth/examcloud/support/enums/HandInExamType.java

@@ -0,0 +1,20 @@
+package cn.com.qmth.examcloud.support.enums;
+
+
+/**
+ * @Description 交卷类型
+ * @Author lideyin
+ * @Date 2019/8/1 18:07
+ * @Version 1.0
+ */
+public enum HandInExamType {
+    /**
+     * 手工交卷
+     */
+    MANUAL,
+    /**
+     * 自动交卷
+     */
+    AUTO
+
+}

+ 14 - 0
src/main/java/cn/com/qmth/examcloud/support/examing/ExamRecordData.java

@@ -5,6 +5,7 @@ import java.util.Date;
 import cn.com.qmth.examcloud.api.commons.enums.ExamType;
 import cn.com.qmth.examcloud.api.commons.exchange.JsonSerializable;
 import cn.com.qmth.examcloud.support.enums.ExamRecordStatus;
+import cn.com.qmth.examcloud.support.enums.HandInExamType;
 
 public class ExamRecordData implements JsonSerializable {
 
@@ -116,6 +117,11 @@ public class ExamRecordData implements JsonSerializable {
     // 考试记录状态
     private ExamRecordStatus examRecordStatus;
 
+    /**
+     * 交卷类型
+     */
+    private HandInExamType handInExamType;
+
     public Long getId() {
         return id;
     }
@@ -283,4 +289,12 @@ public class ExamRecordData implements JsonSerializable {
     public void setExamRecordStatus(ExamRecordStatus examRecordStatus) {
         this.examRecordStatus = examRecordStatus;
     }
+
+    public HandInExamType getHandInExamType() {
+        return handInExamType;
+    }
+
+    public void setHandInExamType(HandInExamType handInExamType) {
+        this.handInExamType = handInExamType;
+    }
 }

+ 8 - 4
src/main/java/cn/com/qmth/examcloud/support/redis/RedisKeyBuilder.java

@@ -1,14 +1,18 @@
 package cn.com.qmth.examcloud.support.redis;
 
 /**
- * Redis key构建器
+ * Redis key构建器接口
  *
  * @author WANGWEI
  * @date 2019年8月16日
  * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
  */
-public class RedisKeyBuilder {
-	
-	
+public interface RedisKeyBuilder {
+
+	@RedisKeyDefine(value = "网考考试记录", Prefix = "OE_ERD")
+	String examRecordDataKey(Long examRecordDateId);
+
+	@RedisKeyDefine(value = "网考作答", Prefix = "OE_ANSWER")
+	String studentAnswerKey(Long examRecordDateId, Integer order);
 
 }

+ 24 - 0
src/main/java/cn/com/qmth/examcloud/support/redis/RedisKeyDefine.java

@@ -0,0 +1,24 @@
+package cn.com.qmth.examcloud.support.redis;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * redis key定义
+ *
+ * @author WANGWEI
+ * @date 2019年12月12日
+ * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
+ */
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface RedisKeyDefine {
+
+	String value();
+
+	String Prefix();
+}

+ 59 - 0
src/main/java/cn/com/qmth/examcloud/support/redis/RedisKeyHelper.java

@@ -0,0 +1,59 @@
+package cn.com.qmth.examcloud.support.redis;
+
+import java.lang.reflect.Method;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.cglib.proxy.Enhancer;
+import org.springframework.cglib.proxy.MethodInterceptor;
+import org.springframework.cglib.proxy.MethodProxy;
+
+/**
+ * redis key helper
+ *
+ * @author WANGWEI
+ * @date 2019年12月12日
+ * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
+ */
+public class RedisKeyHelper {
+
+	private static RedisKeyBuilder redisKeyBuilder;
+
+	/**
+	 * 创建 {@link RedisKeyBuilder} 实例
+	 *
+	 * @author WANGWEI
+	 */
+	private static void newInstance() {
+		Enhancer enhancer = new Enhancer();
+		enhancer.setSuperclass(RedisKeyBuilder.class);
+		enhancer.setCallback(new MethodInterceptor() {
+			@Override
+			public Object intercept(Object obj, Method method, Object[] objects,
+					MethodProxy methodProxy) throws Throwable {
+				RedisKeyDefine define = method.getAnnotation(RedisKeyDefine.class);
+				String prefix = define.Prefix();
+				String key = prefix + ":" + StringUtils.join(objects, '_');
+				return key;
+			}
+		});
+		redisKeyBuilder = (RedisKeyBuilder) enhancer.create();
+	}
+
+	/**
+	 * 获取 {@link RedisKeyBuilder} 实例
+	 *
+	 * @author WANGWEI
+	 * @return
+	 */
+	public static RedisKeyBuilder getBuilder() {
+		if (null == redisKeyBuilder) {
+			synchronized (RedisKeyHelper.class) {
+				if (null == redisKeyBuilder) {
+					newInstance();
+				}
+			}
+		}
+		return redisKeyBuilder;
+	}
+
+}

+ 13 - 0
src/test/java/cn/com/qmth/examcloud/support/test/RedisKeyBuilderTest.java

@@ -0,0 +1,13 @@
+package cn.com.qmth.examcloud.support.test;
+
+import cn.com.qmth.examcloud.support.redis.RedisKeyHelper;
+
+public class RedisKeyBuilderTest {
+
+	public static void main(String[] args) {
+
+		System.out.println(RedisKeyHelper.getBuilder().examRecordDataKey(10L));
+		System.out.println(RedisKeyHelper.getBuilder().studentAnswerKey(10L, 1));
+	}
+
+}