|
@@ -60,13 +60,10 @@ import cn.com.qmth.examcloud.commons.util.RegExpUtil;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.OrgCloudService;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.StudentCloudService;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.bean.OrgBean;
|
|
|
-import cn.com.qmth.examcloud.core.basic.api.bean.StudentBean;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.request.GetOrgReq;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.request.GetOrgsReq;
|
|
|
-import cn.com.qmth.examcloud.core.basic.api.request.GetStudentReq;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.response.GetOrgResp;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.response.GetOrgsResp;
|
|
|
-import cn.com.qmth.examcloud.core.basic.api.response.GetStudentResp;
|
|
|
import cn.com.qmth.examcloud.core.examwork.api.controller.bean.CopyExamDomain;
|
|
|
import cn.com.qmth.examcloud.core.examwork.api.controller.bean.ExamDomain;
|
|
|
import cn.com.qmth.examcloud.core.examwork.api.controller.bean.ExamOrgSettingsDomain;
|
|
@@ -1232,17 +1229,14 @@ public class ExamController extends ControllerSupport {
|
|
|
@ApiOperation(value = "考试IP限制", notes = "")
|
|
|
@GetMapping("ipLimit/{examId}")
|
|
|
public Map<String, Object> ipLimit(HttpServletRequest request, @PathVariable Long examId) {
|
|
|
- ExamEntity exam = GlobalHelper.getEntity(examRepo, examId, ExamEntity.class);
|
|
|
- if (null == exam) {
|
|
|
- throw new StatusException("001010", "考试不存在");
|
|
|
- }
|
|
|
+ User accessUser = getAccessUser();
|
|
|
+ StudentCacheBean studentCache = CacheHelper.getStudent(accessUser.getUserId());
|
|
|
+ Long orgId = studentCache.getOrgId();
|
|
|
+ ExamOrgPropertyCacheBean ipLimitProperty = CacheHelper.getExamOrgProperty(examId, orgId,
|
|
|
+ "IP_LIMIT");
|
|
|
|
|
|
Map<String, Object> map = Maps.newHashMap();
|
|
|
|
|
|
- DynamicEnumManager manager = ExamProperty.getDynamicEnumManager();
|
|
|
- ExamPropertyEntity ipLimitProperty = examPropertyRepo.findByExamIdAndKeyId(exam.getId(),
|
|
|
- manager.getByName("IP_LIMIT").getId());
|
|
|
-
|
|
|
Boolean ipLimit = null;
|
|
|
if (null != ipLimitProperty) {
|
|
|
ipLimit = "true".equalsIgnoreCase(ipLimitProperty.getValue());
|
|
@@ -1265,8 +1259,8 @@ public class ExamController extends ControllerSupport {
|
|
|
}
|
|
|
realIp = realIp.trim();
|
|
|
|
|
|
- ExamPropertyEntity ipAddressesProperty = examPropertyRepo.findByExamIdAndKeyId(exam.getId(),
|
|
|
- manager.getByName("IP_ADDRESSES").getId());
|
|
|
+ ExamOrgPropertyCacheBean ipAddressesProperty = CacheHelper.getExamOrgProperty(examId, orgId,
|
|
|
+ "IP_ADDRESSES");
|
|
|
|
|
|
String ipAddresses = null;
|
|
|
if (null != ipAddressesProperty) {
|
|
@@ -1288,10 +1282,6 @@ public class ExamController extends ControllerSupport {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- User accessUser = getAccessUser();
|
|
|
- StudentBean student = getStudent(accessUser.getUserId());
|
|
|
- Long orgId = student.getOrgId();
|
|
|
-
|
|
|
if (limited) {
|
|
|
String key = "IP_" + orgId;
|
|
|
String value = redisClient.get(key, String.class);
|
|
@@ -1325,19 +1315,4 @@ public class ExamController extends ControllerSupport {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 方法注释
|
|
|
- *
|
|
|
- * @author WANGWEI
|
|
|
- * @param studentId
|
|
|
- * @return
|
|
|
- */
|
|
|
- private StudentBean getStudent(Long studentId) {
|
|
|
- GetStudentReq req = new GetStudentReq();
|
|
|
- req.setStudentId(studentId);
|
|
|
- GetStudentResp resp = studentCloudService.getStudent(req);
|
|
|
- StudentBean studentInfo = resp.getStudentInfo();
|
|
|
- return studentInfo;
|
|
|
- }
|
|
|
-
|
|
|
}
|