|
@@ -1,6 +1,9 @@
|
|
|
package com.ym.mec.web.service.impl;
|
|
|
|
|
|
+import com.ym.mec.web.dal.entity.ClassGroupStudentMapper;
|
|
|
+import com.ym.mec.web.dal.enums.ClassGroupStudentStatusEnum;
|
|
|
import com.ym.mec.web.dal.enums.ClassGroupTypeEnum;
|
|
|
+import com.ym.mec.web.service.ClassGroupStudentMapperService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -9,8 +12,10 @@ import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
import com.ym.mec.web.dal.dao.ClassGroupDao;
|
|
|
import com.ym.mec.web.dal.entity.ClassGroup;
|
|
|
import com.ym.mec.web.service.ClassGroupService;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.util.List;
|
|
|
+import java.lang.reflect.Array;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Service
|
|
|
public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup> implements ClassGroupService {
|
|
@@ -18,6 +23,9 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
@Autowired
|
|
|
private ClassGroupDao classGroupDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ClassGroupStudentMapperService classGroupStudentMapperService;
|
|
|
+
|
|
|
@Override
|
|
|
public BaseDAO<Integer, ClassGroup> getDAO() {
|
|
|
return classGroupDao;
|
|
@@ -41,4 +49,30 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
public List<ClassGroup> findAllClassGroupByMusicGroupIdAndType(int musicGroupId, ClassGroupTypeEnum type) {
|
|
|
return classGroupDao.findAllClassGroupByMusicGroupIdAndType(musicGroupId,type);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public ClassGroup addClassGroup(ClassGroup classGroup) throws Exception {
|
|
|
+ Date date;
|
|
|
+ date = new Date();
|
|
|
+ classGroup.setCreateTime(date);
|
|
|
+ classGroup.setUpdateTime(date);
|
|
|
+ String userIds = classGroup.getUserIds();
|
|
|
+ String[] userIdArr = userIds.split(",");
|
|
|
+
|
|
|
+ classGroup.setStudentNum(userIdArr.length);
|
|
|
+ long classGroupId = this.insert(classGroup);
|
|
|
+ List<ClassGroupStudentMapper> classGroupStudentList = new ArrayList<>();
|
|
|
+ for (String userId:userIdArr) {
|
|
|
+ ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
|
|
|
+ classGroupStudentMapper.setClassGroupId(classGroupId);
|
|
|
+ classGroupStudentMapper.setUserId(Integer.getInteger(userId));
|
|
|
+ classGroupStudentMapper.setCreateTime(date);
|
|
|
+ classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
|
|
|
+ classGroupStudentList.add(classGroupStudentMapper);
|
|
|
+ }
|
|
|
+ classGroupStudentMapperService.classGroupStudentsInsert(classGroupStudentList);
|
|
|
+
|
|
|
+ return classGroup;
|
|
|
+ }
|
|
|
}
|