瀏覽代碼

ip限制逻辑修改

qinchao 4 年之前
父節點
當前提交
385979eb42

+ 2 - 2
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/enums/IpLimitType.java

@@ -12,11 +12,11 @@ public enum IpLimitType {
     /**
      * 允许访问
      */
-    Has_access(0, "允许访问"),
+    HAS_ACCESS(0, "允许访问"),
     /**
      * 禁止访问
      */
-    No_Access(1, "禁止访问");
+    NO_ACCESS(1, "禁止访问");
 
     private Integer id;
 

+ 3 - 6
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/bean/ExamIpLimitInfo.java

@@ -33,10 +33,7 @@ public class ExamIpLimitInfo implements JsonSerializable {
 	 */
 	private String ip;
 
-	/**
-	 * 限制类型:1禁止访问,0允许访问
-	 */
-	private Integer limitType;
+	private String limitType;
 
 	/**
 	 * 创建时间
@@ -80,11 +77,11 @@ public class ExamIpLimitInfo implements JsonSerializable {
 		this.ip = ip;
 	}
 
-	public Integer getLimitType() {
+	public String getLimitType() {
 		return limitType;
 	}
 
-	public void setLimitType(Integer limitType) {
+	public void setLimitType(String limitType) {
 		this.limitType = limitType;
 	}
 

+ 3 - 2
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/impl/ExamServiceImpl.java

@@ -859,6 +859,7 @@ public class ExamServiceImpl implements ExamService {
         pages.getList().forEach(e->{
             ExamIpLimitInfo domain = new ExamIpLimitInfo();
             BeanUtils.copyProperties(e,domain);
+            domain.setLimitType(e.getLimitType() == null ? "" : e.getLimitType().getName());
             Optional<ExamEntity> byId = examRepo.findById(examId);
             byId.ifPresent(examEntity -> domain.setExamName(examEntity.getName()));
             list.add(domain);
@@ -893,7 +894,7 @@ public class ExamServiceImpl implements ExamService {
             Integer totalLimit = getExamLimitProperty(examId, ipTotalLimit.getId(), 0);
             if (totalLimit == 1) {
                 //在白名单中
-                int count = examIpLimitRepo.countByExamIdAndLimitTypeAndIp(examId, IpLimitType.Has_access.getId(),realIp);
+                int count = examIpLimitRepo.countByExamIdAndLimitTypeAndIp(examId, IpLimitType.HAS_ACCESS.getId(),realIp);
                 if (count>0) {
                     //学习中心访问控制
                     Integer centerLimit = getExamLimitProperty(examId,ipCenterLimit.getId(), 0);
@@ -926,7 +927,7 @@ public class ExamServiceImpl implements ExamService {
                 }
             } else {
                 //不在黑名单中
-                int count = examIpLimitRepo.countByExamIdAndLimitTypeAndIp(examId,IpLimitType.No_Access.getId(), realIp);
+                int count = examIpLimitRepo.countByExamIdAndLimitTypeAndIp(examId,IpLimitType.NO_ACCESS.getId(), realIp);
                 return count > 0;
             }
             return true;