|
@@ -881,22 +881,22 @@ public class ExamServiceImpl implements ExamService {
|
|
|
|
|
|
@Override
|
|
|
public boolean getIpLimited(String realIp, Long examId, User accessUser) {
|
|
|
+ DynamicEnumManager manager = ExamProperty.getDynamicEnumManager();
|
|
|
+ DynamicEnum ipLimit = manager.getByName("IP_LIMIT");
|
|
|
//是否开启Ip限制
|
|
|
- ExamPropertyCacheBean ipLimitProperty = CacheHelper.getExamProperty(examId, "IP_LIMIT");
|
|
|
- boolean ipLimited = ipLimitProperty!=null && StringUtil.isTrue(ipLimitProperty.getValue());
|
|
|
+ Boolean ipLimited = getExamLimitProperty(examId, ipLimit.getId(), false);
|
|
|
|
|
|
- DynamicEnumManager manager = ExamProperty.getDynamicEnumManager();
|
|
|
- DynamicEnum ipTotalLimit = manager.getByName("IP_TOTAL_LIMIT");
|
|
|
- DynamicEnum ipCenterLimit = manager.getByName("IP_CENTER_LIMIT");
|
|
|
|
|
|
if (ipLimited) {
|
|
|
//整体控制
|
|
|
+ DynamicEnum ipTotalLimit = manager.getByName("IP_TOTAL_LIMIT");
|
|
|
Boolean totalLimit = getExamLimitProperty(examId, ipTotalLimit.getId(), false);
|
|
|
if (totalLimit) {
|
|
|
//在白名单中
|
|
|
int count = examIpLimitRepo.countByExamIdAndLimitTypeAndIp(examId, IpLimitType.HAS_ACCESS,realIp);
|
|
|
if (count>0) {
|
|
|
//学习中心访问控制
|
|
|
+ DynamicEnum ipCenterLimit = manager.getByName("IP_CENTER_LIMIT");
|
|
|
Boolean centerLimit = getExamLimitProperty(examId,ipCenterLimit.getId(), false);
|
|
|
if (centerLimit) {
|
|
|
StudentCacheBean studentCache = CacheHelper.getStudent(accessUser.getUserId());
|
|
@@ -915,8 +915,8 @@ public class ExamServiceImpl implements ExamService {
|
|
|
if (null != clientIp) {
|
|
|
// IP取前三段
|
|
|
clientIp = clientIp.substring(0, clientIp.lastIndexOf(".") + 1);
|
|
|
- if (realIp.startsWith(clientIp)) {
|
|
|
- return false;
|
|
|
+ if (!realIp.startsWith(clientIp)) {
|
|
|
+ return true;
|
|
|
}
|
|
|
}
|
|
|
}
|