|
@@ -4,21 +4,23 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.ym.mec.education.base.BaseResponse;
|
|
|
import com.ym.mec.education.base.PageResponse;
|
|
|
import com.ym.mec.education.entity.*;
|
|
|
+import com.ym.mec.education.enums.ClassGroupTypeEnum;
|
|
|
import com.ym.mec.education.enums.ReturnCodeEnum;
|
|
|
import com.ym.mec.education.mapper.TeacherMapper;
|
|
|
import com.ym.mec.education.req.TeacherReq;
|
|
|
+import com.ym.mec.education.resp.TeacherDetailResp;
|
|
|
import com.ym.mec.education.resp.TeacherResp;
|
|
|
import com.ym.mec.education.service.*;
|
|
|
+import com.ym.mec.education.utils.DateUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -40,9 +42,15 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherMapper, Teacher> impl
|
|
|
|
|
|
@Autowired
|
|
|
private IClassGroupService classGroupService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IDemoGroupService demoGroupService;
|
|
|
@Autowired
|
|
|
private IClassGroupTeacherMapperService classGroupTeacherMapperService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IDemoGroupCoursesPlanService demoGroupCoursesPlanService;
|
|
|
+
|
|
|
@Override
|
|
|
public PageResponse teacherList(TeacherReq req) {
|
|
|
PageResponse response = new PageResponse();
|
|
@@ -105,6 +113,83 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherMapper, Teacher> impl
|
|
|
response.setMessage(ReturnCodeEnum.CODE_200.getValue());
|
|
|
response.setRecords(teacherRespList);
|
|
|
response.setTotal(Math.toIntExact(teacherIPage.getTotal()));
|
|
|
- return null;
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public BaseResponse teacherDetail(TeacherReq req) {
|
|
|
+
|
|
|
+ TeacherDetailResp teacherDetailResp = new TeacherDetailResp();
|
|
|
+ if(req == null || req.getUserId() == null){
|
|
|
+ return BaseResponse.errorParam();
|
|
|
+ }
|
|
|
+ QueryWrapper<ClassGroupTeacherMapper> mapperQueryWrapper = new QueryWrapper<>();
|
|
|
+ mapperQueryWrapper.eq("user_id_",req.getUserId());
|
|
|
+ List<ClassGroupTeacherMapper> groupTeacherMapperList = classGroupTeacherMapperService.list(mapperQueryWrapper);
|
|
|
+
|
|
|
+ if(!CollectionUtils.isEmpty(groupTeacherMapperList)){
|
|
|
+ List<Integer> classIds = groupTeacherMapperList.stream().map(ClassGroupTeacherMapper :: getClassGroupId).collect(Collectors.toList());
|
|
|
+ QueryWrapper<ClassGroup> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.in("id_",classIds);
|
|
|
+ List<ClassGroup> classGroups = classGroupService.list(queryWrapper);
|
|
|
+ if(!CollectionUtils.isEmpty(classGroups)){
|
|
|
+ List<ClassGroup> norClass = classGroups.stream().filter(e -> ClassGroupTypeEnum.NORMAL.getCode().equalsIgnoreCase(e.getType()) ||
|
|
|
+ ClassGroupTypeEnum.MIX.getCode().equalsIgnoreCase(e.getType()) || ClassGroupTypeEnum.HIGH.getCode().equalsIgnoreCase(e.getType())).collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<ClassGroup> vipClass = classGroups.stream().filter(e -> ClassGroupTypeEnum.VIP.getCode().equalsIgnoreCase(e.getType())).collect(Collectors.toList());
|
|
|
+ if(!CollectionUtils.isEmpty(norClass)){
|
|
|
+ Integer norCount = norClass.stream().mapToInt(ClassGroup::getTotalClassTimes).sum();
|
|
|
+ teacherDetailResp.setGroupClassNum(norCount * norClass.size());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!CollectionUtils.isEmpty(vipClass)){
|
|
|
+ Integer vipCount = vipClass.stream().mapToInt(ClassGroup::getTotalClassTimes).sum();
|
|
|
+ teacherDetailResp.setVipClassNum(vipCount * vipClass.size());
|
|
|
+ }
|
|
|
+ QueryWrapper<DemoGroup> demoGroupQueryWrapper = new QueryWrapper<>();
|
|
|
+ demoGroupQueryWrapper.eq("user_id_",req.getUserId());
|
|
|
+ List<DemoGroup> demoGroupList = demoGroupService.list(demoGroupQueryWrapper);
|
|
|
+ if(!CollectionUtils.isEmpty(demoGroupList)){
|
|
|
+ List<Long> demoId = demoGroupList.stream().map(e ->e.getId()).collect(Collectors.toList());
|
|
|
+ QueryWrapper<DemoGroupCoursesPlan> planQueryWrapper = new QueryWrapper<>();
|
|
|
+ planQueryWrapper.in("demo_group_id_",demoId);
|
|
|
+ List<DemoGroupCoursesPlan> demoGroupCoursesPlans = demoGroupCoursesPlanService.list(planQueryWrapper);
|
|
|
+ if(!CollectionUtils.isEmpty(demoGroupCoursesPlans)){
|
|
|
+ Map<Date, List<DemoGroupCoursesPlan>> collect = demoGroupCoursesPlans.stream()
|
|
|
+ .collect(
|
|
|
+ Collectors.groupingBy(DemoGroupCoursesPlan::getCourseDate));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if(!CollectionUtils.isEmpty(collect)) {
|
|
|
+ List<TeacherDetailResp.InnerDemoGroup> innerDemoGroups = new ArrayList<>();
|
|
|
+ for (Date key : collect.keySet()) {
|
|
|
+ TeacherDetailResp.InnerDemoGroup demoGroup = new TeacherDetailResp.InnerDemoGroup();
|
|
|
+ demoGroup.setDateStr(DateUtil.date2String(key,DateUtil.DATE_FORMAT));
|
|
|
+ demoGroup.setWeek(DateUtil.date2Week(key));
|
|
|
+
|
|
|
+ List<DemoGroupCoursesPlan> demoGroupCoursesPlans1 = collect.get(key);
|
|
|
+ if(!CollectionUtils.isEmpty(demoGroupCoursesPlans1)){
|
|
|
+ List<TeacherDetailResp.DemoGroupPlan> planList = new ArrayList<>();
|
|
|
+ demoGroupCoursesPlans1.forEach(e ->{
|
|
|
+ TeacherDetailResp.DemoGroupPlan demoGroupPlan = new TeacherDetailResp.DemoGroupPlan();
|
|
|
+ demoGroupPlan.setStartTime(DateUtil.date2String(e.getStartTime(),DateUtil.TIME_FORMAT));
|
|
|
+ demoGroupPlan.setEndTime(DateUtil.date2String(e.getEndTime(),DateUtil.TIME_FORMAT));
|
|
|
+ planList.add(demoGroupPlan);
|
|
|
+ });
|
|
|
+ demoGroup.setDemoGroupPlans(planList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ teacherDetailResp.setDemoGroups(innerDemoGroups);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return BaseResponse.success(teacherDetailResp);
|
|
|
}
|
|
|
}
|