package com.ruoyi.course.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.course.domain.Teacher;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * <p>
 * 教师信息表 Mapper 接口
 * </p>
 *
 * @author xu
 * @since 2025-12-14
 */
@Mapper
public interface TeacherMapper extends BaseMapper<Teacher> {

    default List<Teacher> findBySubject(String subject) {
        LambdaQueryWrapper<Teacher> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Teacher::getSubject, subject)
                .eq(Teacher::getStatus, 1)
                .orderByAsc(Teacher::getTeacherNo);
        return selectList(wrapper);
    }

    default List<Teacher> findByGradeLevel(String gradeLevel) {
        LambdaQueryWrapper<Teacher> wrapper = new LambdaQueryWrapper<>();
        wrapper
                .eq(Teacher::getStatus, 1)
                .orderByAsc(Teacher::getTeacherName);
        return selectList(wrapper);
    }

    default Teacher findByTeacherNo(String teacherNo) {
        LambdaQueryWrapper<Teacher> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Teacher::getTeacherNo, teacherNo)
                .eq(Teacher::getStatus, 1);
        return selectOne(wrapper);
    }

    default List<Teacher> findAll() {
        LambdaQueryWrapper<Teacher> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Teacher::getStatus, 1)
                .orderByAsc(Teacher::getId);
        return selectList(wrapper);
    }

}
