baizonghao
2023-06-19 996dd70c3617d3dac5fe8b6d44d5cb70a26069a4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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<Integer> 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<VideoStudent> all = videoMapper.getAll();
        List<Integer> collect = all.stream().map(new Function<VideoStudent, Integer>() {
            @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<VideoStudentListVO> getStudentVideoList() {
        List<String> studentList = videoMapper.getStudentList();
        ArrayList<VideoStudentListVO> 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;
    }
}