package com.cxy.classroll.student.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cxy.classroll.model.entity.Lesson;
import com.cxy.classroll.model.entity.Stu_lesson;
import com.cxy.classroll.student.mapper.LessonInfoMapper;
import com.cxy.classroll.student.mapper.StuLessonMapper;
import com.cxy.classroll.student.service.LessonInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class LessonInfoServiceImpl extends ServiceImpl<LessonInfoMapper, Lesson> implements LessonInfoService {
    @Autowired
    LessonInfoMapper lessonInfoMapper;

    @Override
    public Lesson getLessonInfoByLessonName(String lesson_name) {
        LambdaQueryWrapper<Lesson> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Lesson::getLesson_name, lesson_name);
        Lesson lesson = lessonInfoMapper.selectOne(wrapper);
        return lesson;
    }

    @Override
    public Lesson getLessonInfoById(Long lesson_id) {
        return lessonInfoMapper.selectById(lesson_id);
    }

    @Override
    public Integer listenLessonStatus(Long lesson_id) {
        Lesson lesson = lessonInfoMapper.selectById(lesson_id);
        return lesson.getStatus();
    }

    @Override
    public Integer listenLessonRoll(Long lesson_id) {
        Lesson lesson = lessonInfoMapper.selectById(lesson_id);
        return lesson.getRoll();
    }
}
