宋悦 7 年之前
父节点
当前提交
afe6decf1e

+ 12 - 1
core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/CourseService.java

@@ -61,7 +61,7 @@ public class CourseService {
             	}
                 ExcelError error = importCheck(course);
                 if (error == null) {
-                	list.add(course);
+					addCourse(list,course);
                 }
                 return error;
             }
@@ -73,6 +73,17 @@ public class CourseService {
 		return excelErrors;
 	}
 
+	private void addCourse(List<Course> courses,Course course){
+		for(Course tempCourse:courses){
+			if(tempCourse.getCode().equals(course.getCode())){
+				tempCourse.setName(course.getName());
+				tempCourse.setUpdateTime(new Date());
+				return;
+			}
+		}
+		courses.add(course);
+	}
+
 	private ExcelError importCheck(Course course) {
 		if(StringUtils.isEmpty(course.getCode())){
 			return new ExcelError("代码不能为空");

+ 16 - 5
core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/SpecialtyService.java

@@ -51,7 +51,7 @@ public class SpecialtyService {
 				specialty.setEnable(true);
 				ExcelError error = importCheck(specialty);
 				if (error == null) {
-					list.add(specialty);
+					addSpecialty(list,specialty);
 				}
 				return error;
 			}
@@ -63,14 +63,25 @@ public class SpecialtyService {
 		return excelErrors;
 	}
 
-	private ExcelError importCheck(Specialty Specialty) {
-		if(StringUtils.isEmpty(Specialty.getCode())){
+	private void addSpecialty(List<Specialty> specialties,Specialty specialty){
+		for(Specialty tempSpecialty:specialties){
+			if(tempSpecialty.getCode().equals(specialty.getCode())){
+				tempSpecialty.setName(specialty.getName());
+				tempSpecialty.setUpdateTime(new Date());
+				return;
+			}
+		}
+		specialties.add(specialty);
+	}
+
+	private ExcelError importCheck(Specialty specialty) {
+		if(StringUtils.isEmpty(specialty.getCode())){
 			return new ExcelError("代码不能为空");
 		}
-		if(StringUtils.isEmpty(Specialty.getName())){
+		if(StringUtils.isEmpty(specialty.getName())){
 			return new ExcelError("名称不能为空");
 		}
-		Specialty domain = specialtyRepo.findByOrgIdAndCode(Specialty.getOrgId(),Specialty.getCode());
+		Specialty domain = specialtyRepo.findByOrgIdAndCode(specialty.getOrgId(),specialty.getCode());
 		if(domain != null){
 			return new ExcelError("代码已存在");
 		}

+ 1 - 0
core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/UserRoleService.java

@@ -42,6 +42,7 @@ public class UserRoleService{
         List<Role> tempRoles = new ArrayList<>(RolesService.ROLE_LIST);
         tempRoles = tempRoles.stream()
                 .filter(role -> !role.getCode().equals(RoleMeta.MARKER.name()))
+                .filter(role -> !role.getCode().equals(RoleMeta.STUDENT.name()))
                 .collect(Collectors.toList());
         return tempRoles;
     }