|
@@ -118,20 +118,23 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public ClassGroup addClassGroup(ClassGroup classGroup) throws Exception {
|
|
public ClassGroup addClassGroup(ClassGroup classGroup) throws Exception {
|
|
|
|
+ String userIds = classGroup.getUserIds();
|
|
|
|
+ if(userIds == null || userIds.isEmpty()) throw new Exception("班级学生不能为空");
|
|
|
|
+
|
|
|
|
+ HashSet<String> userIdStrSet = new HashSet<>(Arrays.asList(userIds.split(",")));
|
|
|
|
+
|
|
Date date = new Date();
|
|
Date date = new Date();
|
|
classGroup.setCreateTime(date);
|
|
classGroup.setCreateTime(date);
|
|
classGroup.setUpdateTime(date);
|
|
classGroup.setUpdateTime(date);
|
|
classGroup.setType(ClassGroupTypeEnum.NORMAL);
|
|
classGroup.setType(ClassGroupTypeEnum.NORMAL);
|
|
- String userIds = classGroup.getUserIds();
|
|
|
|
- String[] userIdArr = userIds.split(",");
|
|
|
|
|
|
|
|
- classGroup.setExpectStudentNum(userIdArr.length);
|
|
|
|
- classGroup.setStudentNum(userIdArr.length);
|
|
|
|
|
|
+ classGroup.setExpectStudentNum(userIdStrSet.size());
|
|
|
|
+ classGroup.setStudentNum(userIdStrSet.size());
|
|
insert(classGroup);
|
|
insert(classGroup);
|
|
|
|
|
|
//2、插入班级学生关联关系
|
|
//2、插入班级学生关联关系
|
|
List<ClassGroupStudentMapper> classGroupStudentList = new ArrayList<>();
|
|
List<ClassGroupStudentMapper> classGroupStudentList = new ArrayList<>();
|
|
- for (String userId : userIdArr) {
|
|
|
|
|
|
+ for (String userId : userIdStrSet) {
|
|
ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
|
|
ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
|
|
classGroupStudentMapper.setMusicGroupId(classGroup.getMusicGroupId());
|
|
classGroupStudentMapper.setMusicGroupId(classGroup.getMusicGroupId());
|
|
classGroupStudentMapper.setClassGroupId(classGroup.getId());
|
|
classGroupStudentMapper.setClassGroupId(classGroup.getId());
|
|
@@ -139,9 +142,10 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
classGroupStudentMapper.setCreateTime(date);
|
|
classGroupStudentMapper.setCreateTime(date);
|
|
classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
|
|
classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
|
|
classGroupStudentList.add(classGroupStudentMapper);
|
|
classGroupStudentList.add(classGroupStudentMapper);
|
|
|
|
+
|
|
StudentRegistration studentRegistration = new StudentRegistration();
|
|
StudentRegistration studentRegistration = new StudentRegistration();
|
|
studentRegistration.setClassGroupId(classGroup.getId());
|
|
studentRegistration.setClassGroupId(classGroup.getId());
|
|
- studentRegistration.setUserId(Integer.getInteger(userId));
|
|
|
|
|
|
+ studentRegistration.setUserId(Integer.parseInt(userId));
|
|
studentRegistration.setMusicGroupId(classGroup.getMusicGroupId());
|
|
studentRegistration.setMusicGroupId(classGroup.getMusicGroupId());
|
|
studentRegistrationDao.updateByUserIdAndMusicGroupId(studentRegistration);
|
|
studentRegistrationDao.updateByUserIdAndMusicGroupId(studentRegistration);
|
|
}
|
|
}
|