Selaa lähdekoodia

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java
zouxuan 4 vuotta sitten
vanhempi
commit
6698535015

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/StudentRegistrationService.java

@@ -328,4 +328,12 @@ public interface StudentRegistrationService extends BaseService<Long, StudentReg
      */
     List<StudentMusicGroupDto> queryStudentMusicGroupInfo(Integer userId);
 
+
+    /**
+     * 删除学生报名
+     * @param id
+     * @return
+     */
+    Boolean delReg(Long id);
+
 }

+ 15 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -2573,6 +2573,20 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             throw new BizException("获取用户信息失败");
         }
         List<StudentRegistration> studentRegistrations = studentRegistrationDao.findStudentListByIdList(registerIds);
+        List<StudentRegistration> oldRegs = studentRegistrationDao.getMusicGroupStu(musicGroupId);
+        Map<Integer, List<StudentRegistration>> oldRegMap = oldRegs.stream().collect(Collectors.groupingBy(StudentRegistration::getUserId));
+        //去掉相同的人
+        List<StudentRegistration> newRegs = new ArrayList<>();
+        Set<Integer> hasUsers = new HashSet<>();
+        for (StudentRegistration studentRegistration : studentRegistrations) {
+            if (oldRegMap.containsKey(studentRegistration.getUserId()) || hasUsers.contains(studentRegistration.getUserId())) {
+                continue;
+            }
+            hasUsers.add(studentRegistration.getUserId());
+            newRegs.add(studentRegistration);
+        }
+        studentRegistrations = newRegs;
+
         List<Integer> subjectIds = studentRegistrations.stream().map(StudentRegistration::getActualSubjectId).collect(Collectors.toList());
         List<Subject> subjects = subjectDao.findBySubjectIds(subjectIds);
         Map<Integer, List<Subject>> subjectMap = subjects.stream().collect(Collectors.groupingBy(Subject::getId));
@@ -2586,7 +2600,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             for (MusicGroupSubjectPlan musicGroupSubjectPlan : musicSubjectClassPlans) {
                 if (!subjectId.equals(musicGroupSubjectPlan.getSubjectId())) continue;
                 hasSubject = true;
-                musicGroupSubjectPlan.setApplyStudentNum(regs.size());
+                musicGroupSubjectPlan.setApplyStudentNum(musicGroupSubjectPlan.getApplyStudentNum() + regs.size());
                 subjectPlan = musicGroupSubjectPlan;
             }
             if (!hasSubject) {

+ 12 - 0
mec-web/src/main/java/com/ym/mec/web/controller/StudentRegistrationController.java

@@ -11,6 +11,7 @@ import com.ym.mec.biz.service.MusicGroupSubjectPlanService;
 import com.ym.mec.biz.service.StudentRegistrationService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.exception.BizException;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -179,4 +180,15 @@ public class StudentRegistrationController extends BaseController {
         return succeed(studentRegistrationService.getClassGroupCourseExpectPrice(classGroupIds));
     }
 
+    @ApiOperation(value = "删除报名的学生")
+    @PostMapping("/del")
+    @PreAuthorize("@pcs.hasPermissions('studentRegistration/del')")
+    public HttpResponseResult<Boolean> del(Long id) {
+        StudentRegistration studentRegistration = studentRegistrationService.get(id);
+        if(studentRegistration == null){
+            return failed("删除的报名信息不存在");
+        }
+        return succeed(studentRegistrationService.delReg(id));
+    }
+
 }