|
@@ -1418,8 +1418,8 @@ public class ExamController extends ControllerSupport {
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "保存ip限制信息",notes = "保存ip限制")
|
|
|
- @PostMapping("ipLimited/{ids}")
|
|
|
- public void save(@PathVariable String ids, @RequestBody ExamIpLimitEntity entity) {
|
|
|
+ @PostMapping("ipLimited")
|
|
|
+ public void save(String ids, @RequestBody ExamIpLimitEntity entity) {
|
|
|
|
|
|
//ids不为空,说明是批量设置限制类型
|
|
|
if (StringUtils.isNotBlank(ids)) {
|
|
@@ -1473,24 +1473,30 @@ public class ExamController extends ControllerSupport {
|
|
|
|
|
|
@ApiOperation(value = "查询整体控制和学习中心控制",notes = "查询控制")
|
|
|
@GetMapping("ipLimited/property/{examId}")
|
|
|
- public Map<String,Boolean> ipLimitedProperty(@PathVariable Long examId) {
|
|
|
- Map<String,Boolean> map = new HashMap<>();
|
|
|
+ public Map<String,Integer> ipLimitedProperty(@PathVariable Long examId) {
|
|
|
+ Map<String,Integer> map = new HashMap<>();
|
|
|
map.put("totalLimit", getExamBooleanProperty(examId,49));
|
|
|
map.put("centerLimit",getExamBooleanProperty(examId,50));
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "修改整体控制和学习中心控制",notes = "修改控制")
|
|
|
- @PutMapping("ipLimited/property/{examId}")
|
|
|
- public void ipLimitedProperty(@PathVariable Long examId, @RequestBody Map<String,Boolean> map) {
|
|
|
+ @PostMapping("ipLimited/property/{examId}")
|
|
|
+ public void ipLimitedProperty(@PathVariable Long examId, @RequestBody Map<String,Integer> map) {
|
|
|
updateExamProperty(examId,49,map.get("totalLimit"));
|
|
|
updateExamProperty(examId,50,map.get("centerLimit"));
|
|
|
}
|
|
|
|
|
|
private void updateExamProperty(Long examId, Integer keyId, Object value) {
|
|
|
- //虚拟摄像头进入待审核,且有虚拟摄像头的
|
|
|
- String valueSql="update ec_e_exam_prop set value = '"+value+"'where exam_id ="+examId+" AND key_id="+keyId;
|
|
|
- jdbcTemplate.update(valueSql);
|
|
|
+ String countSql="select count(1) from ec_e_exam_prop where exam_id ="+examId+" AND key_id="+keyId;
|
|
|
+ Integer count = jdbcTemplate.queryForObject(countSql, Integer.class);
|
|
|
+ if (count==0){
|
|
|
+ String valueSql="insert into ec_e_exam_prop values (null,NOW(),NOW(),"+examId+","+keyId+","+value+")";
|
|
|
+ jdbcTemplate.update(valueSql);
|
|
|
+ } else {
|
|
|
+ String valueSql="update ec_e_exam_prop set value = '"+value+"'where exam_id ="+examId+" AND key_id="+keyId;
|
|
|
+ jdbcTemplate.update(valueSql);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "下载ip限制导入模板", notes = "下载导入模板")
|
|
@@ -1501,8 +1507,8 @@ public class ExamController extends ControllerSupport {
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "导入考试ip限制", notes = "导入")
|
|
|
- @PostMapping("ipLimited/import")
|
|
|
- public Map<String, Object> importExamIpLimit(@RequestParam Long examId,
|
|
|
+ @PostMapping("ipLimited/import/{examId}")
|
|
|
+ public Map<String, Object> importExamIpLimit(@PathVariable Long examId,
|
|
|
@RequestParam CommonsMultipartFile file) {
|
|
|
DiskFileItem item = (DiskFileItem) file.getFileItem();
|
|
|
File storeLocation = item.getStoreLocation();
|
|
@@ -1659,14 +1665,14 @@ public class ExamController extends ControllerSupport {
|
|
|
}
|
|
|
realIp = realIp.trim();
|
|
|
//整体控制
|
|
|
- boolean totalLimit = getExamBooleanProperty(examId,49);
|
|
|
- if (totalLimit) {
|
|
|
+ Integer totalLimit = getExamBooleanProperty(examId,49);
|
|
|
+ if (totalLimit == 1) {
|
|
|
//在白名单中
|
|
|
int count = examIpLimitRepo.countByExamIdAndLimitTypeAndIp(examId,"0",realIp);
|
|
|
if (count>0) {
|
|
|
//学习中心访问控制
|
|
|
- boolean centerLimit = getExamBooleanProperty(examId,50);
|
|
|
- if (centerLimit) {
|
|
|
+ Integer centerLimit = getExamBooleanProperty(examId,50);
|
|
|
+ if (centerLimit == 1) {
|
|
|
User accessUser = getAccessUser();
|
|
|
StudentCacheBean studentCache = CacheHelper.getStudent(accessUser.getUserId());
|
|
|
Long orgId = studentCache.getOrgId();
|
|
@@ -1704,11 +1710,10 @@ public class ExamController extends ControllerSupport {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- private boolean getExamBooleanProperty(Long examId,Integer keyId) {
|
|
|
- //虚拟摄像头进入待审核,且有虚拟摄像头的
|
|
|
+ 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<Boolean> list = jdbcTemplate.query(valueSql, (rs, rowNum) -> rs.getBoolean("value"));
|
|
|
- return !CollectionUtils.isEmpty(list) && list.get(0);
|
|
|
+ List<Integer> list = jdbcTemplate.query(valueSql, (rs, rowNum) -> rs.getInt("value"));
|
|
|
+ return !CollectionUtils.isEmpty(list) ? list.get(0) : 0;
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "是否可以微信作答", notes = "")
|