Pārlūkot izejas kodu

Merge branch 'course_adjust'

Joburgess 4 gadi atpakaļ
vecāks
revīzija
c4c9c9fa87

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ClassGroupStudentMapperDao.java

@@ -45,7 +45,7 @@ public interface ClassGroupStudentMapperDao extends BaseDAO<Long, ClassGroupStud
      * @author Joburgess
      * @date 2019/12/18
      */
-    ClassGroupStudentMapper findClassGroupStudent(@Param("classGroupId") int classGroupId, @Param("userId") Integer userId);
+    ClassGroupStudentMapper findClassGroupStudent(@Param("classGroupId") Integer classGroupId, @Param("userId") Integer userId);
 
     /**
      * 根据乐团编号删除指定学生

+ 16 - 8
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

@@ -1071,14 +1071,22 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
             throw new BizException("报名失败,请重试");
         }
         //2、插入关联关系
-        ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
-        classGroupStudentMapper.setMusicGroupId(classGroup.getMusicGroupId());
-        classGroupStudentMapper.setClassGroupId(classGroup.getId());
-        classGroupStudentMapper.setUserId(userId);
-        classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
-        classGroupStudentMapper.setGroupType(groupType);
-        classGroupStudentMapper.setCreateTime(date);
-        classGroupStudentMapperDao.insert(classGroupStudentMapper);
+        ClassGroupStudentMapper classGroupStudent = classGroupStudentMapperDao.findClassGroupStudent(classGroup.getId(), userId);
+        if(Objects.nonNull(classGroupStudent)){
+            classGroupStudent.setStatus(ClassGroupStudentStatusEnum.NORMAL);
+            classGroupStudent.setUpdateTime(date);
+            classGroupStudentMapperDao.update(classGroupStudent);
+        }else{
+            classGroupStudent = new ClassGroupStudentMapper();
+            classGroupStudent.setMusicGroupId(classGroup.getMusicGroupId());
+            classGroupStudent.setClassGroupId(classGroup.getId());
+            classGroupStudent.setUserId(userId);
+            classGroupStudent.setStatus(ClassGroupStudentStatusEnum.NORMAL);
+            classGroupStudent.setGroupType(groupType);
+            classGroupStudent.setCreateTime(date);
+            classGroupStudentMapperDao.insert(classGroupStudent);
+        }
+
 
         //3、学生加入级未开始课程
         List<CourseSchedule> courseScheduleList = courseScheduleService.findNoStartCoursesByClassGroupId(classGroup.getId());

+ 1 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -3010,6 +3010,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 		try {
 			checkNewCourseSchedules(oldCourses, false, false);
 		} catch (Exception e) {
+			TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
 			String errMessage = e.getMessage();
 			if (errMessage.equals("您设置的循环周期存在时间冲突")) {
 				errMessage = "日期相同课程不可批量调整上课时间";