|
@@ -1,5 +1,11 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
+import com.ym.mec.biz.dal.entity.CourseSchedule;
|
|
|
+import com.ym.mec.biz.dal.entity.StudentRegistration;
|
|
|
+import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
|
|
|
+import com.ym.mec.biz.service.CourseScheduleService;
|
|
|
+import com.ym.mec.biz.service.CourseScheduleStudentPaymentService;
|
|
|
+import com.ym.mec.biz.service.StudentRegistrationService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -8,22 +14,50 @@ import com.ym.mec.biz.dal.entity.ClassGroupStudentMapper;
|
|
|
import com.ym.mec.biz.service.ClassGroupStudentMapperService;
|
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
@Service
|
|
|
-public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, ClassGroupStudentMapper> implements ClassGroupStudentMapperService {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ClassGroupStudentMapperDao classGroupStudentMapperDao;
|
|
|
+public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, ClassGroupStudentMapper> implements ClassGroupStudentMapperService {
|
|
|
|
|
|
- @Override
|
|
|
- public BaseDAO<Long, ClassGroupStudentMapper> getDAO() {
|
|
|
- return classGroupStudentMapperDao;
|
|
|
- }
|
|
|
+ @Autowired
|
|
|
+ private ClassGroupStudentMapperDao classGroupStudentMapperDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CourseScheduleService courseScheduleService;
|
|
|
+ @Autowired
|
|
|
+ StudentRegistrationService studentRegistrationService;
|
|
|
+ @Autowired
|
|
|
+ private CourseScheduleStudentPaymentService courseScheduleStudentPaymentService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public BaseDAO<Long, ClassGroupStudentMapper> getDAO() {
|
|
|
+ return classGroupStudentMapperDao;
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public ClassGroupStudentMapper findClassStudentMapperByUserIdAndClassGroupId(Integer userId, Integer classGroupId) {
|
|
|
- return classGroupStudentMapperDao.findClassStudentMapperByUserIdAndClassGroupId(userId,classGroupId);
|
|
|
+ return classGroupStudentMapperDao.findClassStudentMapperByUserIdAndClassGroupId(userId, classGroupId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public boolean delClassGroupStudent(Integer userId, Integer classGroupId) throws Exception {
|
|
|
+ ClassGroupStudentMapper classStudentMapper = findClassStudentMapperByUserIdAndClassGroupId(userId, classGroupId);
|
|
|
+ if (classStudentMapper == null) {
|
|
|
+ throw new Exception("班级学生不存在");
|
|
|
+ }
|
|
|
+ //1、删除班级学生对应班级关系
|
|
|
+ classStudentMapper.setStatus(ClassGroupStudentStatusEnum.QUIT);
|
|
|
+ update(classStudentMapper);
|
|
|
+ StudentRegistration student = studentRegistrationService.findStudentByClassGroupIdAndUserId(userId, classGroupId);
|
|
|
+ student.setClassGroupId(null);
|
|
|
+ studentRegistrationService.update(student);
|
|
|
+
|
|
|
+ //2、删除学生对应班级的单技课程和对应合奏课程
|
|
|
+ List<CourseSchedule> courseScheduleList = courseScheduleService.findNoStartCoursesByClassGroupId(classGroupId);
|
|
|
+ courseScheduleStudentPaymentService.deleteStudentCourseSchedule(userId, courseScheduleList);
|
|
|
+ return true;
|
|
|
}
|
|
|
}
|