|
@@ -1,10 +1,21 @@
|
|
|
package com.ym.mec.education.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.ym.mec.education.entity.VipGroup;
|
|
|
+import com.ym.mec.biz.dal.enums.ClassGroupTypeEnum;
|
|
|
+import com.ym.mec.education.base.BaseResponse;
|
|
|
+import com.ym.mec.education.entity.*;
|
|
|
import com.ym.mec.education.mapper.VipGroupMapper;
|
|
|
-import com.ym.mec.education.service.IVipGroupService;
|
|
|
+import com.ym.mec.education.req.VipGroupReq;
|
|
|
+import com.ym.mec.education.resp.VipGroupResp;
|
|
|
+import com.ym.mec.education.service.*;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.Optional;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -17,4 +28,53 @@ import org.springframework.stereotype.Service;
|
|
|
@Service("IVipGroupService")
|
|
|
public class VipGroupServiceImpl extends ServiceImpl<VipGroupMapper, VipGroup> implements IVipGroupService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ICourseScheduleService courseScheduleService;
|
|
|
+ @Autowired
|
|
|
+ private ISysUserService userService;
|
|
|
+ @Autowired
|
|
|
+ private IClassGroupService classGroupService;
|
|
|
+ @Autowired
|
|
|
+ private IClassGroupStudentMapperService classGroupStudentMapperService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public BaseResponse getInfo(VipGroupReq vipGroupReq) {
|
|
|
+ if (Objects.isNull(vipGroupReq.getVipGroupId())) {
|
|
|
+ return BaseResponse.errorParam();
|
|
|
+ }
|
|
|
+ VipGroupResp vipGroupResp = new VipGroupResp();
|
|
|
+ QueryWrapper<CourseSchedule> courseScheduleQueryWrapper = new QueryWrapper();
|
|
|
+ courseScheduleQueryWrapper.lambda().eq(CourseSchedule::getClassGroupId, vipGroupReq.getVipGroupId())
|
|
|
+ .eq(CourseSchedule::getType, CourseSchedule.CourseScheduleType.VIP.getCode());
|
|
|
+ CourseSchedule courseSchedule = courseScheduleService.getOne(courseScheduleQueryWrapper);
|
|
|
+ if (Objects.nonNull(courseSchedule)) {
|
|
|
+ if (Objects.nonNull(courseSchedule.getTeacherId())) {
|
|
|
+ Optional.ofNullable(userService.getById(courseSchedule.getTeacherId()))
|
|
|
+ .ifPresent(user -> vipGroupResp.setTeacher(user.getRealName()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ QueryWrapper<ClassGroup> classGroupQueryWrapper = new QueryWrapper();
|
|
|
+ classGroupQueryWrapper.lambda().eq(ClassGroup::getMusicGroupId, vipGroupReq.getVipGroupId())
|
|
|
+ .eq(ClassGroup::getType, ClassGroupTypeEnum.VIP.getCode());
|
|
|
+ List<ClassGroup> classGroupList = classGroupService.list(classGroupQueryWrapper);
|
|
|
+ if (!CollectionUtils.isEmpty(classGroupList)) {
|
|
|
+ classGroupList.stream().findFirst().ifPresent(classGroup -> {
|
|
|
+ if (Objects.nonNull(classGroup.getCurrentClassTimes()) && Objects.nonNull(classGroup.getTotalClassTimes())) {
|
|
|
+ vipGroupResp.setCourseProgress(classGroup.getCurrentClassTimes() + "/" + classGroup.getTotalClassTimes());
|
|
|
+ }
|
|
|
+ QueryWrapper<ClassGroupStudentMapper> classGroupStudentMapperQueryWrapper = new QueryWrapper<>();
|
|
|
+ classGroupStudentMapperQueryWrapper.lambda().eq(ClassGroupStudentMapper::getClassGroupId, classGroup.getId());
|
|
|
+ List<ClassGroupStudentMapper> classGroupStudentMapperList = classGroupStudentMapperService.list(classGroupStudentMapperQueryWrapper);
|
|
|
+ if (!CollectionUtils.isEmpty(classGroupStudentMapperList)) {
|
|
|
+ QueryWrapper<SysUser> sysUserQueryWrapper = new QueryWrapper<>();
|
|
|
+ sysUserQueryWrapper.lambda().in(SysUser::getId, classGroupStudentMapperList.stream().map(ClassGroupStudentMapper::getUserId).collect(Collectors.toList()));
|
|
|
+ List<SysUser> studentList = userService.list(sysUserQueryWrapper);
|
|
|
+ if (!CollectionUtils.isEmpty(studentList)) {
|
|
|
+ vipGroupResp.setStudentList(studentList.stream().map(SysUser::getRealName).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return BaseResponse.success(vipGroupResp);
|
|
|
+ }
|
|
|
}
|