wangwei 7 years ago
parent
commit
08b569afcc

+ 9 - 7
examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/impl/CourseSpeciatlyService.java

@@ -34,8 +34,8 @@ public class CourseSpeciatlyService {
 	 */
 	public List<Course> getAllCoursesBySpeciatlyId(String speciatlyId) {
 		// 根据专业id查询 专业课程
-		List<CourseSpeciatly> list = courseSpeciatlyRepo.findBySpecialtyId(Long
-				.parseLong(speciatlyId));
+		List<CourseSpeciatly> list = courseSpeciatlyRepo
+				.findBySpecialtyId(Long.parseLong(speciatlyId));
 		List<Course> courses = new ArrayList<Course>();
 		if (list == null) {
 			return null;
@@ -74,11 +74,10 @@ public class CourseSpeciatlyService {
 		return list;
 	}
 
-	public void addCourseSpecialty(Long userId, List<String> courseIds,
-			String speciallyId) {
+	public void addCourseSpecialty(Long userId, List<String> courseIds, String speciallyId) {
 		// 首先判断该专业是否有关联的课程
-		List<CourseSpeciatly> list = courseSpeciatlyRepo.findBySpecialtyId(Long
-				.parseLong(speciallyId));
+		List<CourseSpeciatly> list = courseSpeciatlyRepo
+				.findBySpecialtyId(Long.parseLong(speciallyId));
 		if (list != null || list.size() > 0) {
 			for (CourseSpeciatly courseSpeciatly : list) {
 				courseSpeciatlyRepo.delete(courseSpeciatly);
@@ -99,7 +98,10 @@ public class CourseSpeciatlyService {
 		List<CourseSpeciatly> list = courseSpeciatlyRepo.findByCourseId(courseId);
 		List<Specialty> specialties = new ArrayList<Specialty>();
 		for (CourseSpeciatly courseSpeciatly : list) {
-			specialties.add(specialtyRepo.findOne(courseSpeciatly.getSpecialtyId()));
+			Specialty one = specialtyRepo.findOne(courseSpeciatly.getSpecialtyId());
+			if (null != one) {
+				specialties.add(one);
+			}
 		}
 		return specialties;
 	}