|
@@ -147,9 +147,58 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public boolean createClassGroup(ClassGroup classGroup) {
|
|
|
- return true;
|
|
|
- }
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
+ public boolean create(ClassGroup classGroup) {
|
|
|
+
|
|
|
+ if(classGroup.getType() == null){
|
|
|
+ throw new BizException("班级类型不能为空");
|
|
|
+ }
|
|
|
+ if(classGroup.getGroupType() == null){
|
|
|
+ throw new BizException("课程组类型不能为空");
|
|
|
+ }
|
|
|
+ String userIds = classGroup.getUserIds();
|
|
|
+
|
|
|
+ if(StringUtils.isBlank(userIds)){
|
|
|
+ userIds = "";
|
|
|
+ }
|
|
|
+
|
|
|
+ Set<String> userIdStrSet = new HashSet<>(Arrays.asList(userIds.split(",")));
|
|
|
+
|
|
|
+ Date date = new Date();
|
|
|
+ classGroup.setCreateTime(date);
|
|
|
+ classGroup.setUpdateTime(date);
|
|
|
+ classGroup.setType(ClassGroupTypeEnum.NORMAL);
|
|
|
+ classGroup.setExpectStudentNum(userIdStrSet.size());
|
|
|
+ classGroup.setStudentNum(userIdStrSet.size());
|
|
|
+ insert(classGroup);
|
|
|
+
|
|
|
+ //2、插入班级学生关联关系
|
|
|
+ List<Integer> userIdList = new ArrayList<>();
|
|
|
+ List<ClassGroupStudentMapper> classGroupStudentList = new ArrayList<>();
|
|
|
+ for (String userId : userIdStrSet) {
|
|
|
+ ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
|
|
|
+ classGroupStudentMapper.setMusicGroupId(classGroup.getMusicGroupId());
|
|
|
+ classGroupStudentMapper.setClassGroupId(classGroup.getId());
|
|
|
+ classGroupStudentMapper.setUserId(Integer.parseInt(userId));
|
|
|
+ classGroupStudentMapper.setCreateTime(date);
|
|
|
+ classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
|
|
|
+ classGroupStudentMapper.setGroupType(GroupType.MUSIC);
|
|
|
+ classGroupStudentList.add(classGroupStudentMapper);
|
|
|
+
|
|
|
+ StudentRegistration studentRegistration = new StudentRegistration();
|
|
|
+ studentRegistration.setClassGroupId(classGroup.getId());
|
|
|
+ studentRegistration.setUserId(Integer.parseInt(userId));
|
|
|
+ studentRegistration.setMusicGroupId(classGroup.getMusicGroupId());
|
|
|
+ studentRegistrationDao.updateByUserIdAndMusicGroupId(studentRegistration);
|
|
|
+
|
|
|
+ userIdList.add(Integer.parseInt(userId));
|
|
|
+ }
|
|
|
+ classGroupStudentMapperDao.classGroupStudentsInsert(classGroupStudentList);
|
|
|
+
|
|
|
+ //加入IM群组
|
|
|
+ addImGroup(classGroup, userIdList);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public List<ClassGroup> findClassGroup4Teacher(Integer teacherId) {
|