Ver Fonte

增加调整班级接口

周箭河 há 5 anos atrás
pai
commit
2b8084ecbc

+ 12 - 10
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupStudentMapperServiceImpl.java

@@ -1,18 +1,12 @@
 package com.ym.mec.biz.service.impl;
 
-import com.ym.mec.biz.dal.entity.CourseSchedule;
-import com.ym.mec.biz.dal.entity.CourseScheduleStudentPayment;
-import com.ym.mec.biz.dal.entity.StudentRegistration;
+import com.ym.mec.biz.dal.entity.*;
 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 com.ym.mec.biz.service.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import com.ym.mec.biz.dal.dao.ClassGroupStudentMapperDao;
-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;
@@ -34,6 +28,8 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
     StudentRegistrationService studentRegistrationService;
     @Autowired
     private CourseScheduleStudentPaymentService courseScheduleStudentPaymentService;
+    @Autowired
+    private ClassGroupService classGroupService;
 
     @Override
     public BaseDAO<Long, ClassGroupStudentMapper> getDAO() {
@@ -59,7 +55,10 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
         student.setClassGroupId(null);
         studentRegistrationService.update(student);
 
-        //2、删除学生对应班级的单技课程和对应合奏课程
+        //班级人数调整
+        classGroupService.updateClassStudentNum(classGroupId.longValue(), -1);
+
+        //3、删除学生对应班级的课程
         List<CourseSchedule> courseScheduleList = courseScheduleService.findNoStartCoursesByClassGroupId(classGroupId);
         courseScheduleStudentPaymentService.deleteStudentCourseSchedule(userId, courseScheduleList);
         return true;
@@ -67,7 +66,7 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
 
     @Override
     public List<StudentRegistration> findClassStudentList(Integer classGroupId, ClassGroupStudentStatusEnum status) {
-        return classGroupStudentMapperDao.findClassStudentList(classGroupId,status);
+        return classGroupStudentMapperDao.findClassStudentList(classGroupId, status);
     }
 
     @Override
@@ -80,6 +79,9 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
         //1、更新学生对应班级关系
         classStudentMapper.setClassGroupId(classGroupId);
         update(classStudentMapper);
+        //班级人数调整
+        classGroupService.updateClassStudentNum(oldClassGroupId.longValue(), -1);
+        classGroupService.updateClassStudentNum(classGroupId.longValue(), 1);
 
         //2、删除学生对应原班级未开始课程
         List<CourseSchedule> courseScheduleList = courseScheduleService.findNoStartCoursesByClassGroupId(oldClassGroupId);