package com.mindskip.xzs.service.impl; import com.mindskip.xzs.domain.VideoStudent; import com.mindskip.xzs.domain.vo.VideoStudentDto; import com.mindskip.xzs.domain.vo.VideoStudentListVO; import com.mindskip.xzs.domain.vo.VideoStudentVO; import com.mindskip.xzs.repository.VideoMapper; import com.mindskip.xzs.service.IVideoService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.function.Function; import java.util.stream.Collectors; @Service public class VideoServiceImpl implements IVideoService { @Autowired private VideoMapper videoMapper; @Override public void save(VideoStudentDto videoStudentVO) { List stuIds = videoStudentVO.getStuIds(); for (Integer stuId : stuIds) { VideoStudent record = new VideoStudent(); Calendar calendar = Calendar.getInstance(); Date start = calendar.getTime(); calendar.add(Calendar.MINUTE, 10); // 加上十分钟 Date end = calendar.getTime(); record.setRoomName(videoStudentVO.getRoomName()); record.setStart(start); record.setEnd(end); record.setStuId(stuId); videoMapper.insert(record); } } @Override public void clear() { videoMapper.clear(); } @Override public VideoStudentVO showButton(Integer id) { List all = videoMapper.getAll(); List collect = all.stream().map(new Function() { @Override public Integer apply(VideoStudent videoStudent) { return videoStudent.getStuId(); } }).collect(Collectors.toList()); VideoStudentVO videoStudentVO = new VideoStudentVO(); videoStudentVO.setFlag(collect.contains(id)); videoStudentVO.setRoomName(all.get(0).getRoomName()); return videoStudentVO; } @Override public List getStudentVideoList() { List studentList = videoMapper.getStudentList(); ArrayList list = new ArrayList<>(); for (String s : studentList) { VideoStudentListVO videoStudentListVO = new VideoStudentListVO(); videoStudentListVO.setCreateTime(new Date()); videoStudentListVO.setTeacherName(s); videoStudentListVO.setRoomName(s); list.add(videoStudentListVO); } return list; } }