package com.ga.core.mapper.commission;

import com.ga.core.vo.commission.GradeEvalRuleResp;
import com.ga.core.vo.commission.GradeEvalRuleSearchParam;
import com.ga.core.vo.commission.GradeEvalRuleVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;

/**
 * grade_eval_rule Mapper.
 * 등급평가 룰: 점수 구간별 등급 매핑 마스터.
 */
@Mapper
public interface GradeEvalRuleMapper {

    GradeEvalRuleResp selectById(@Param("ruleId") Long ruleId);

    List<GradeEvalRuleResp> selectList(GradeEvalRuleSearchParam param);

    /**
     * 점수 이상인 최대 min_score 룰 1건 조회 — 등급 산정 Service 용도.
     * 기준일(baseDate) 기준 유효한 룰 중 score 이상이고 min_score 가 최대인 1건 반환.
     */
    GradeEvalRuleVO selectActiveRuleByScore(@Param("score") BigDecimal score,
                                            @Param("baseDate") LocalDate baseDate);

    int insert(GradeEvalRuleVO vo);

    int update(GradeEvalRuleVO vo);

    int delete(@Param("ruleId") Long ruleId);
}
