Browse Source

merge from release_v4.0.2

deason 4 năm trước cách đây
mục cha
commit
f544b2d8e2

+ 8 - 9
examcloud-task-service/src/main/java/cn/com/qmth/examcloud/task/service/job/ExamStudentImportParsingFileTask.java

@@ -2,8 +2,6 @@ package cn.com.qmth.examcloud.task.service.job;
 
 
 import cn.com.qmth.examcloud.api.commons.enums.ExamSpecialSettingsType;
 import cn.com.qmth.examcloud.api.commons.enums.ExamSpecialSettingsType;
 import cn.com.qmth.examcloud.commons.helpers.poi.ExcelReader;
 import cn.com.qmth.examcloud.commons.helpers.poi.ExcelReader;
-import cn.com.qmth.examcloud.commons.util.BooleanUtil;
-import cn.com.qmth.examcloud.commons.util.DateUtil;
 import cn.com.qmth.examcloud.commons.util.PathUtil;
 import cn.com.qmth.examcloud.commons.util.PathUtil;
 import cn.com.qmth.examcloud.examwork.api.ExamStageCloudService;
 import cn.com.qmth.examcloud.examwork.api.ExamStageCloudService;
 import cn.com.qmth.examcloud.examwork.api.bean.ExamStageBean;
 import cn.com.qmth.examcloud.examwork.api.bean.ExamStageBean;
@@ -26,7 +24,6 @@ import com.google.common.collect.Sets;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.math.NumberUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
 
 
@@ -50,8 +47,7 @@ public class ExamStudentImportParsingFileTask extends AbstractTask {
     private static final String EXAM_STUDENT_IMPORT_FILES = "exam_student_import_files";
     private static final String EXAM_STUDENT_IMPORT_FILES = "exam_student_import_files";
 
 
     private static final String[] EXCEL_HEADER = new String[]{"姓名", "学号", "身份证号", "学习中心代码",
     private static final String[] EXCEL_HEADER = new String[]{"姓名", "学号", "身份证号", "学习中心代码",
-            "学习中心名称", "课程代码", "课程名称", "试卷类型", "专业", "考点", "信息采集人", "学生电话", "年级", "试卷袋编码", "考试开始时间",
-            "考试结束时间", "场次"};
+            "学习中心名称", "课程代码", "课程名称", "试卷类型", "专业", "考点", "信息采集人", "学生电话", "年级", "试卷袋编码", "场次"};
 
 
     @Autowired
     @Autowired
     TaskTracker taskTracker;
     TaskTracker taskTracker;
@@ -174,7 +170,9 @@ public class ExamStudentImportParsingFileTask extends AbstractTask {
 
 
             es.setExt1(trimAndNullIfBlank(line[13]));
             es.setExt1(trimAndNullIfBlank(line[13]));
 
 
-            String d1 = trimAndNullIfBlank(line[14]);
+            // 从导入模板中去掉”考试开始时间“、”考试结束时间“
+
+            /*String d1 = trimAndNullIfBlank(line[14]);
             String d2 = trimAndNullIfBlank(line[15]);
             String d2 = trimAndNullIfBlank(line[15]);
 
 
             if (!new Boolean(null == d1).equals(new Boolean(null == d2))) {
             if (!new Boolean(null == d1).equals(new Boolean(null == d2))) {
@@ -213,9 +211,9 @@ public class ExamStudentImportParsingFileTask extends AbstractTask {
                 }
                 }
                 es.setSpecialBeginTime(specialBeginTime);
                 es.setSpecialBeginTime(specialBeginTime);
                 es.setSpecialEndTime(specialEndTime);
                 es.setSpecialEndTime(specialEndTime);
-            }
+            }*/
 
 
-            String strExamStageOrder = trimAndNullIfBlank(line[16]);
+            String strExamStageOrder = trimAndNullIfBlank(line[14]);
             if (StringUtils.isNotEmpty(strExamStageOrder)) {
             if (StringUtils.isNotEmpty(strExamStageOrder)) {
 
 
                 //只有开启场次特殊设置的才会使用场次字段值
                 //只有开启场次特殊设置的才会使用场次字段值
@@ -261,7 +259,7 @@ public class ExamStudentImportParsingFileTask extends AbstractTask {
             }
             }
 
 
             list.add(es);
             list.add(es);
-            
+
             String key = es.getIdentityNumber() + "____" + es.getCourseCode();
             String key = es.getIdentityNumber() + "____" + es.getCourseCode();
             if (fullSet.contains(key)) {
             if (fullSet.contains(key)) {
                 sb.append("line ").append(es.getLineNum()).append("  重复数据,执行更新").append("\n");
                 sb.append("line ").append(es.getLineNum()).append("  重复数据,执行更新").append("\n");
@@ -414,4 +412,5 @@ public class ExamStudentImportParsingFileTask extends AbstractTask {
     public TaskTracker getTaskTracker() {
     public TaskTracker getTaskTracker() {
         return taskTracker;
         return taskTracker;
     }
     }
+
 }
 }

+ 1 - 1
examcloud-task-starter/src/main/java/cn/com/qmth/examcloud/task/starter/TaskApp.java

@@ -33,7 +33,7 @@ public class TaskApp {
 	static {
 	static {
 		String runtimeLevel = System.getProperty("log.commonLevel");
 		String runtimeLevel = System.getProperty("log.commonLevel");
 		if (null == runtimeLevel) {
 		if (null == runtimeLevel) {
-			System.setProperty("log.commonLevel", "DEBUG");
+			System.setProperty("log.commonLevel", "INFO");
 		}
 		}
 		System.setProperty("hibernate.dialect.storage_engine", "innodb");
 		System.setProperty("hibernate.dialect.storage_engine", "innodb");
 	}
 	}

+ 113 - 108
examcloud-task-starter/src/main/java/cn/com/qmth/examcloud/task/starter/config/ExamCloudResourceManager.java

@@ -1,19 +1,7 @@
 package cn.com.qmth.examcloud.task.starter.config;
 package cn.com.qmth.examcloud.task.starter.config;
 
 
-import java.util.List;
-import java.util.Set;
-
-import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import com.google.common.collect.Sets;
-
-import cn.com.qmth.examcloud.api.commons.security.bean.AccessApp;
-import cn.com.qmth.examcloud.api.commons.security.bean.Role;
-import cn.com.qmth.examcloud.api.commons.security.bean.User;
-import cn.com.qmth.examcloud.api.commons.security.bean.UserType;
+import cn.com.qmth.examcloud.api.commons.enums.DataRuleType;
+import cn.com.qmth.examcloud.api.commons.security.bean.*;
 import cn.com.qmth.examcloud.api.commons.security.enums.RoleMeta;
 import cn.com.qmth.examcloud.api.commons.security.enums.RoleMeta;
 import cn.com.qmth.examcloud.commons.util.PathUtil;
 import cn.com.qmth.examcloud.commons.util.PathUtil;
 import cn.com.qmth.examcloud.commons.util.PropertiesUtil;
 import cn.com.qmth.examcloud.commons.util.PropertiesUtil;
@@ -23,6 +11,14 @@ import cn.com.qmth.examcloud.support.cache.bean.AppCacheBean;
 import cn.com.qmth.examcloud.web.redis.RedisClient;
 import cn.com.qmth.examcloud.web.redis.RedisClient;
 import cn.com.qmth.examcloud.web.security.ResourceManager;
 import cn.com.qmth.examcloud.web.security.ResourceManager;
 import cn.com.qmth.examcloud.web.support.ApiInfo;
 import cn.com.qmth.examcloud.web.support.ApiInfo;
+import com.google.common.collect.Sets;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.Set;
 
 
 /**
 /**
  * Demo资源管理器
  * Demo资源管理器
@@ -34,99 +30,108 @@ import cn.com.qmth.examcloud.web.support.ApiInfo;
 @Component
 @Component
 public class ExamCloudResourceManager implements ResourceManager {
 public class ExamCloudResourceManager implements ResourceManager {
 
 
-	@Autowired
-	RedisClient redisClient;
-
-	static {
-		PropertiesUtil.loadFromPath(PathUtil.getResoucePath("security.properties"));
-	}
-
-	@Override
-	public AccessApp getAccessApp(Long appId) {
-		AppCacheBean appCacheBean = CacheHelper.getApp(appId);
-		AccessApp app = new AccessApp();
-		app.setAppId(appCacheBean.getId());
-		app.setAppCode(appCacheBean.getCode());
-		app.setAppName(appCacheBean.getName());
-		app.setSecretKey(appCacheBean.getSecretKey());
-		app.setTimeRange(appCacheBean.getTimeRange());
-		return app;
-	}
-
-	@Override
-	public boolean isNaked(ApiInfo apiInfo, String mapping) {
-		if (null == apiInfo) {
-			return true;
-		}
-
-		if (mapping.matches(".*swagger.*")) {
-			return true;
-		}
-
-		if (null != apiInfo) {
-			if (apiInfo.isNaked()) {
-				return true;
-			}
-		}
-
-		return false;
-	}
-
-	@Override
-	public boolean hasPermission(User user, ApiInfo apiInfo, String mapping) {
-
-		// 学生鉴权
-		if (user.getUserType().equals(UserType.STUDENT)) {
-			String key = "[s]" + mapping;
-			return PropertiesUtil.getBoolean(key, false);
-		}
-
-		List<Role> roleList = user.getRoleList();
-
-		if (CollectionUtils.isEmpty(roleList)) {
-			return false;
-		}
-
-		for (Role role : roleList) {
-			if (role.getRoleCode().equals(RoleMeta.SUPER_ADMIN.name())) {
-				return true;
-			}
-		}
-
-		// 权限组集合
-		String privilegeGroups = PropertiesUtil.getString(mapping);
-		if (StringUtils.isBlank(privilegeGroups)) {
-			return true;
-		}
-
-		// 用户权限集合
-		Set<String> rolePrivilegeList = Sets.newHashSet();
-		Long rootOrgId = user.getRootOrgId();
-		for (Role role : roleList) {
-			String key = "$_P_" + rootOrgId + "_" + role.getRoleId();
-			String rolePrivileges = redisClient.get(key, String.class);
-
-			List<String> rpList = RegExpUtil.findAll(rolePrivileges, "\\w+");
-			rolePrivilegeList.addAll(rpList);
-		}
-
-		List<String> privilegeGroupList = RegExpUtil.findAll(privilegeGroups, "[^\\;]+");
-
-		for (String pg : privilegeGroupList) {
-			pg = pg.trim();
-			if (StringUtils.isBlank(pg)) {
-				continue;
-			}
-
-			List<String> pList = RegExpUtil.findAll(pg, "[^\\,]+");
-			if (rolePrivilegeList.containsAll(pList)) {
-				return true;
-			} else {
-				continue;
-			}
-		}
-
-		return false;
-	}
+    @Autowired
+    RedisClient redisClient;
+
+    // @Autowired
+    // UserDataRuleCloudService userDataRuleCloudService;
+
+    static {
+        PropertiesUtil.loadFromPath(PathUtil.getResoucePath("security.properties"));
+    }
+
+    @Override
+    public AccessApp getAccessApp(Long appId) {
+        AppCacheBean appCacheBean = CacheHelper.getApp(appId);
+        AccessApp app = new AccessApp();
+        app.setAppId(appCacheBean.getId());
+        app.setAppCode(appCacheBean.getCode());
+        app.setAppName(appCacheBean.getName());
+        app.setSecretKey(appCacheBean.getSecretKey());
+        app.setTimeRange(appCacheBean.getTimeRange());
+        return app;
+    }
+
+    @Override
+    public boolean isNaked(ApiInfo apiInfo, String mapping) {
+        if (null == apiInfo) {
+            return true;
+        }
+
+        if (mapping.matches(".*swagger.*")) {
+            return true;
+        }
+
+        if (null != apiInfo) {
+            if (apiInfo.isNaked()) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    @Override
+    public boolean hasPermission(User user, ApiInfo apiInfo, String mapping) {
+
+        // 学生鉴权
+        if (user.getUserType().equals(UserType.STUDENT)) {
+            String key = "[s]" + mapping;
+            return PropertiesUtil.getBoolean(key, false);
+        }
+
+        List<Role> roleList = user.getRoleList();
+
+        if (CollectionUtils.isEmpty(roleList)) {
+            return false;
+        }
+
+        for (Role role : roleList) {
+            if (role.getRoleCode().equals(RoleMeta.SUPER_ADMIN.name())) {
+                return true;
+            }
+        }
+
+        // 权限组集合
+        String privilegeGroups = PropertiesUtil.getString(mapping);
+        if (StringUtils.isBlank(privilegeGroups)) {
+            return true;
+        }
+
+        // 用户权限集合
+        Set<String> rolePrivilegeList = Sets.newHashSet();
+        Long rootOrgId = user.getRootOrgId();
+        for (Role role : roleList) {
+            String key = "$_P_" + rootOrgId + "_" + role.getRoleId();
+            String rolePrivileges = redisClient.get(key, String.class);
+
+            List<String> rpList = RegExpUtil.findAll(rolePrivileges, "\\w+");
+            rolePrivilegeList.addAll(rpList);
+        }
+
+        List<String> privilegeGroupList = RegExpUtil.findAll(privilegeGroups, "[^\\;]+");
+
+        for (String pg : privilegeGroupList) {
+            pg = pg.trim();
+            if (StringUtils.isBlank(pg)) {
+                continue;
+            }
+
+            List<String> pList = RegExpUtil.findAll(pg, "[^\\,]+");
+            if (rolePrivilegeList.containsAll(pList)) {
+                return true;
+            } else {
+                continue;
+            }
+        }
+
+        return false;
+    }
+
+    @Override
+    public UserDataRule loadUserDataRule(Long userId, DataRuleType dataRuleType) {
+        // ignore
+        return new UserDataRule();
+    }
 
 
 }
 }

+ 34 - 31
examcloud-task-starter/src/main/java/cn/com/qmth/examcloud/task/starter/config/ExamCloudWebMvcConfigurer.java

@@ -1,18 +1,18 @@
 package cn.com.qmth.examcloud.task.starter.config;
 package cn.com.qmth.examcloud.task.starter.config;
 
 
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.servlet.config.annotation.CorsRegistry;
-import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
-
 import cn.com.qmth.examcloud.web.interceptor.ApiStatisticInterceptor;
 import cn.com.qmth.examcloud.web.interceptor.ApiStatisticInterceptor;
 import cn.com.qmth.examcloud.web.interceptor.FirstInterceptor;
 import cn.com.qmth.examcloud.web.interceptor.FirstInterceptor;
 import cn.com.qmth.examcloud.web.interceptor.SeqlockInterceptor;
 import cn.com.qmth.examcloud.web.interceptor.SeqlockInterceptor;
 import cn.com.qmth.examcloud.web.redis.RedisClient;
 import cn.com.qmth.examcloud.web.redis.RedisClient;
+import cn.com.qmth.examcloud.web.security.DataRuleInterceptor;
 import cn.com.qmth.examcloud.web.security.RequestPermissionInterceptor;
 import cn.com.qmth.examcloud.web.security.RequestPermissionInterceptor;
 import cn.com.qmth.examcloud.web.security.ResourceManager;
 import cn.com.qmth.examcloud.web.security.ResourceManager;
 import cn.com.qmth.examcloud.web.security.RpcInterceptor;
 import cn.com.qmth.examcloud.web.security.RpcInterceptor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
 
 /**
 /**
  * WebMvcConfigurer
  * WebMvcConfigurer
@@ -23,28 +23,31 @@ import cn.com.qmth.examcloud.web.security.RpcInterceptor;
  */
  */
 @Configuration
 @Configuration
 public class ExamCloudWebMvcConfigurer implements WebMvcConfigurer {
 public class ExamCloudWebMvcConfigurer implements WebMvcConfigurer {
-	@Autowired
-	ResourceManager resourceManager;
-
-	@Autowired
-	RedisClient redisClient;
-
-	@Override
-	public void addInterceptors(InterceptorRegistry registry) {
-		registry.addInterceptor(new FirstInterceptor()).addPathPatterns("/**");
-		registry.addInterceptor(new RpcInterceptor(resourceManager)).addPathPatterns("/**");
-
-		RequestPermissionInterceptor permissionInterceptor = new RequestPermissionInterceptor(
-				resourceManager, redisClient);
-		registry.addInterceptor(permissionInterceptor).addPathPatterns("/**");
-		registry.addInterceptor(new SeqlockInterceptor(redisClient)).addPathPatterns("/**");
-		registry.addInterceptor(new ApiStatisticInterceptor()).addPathPatterns("/**");
-	}
-
-	@Override
-	public void addCorsMappings(CorsRegistry registry) {
-		registry.addMapping("/**").allowedOrigins("*").allowCredentials(false).allowedMethods("*")
-				.maxAge(3600);
-	}
-
-}
+
+    @Autowired
+    ResourceManager resourceManager;
+
+    @Autowired
+    RedisClient redisClient;
+
+    @Override
+    public void addInterceptors(InterceptorRegistry registry) {
+        registry.addInterceptor(new FirstInterceptor()).addPathPatterns("/**");
+        registry.addInterceptor(new RpcInterceptor(resourceManager)).addPathPatterns("/**");
+
+        RequestPermissionInterceptor permissionInterceptor = new RequestPermissionInterceptor(resourceManager, redisClient);
+        registry.addInterceptor(permissionInterceptor).addPathPatterns("/**");
+
+        registry.addInterceptor(new SeqlockInterceptor(redisClient)).addPathPatterns("/**");
+        registry.addInterceptor(new ApiStatisticInterceptor()).addPathPatterns("/**");
+
+        // registry.addInterceptor(new DataRuleInterceptor(resourceManager)).addPathPatterns("/api/**");
+    }
+
+    @Override
+    public void addCorsMappings(CorsRegistry registry) {
+        registry.addMapping("/**").allowedOrigins("*").allowCredentials(false).allowedMethods("*")
+                .maxAge(3600);
+    }
+
+}