qinchao il y a 4 ans
Parent
commit
63954a4755

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

@@ -65,7 +65,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.*;
 import org.springframework.data.domain.Sort.Direction;
 import org.springframework.data.jpa.domain.Specification;
-import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.commons.CommonsMultipartFile;
@@ -144,9 +143,6 @@ public class ExamController extends ControllerSupport {
     @Autowired
     ExamSettingsCache examSettingsCache;
 
-    @Autowired
-    JdbcTemplate jdbcTemplate;
-
     private static final String[] EXAM_ORG_SETTINGS_EXCEL_HEADER = new String[]{"学习中心ID", "学习中心代码",
             "学习中心名称", "是否可以考试(是/否)", "开始考试时间 yyyy-MM-dd hh:mm:ss", "结束考试时间 yyyy-MM-dd hh:mm:ss"};
 
@@ -1307,7 +1303,7 @@ public class ExamController extends ControllerSupport {
      * @author WANGWEI
      */
     @ApiOperation(value = "考试IP限制", notes = "")
-    @GetMapping("ipLimit/{examId}")
+    //@GetMapping("ipLimit/{examId}")
     public Map<String, Object> ipLimit(HttpServletRequest request, @PathVariable Long examId) {
         User accessUser = getAccessUser();
         StudentCacheBean studentCache = CacheHelper.getStudent(accessUser.getUserId());
@@ -1453,15 +1449,12 @@ public class ExamController extends ControllerSupport {
         if (CollectionUtils.isEmpty(lineList)) {
             throw new StatusException("100111", "Excel无内容");
         }
-
         if (10001 < lineList.size()) {
             throw new StatusException("100112", "数据行数不能超过10000");
         }
-        List<Map<String, Object>> failRecords = Collections
-                .synchronizedList(new ArrayList<>());
+        List<Map<String, Object>> failRecords = Collections.synchronizedList(new ArrayList<>());
 
         List<ExamIpLimitEntity> list = Lists.newArrayList();
-
         for (int i = 0; i < lineList.size(); i++) {
             String[] line = lineList.get(i);
             if (0 == i) {
@@ -1470,7 +1463,6 @@ public class ExamController extends ControllerSupport {
                 }
                 continue;
             }
-
             boolean hasError = false;
             StringBuilder msg = new StringBuilder();
 
@@ -1478,7 +1470,6 @@ public class ExamController extends ControllerSupport {
             entity.setExamId(examId);
 
             String ip = line[0];
-
             if (StringUtils.isBlank(ip)) {
                 msg.append("  IP地址不能为空");
                 hasError = true;
@@ -1565,16 +1556,14 @@ public class ExamController extends ControllerSupport {
     }
 
     @ApiOperation(value = "检查是否Ip限制",notes = "检查是否Ip限制")
-    @GetMapping("ipLimited/{examId}")
-    public boolean ipLimited(HttpServletRequest request, @PathVariable Long examId) {
+    @GetMapping("ipLimit/{examId}")
+    public Map<String, Object> ipLimited(HttpServletRequest request, @PathVariable Long examId) {
         User accessUser = getAccessUser();
-        return examService.getIpLimited(request, examId, accessUser);
-    }
-
-    private Integer getExamBooleanProperty(Long examId, Integer keyId) {
-        String valueSql="SELECT value FROM ec_e_exam_prop WHERE exam_id ="+examId+" AND key_id="+keyId;
-        List<Integer> list = jdbcTemplate.query(valueSql, (rs, rowNum) -> rs.getInt("value"));
-        return !CollectionUtils.isEmpty(list) ? list.get(0) : 0;
+        boolean ipLimited = examService.getIpLimited(request, examId, accessUser);
+        Map<String, Object> map = new HashMap<>();
+        map.put("limited",ipLimited);
+        map.put("desc","该考试当前考生受限");
+        return map;
     }
 
     @ApiOperation(value = "是否可以微信作答", notes = "")