package com.lesingle.creation.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lesingle.creation.entity.SchoolClass;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 班级 Mapper 接口
 */
@Mapper
public interface SchoolClassMapper extends BaseMapper<SchoolClass> {

    /**
     * 根据租户 ID 和班级编码查询班级
     *
     * @param tenantId 租户 ID
     * @param code 班级编码
     * @return 班级实体
     */
    @Select("SELECT * FROM t_biz_class WHERE tenant_id = #{tenantId} AND code = #{code} AND deleted = 0")
    SchoolClass selectByCode(@Param("tenantId") Long tenantId, @Param("code") String code);

    /**
     * 根据年级 ID 查询班级列表
     *
     * @param gradeId 年级 ID
     * @return 班级列表
     */
    @Select("SELECT * FROM t_biz_class WHERE grade_id = #{gradeId} AND deleted = 0 ORDER BY name ASC")
    List<SchoolClass> selectByGradeId(@Param("gradeId") Long gradeId);
}
