ソースを参照

加入学生,学生在合奏班,加入合奏班

周箭河 5 年 前
コミット
492bafc001

+ 13 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupStudentMapperServiceImpl.java

@@ -144,6 +144,8 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
         List<ClassGroupStudentMapper> classGroupStudentMappers = new ArrayList<>();
         List<ImGroupMember> imGroupMemberList = new ArrayList<>();
 
+        ClassGroupRelation classGroupRelation = classGroupRelationService.findClassGroupRelation(classGroupId);
+
         for (String userIdStr : userIdStrSet) {
             ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
             classGroupStudentMapper.setMusicGroupId(classGroup.getMusicGroupId());
@@ -152,13 +154,23 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
             classGroupStudentMapper.setCreateTime(nowDate);
             classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
             classGroupStudentMapper.setGroupType(GroupType.MUSIC);
-            classGroupStudentMapper.setGroupType(groupType);
             classGroupStudentMappers.add(classGroupStudentMapper);
             if (classGroup.getType().equals(ClassGroupTypeEnum.NORMAL)) {
                 StudentRegistration studentRegistration = studentRegistrationService.queryByUserIdAndMusicGroupId(Integer.parseInt(userIdStr), classGroup.getMusicGroupId());
                 studentRegistration.setClassGroupId(classGroupId);
                 studentRegistrationService.update(studentRegistration);
             }
+            //班级在合奏班中
+            if(classGroupRelation != null){
+                classGroupStudentMapper = new ClassGroupStudentMapper();
+                classGroupStudentMapper.setMusicGroupId(classGroup.getMusicGroupId());
+                classGroupStudentMapper.setClassGroupId(classGroupRelation.getClassGroupId());
+                classGroupStudentMapper.setUserId(Integer.parseInt(userIdStr));
+                classGroupStudentMapper.setCreateTime(nowDate);
+                classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
+                classGroupStudentMapper.setGroupType(GroupType.MUSIC);
+                classGroupStudentMappers.add(classGroupStudentMapper);
+            }
             imGroupMemberList.add(new ImGroupMember(userIdStr));
         }
         classGroupStudentMapperDao.classGroupStudentsInsert(classGroupStudentMappers);
@@ -174,7 +186,6 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
         List<CourseSchedule> courseScheduleList = courseScheduleService.findNoStartCoursesByClassGroupId(classGroupId);
 
         //4、班级在合奏班、添加合奏课程
-        ClassGroupRelation classGroupRelation = classGroupRelationService.findClassGroupRelation(classGroupId);
         if (classGroupRelation != null) {
             //合奏班增加人数
             classGroupService.updateClassStudentNum(classGroupRelation.getClassGroupId().longValue(), userIdStrSet.size());