소스 검색

IP限制修改

qinchao 4 년 전
부모
커밋
f9d48394b8

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

@@ -1417,7 +1417,7 @@ public class ExamController extends ControllerSupport {
 
     @ApiOperation(value = "查询整体控制和学习中心控制",notes = "查询控制")
     @GetMapping("ipLimited/property/{examId}")
-    public Map<String,Integer> ipLimitedProperty(@PathVariable Long examId) {
+    public Map<String,Boolean> ipLimitedProperty(@PathVariable Long examId) {
         return examService.getIpLimitedProperty(examId);
     }
 

+ 1 - 1
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/ExamService.java

@@ -149,7 +149,7 @@ public interface ExamService {
      * @param examId
      * @return Map<String,Object>
      */
-    Map<String, Integer> getIpLimitedProperty(Long examId);
+    Map<String, Boolean> getIpLimitedProperty(Long examId);
 
     /***
      * Description 更新整体控制和学习中心控制

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

@@ -891,14 +891,14 @@ public class ExamServiceImpl implements ExamService {
 
         if (ipLimited) {
             //整体控制
-            Integer totalLimit = getExamLimitProperty(examId, ipTotalLimit.getId(), 0);
-            if (totalLimit == 1) {
+            Boolean totalLimit = getExamLimitProperty(examId, ipTotalLimit.getId(), false);
+            if (totalLimit) {
                 //在白名单中
                 int count = examIpLimitRepo.countByExamIdAndLimitTypeAndIp(examId, IpLimitType.HAS_ACCESS.getId(),realIp);
                 if (count>0) {
                     //学习中心访问控制
-                    Integer centerLimit = getExamLimitProperty(examId,ipCenterLimit.getId(), 0);
-                    if (centerLimit == 1) {
+                    Boolean centerLimit = getExamLimitProperty(examId,ipCenterLimit.getId(), false);
+                    if (centerLimit) {
                         StudentCacheBean studentCache = CacheHelper.getStudent(accessUser.getUserId());
                         Long orgId = studentCache.getOrgId();
                         String key = "IP_" + orgId;
@@ -983,15 +983,15 @@ public class ExamServiceImpl implements ExamService {
     }
 
     @Override
-    public Map<String, Integer> getIpLimitedProperty(Long examId) {
-        Map<String,Integer> map = new HashMap<>();
+    public Map<String, Boolean> getIpLimitedProperty(Long examId) {
+        Map<String,Boolean> map = new HashMap<>();
 
         DynamicEnumManager manager = ExamProperty.getDynamicEnumManager();
         DynamicEnum ipTotalLimit = manager.getByName("IP_TOTAL_LIMIT");
         DynamicEnum ipCenterLimit = manager.getByName("IP_CENTER_LIMIT");
 
-        map.put("totalLimit", getExamLimitProperty(examId,ipTotalLimit.getId(),0));
-        map.put("centerLimit",getExamLimitProperty(examId,ipCenterLimit.getId(),0));
+        map.put("totalLimit", getExamLimitProperty(examId,ipTotalLimit.getId(),false));
+        map.put("centerLimit",getExamLimitProperty(examId,ipCenterLimit.getId(),false));
         return map;
     }
 
@@ -1039,10 +1039,10 @@ public class ExamServiceImpl implements ExamService {
                 .collect(Collectors.toList());
     }
 
-    private Integer getExamLimitProperty(Long examId, Long keyId ,Integer defaultValue) {
+    private Boolean getExamLimitProperty(Long examId, Long keyId ,Boolean defaultValue) {
         ExamPropertyEntity propertyEntity = examPropertyRepo.findByExamIdAndKeyId(examId, keyId);
         return propertyEntity != null && StringUtils.isNotBlank(propertyEntity.getValue())
-                ? Integer.valueOf(propertyEntity.getValue()) : defaultValue;
+                ? Boolean.valueOf(propertyEntity.getValue()) : defaultValue;
     }
 
     private Specification<ExamIpLimitEntity> getSpec(Long examId, Integer limitType, String ip){

+ 2 - 2
examcloud-core-examwork-starter/src/main/resources/exam-properties.xml

@@ -292,12 +292,12 @@
 		<id>49</id>
 		<name>IP_TOTAL_LIMIT</name>
 		<desc>IP访问设置-整体控制</desc>
-		<valueType>INTEGER</valueType>
+		<valueType>BOOLEAN</valueType>
 	</enum>
 	<enum>
 		<id>50</id>
 		<name>IP_CENTER_LIMIT</name>
 		<desc>IP访问设置-学习中心控制</desc>
-		<valueType>INTEGER</valueType>
+		<valueType>BOOLEAN</valueType>
 	</enum>
 </enums>