package com.lesingle.creation.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lesingle.creation.entity.Grade;
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 GradeMapper extends BaseMapper<Grade> {

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

    /**
     * 根据租户 ID 查询年级列表
     *
     * @param tenantId 租户 ID
     * @return 年级列表
     */
    @Select("SELECT * FROM t_biz_grade WHERE tenant_id = #{tenantId} AND deleted = 0 ORDER BY level ASC")
    List<Grade> selectByTenantId(@Param("tenantId") Long tenantId);
}
