Browse Source

ip限制逻辑修改

qinchao 4 years ago
parent
commit
7235090ea7

+ 1 - 1
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/ExamController.java

@@ -1562,7 +1562,7 @@ public class ExamController extends ControllerSupport {
         boolean ipLimited = examService.getIpLimited(request, examId, accessUser);
         Map<String, Object> map = new HashMap<>();
         map.put("limited",ipLimited);
-        if(ipLimited){
+        if (ipLimited) {
             map.put("desc","该考试当前考生受限");
         }
         return map;

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

@@ -911,7 +911,7 @@ public class ExamServiceImpl implements ExamService {
                                         // IP取前三段
                                         clientIp = clientIp.substring(0, clientIp.lastIndexOf(".") + 1);
                                         if (realIp.startsWith(clientIp)) {
-                                            return false;
+                                            return true;
                                         }
                                     }
                                 }
@@ -921,13 +921,13 @@ public class ExamServiceImpl implements ExamService {
                     }
                 }
             } else {
-                //在黑名单中
+                //在黑名单中
                 int count = examIpLimitRepo.countByExamIdAndLimitTypeAndIp(examId,IpLimitType.No_Access.getId(), realIp);
-                return count != 0;
+                return count > 0;
             }
 
         }
-        return true;
+        return false;
     }
 
     private String getIp(HttpServletRequest request) {