| 
					
				 | 
			
			
				@@ -1,21 +1,42 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package com.yonge.cooleshow.biz.dal.service.impl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.baomidou.mybatisplus.core.metadata.IPage; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.baomidou.mybatisplus.core.toolkit.Wrappers; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.yonge.cooleshow.biz.dal.dao.CourseScheduleDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.yonge.cooleshow.biz.dal.dao.StudentStarDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.dto.search.StudentSearch; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.yonge.cooleshow.biz.dal.entity.Teacher; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.entity.TeacherStyleVideo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.yonge.cooleshow.biz.dal.enums.CacheNameEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.yonge.cooleshow.biz.dal.vo.StudentTotalVo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.vo.StudentVo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.yonge.cooleshow.biz.dal.vo.TeacherTotalVo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.vo.TeacherVo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.redisson.api.RedissonClient; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.entity.Student; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.dao.StudentDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.service.StudentService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.util.CollectionUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.ArrayList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.HashMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Service 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> implements StudentService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private StudentStarDao studentStarDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private CourseScheduleDao courseScheduleDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private RedissonClient redissonClient; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public StudentVo detail(Long userId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         StudentVo detail = baseMapper.detail(userId); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -26,4 +47,41 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public IPage<StudentVo> selectPage(IPage<StudentVo> page, StudentSearch studentSearch) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return page.setRecords(baseMapper.selectPage(page, studentSearch)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public List<StudentTotalVo> queryStudentHomeTotal() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<Student> students = baseMapper.selectList(Wrappers.<Student>emptyWrapper() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .select("userId")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //查询关注老师数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<StudentTotalVo> studentStarTotal = studentStarDao.queryStudentHomeTotal(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<Long, StudentTotalVo> studentStarMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!CollectionUtils.isEmpty(studentStarTotal)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            studentStarMap = studentStarTotal.stream().collect(Collectors.toMap(StudentTotalVo::getUserId, o -> o)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //查询已上未上课时数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<StudentTotalVo> studentCourseTotal = courseScheduleDao.queryStudentHomeTotal(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<Long, StudentTotalVo> studentCourseMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!CollectionUtils.isEmpty(studentCourseTotal)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            studentCourseMap = studentCourseTotal.stream().collect(Collectors.toMap(StudentTotalVo::getUserId, o -> o)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<StudentTotalVo> resultList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (Student student : students) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            StudentTotalVo totalVo = new StudentTotalVo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            totalVo.setUserId(student.getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            StudentTotalVo starTotal = studentStarMap.get(student.getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (null != starTotal) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                totalVo.setStarNum(starTotal.getStarNum()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            StudentTotalVo courseTotal = studentCourseMap.get(student.getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (null != courseTotal) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                totalVo.setExpTime(courseTotal.getExpTime()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                totalVo.setUnExpTime(courseTotal.getUnExpTime()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            resultList.add(totalVo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            redissonClient.getBucket(CacheNameEnum.STUDENT_HOME_TOTAL.getRedisKey(totalVo.getUserId())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .set(totalVo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return resultList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |