package com.dora.mapper;

import com.dora.entity.RevenueConfig;
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 PromotionRuleMapper {

    /**
     * 获取所有推广等级规则
     * @return 推广等级规则列表
     */
    @Select("SELECT id, config_key, config_type, target_count, reward_amount, level, level_name, " +
            "min_fans, commission_rate, config_value, description, create_time, update_time " +
            "FROM revenue_config " +
            "WHERE config_type = 'promotion' AND is_deleted = 0 " +
            "ORDER BY level ASC")
    List<RevenueConfig> selectPromotionLevelRules();

    /**
     * 获取所有内容收益规则
     * @return 内容收益规则列表
     */
    @Select("SELECT id, config_key, config_type, target_count, reward_amount, level, level_name, " +
            "min_fans, commission_rate, config_value, description, create_time, update_time " +
            "FROM revenue_config " +
            "WHERE config_type IN ('video', 'workflow') AND is_deleted = 0 " +
            "ORDER BY config_type ASC, target_count ASC")
    List<RevenueConfig> selectContentRewardRules();

    /**
     * 根据配置类型获取规则
     * @param configType 配置类型
     * @return 规则列表
     */
    @Select("SELECT id, config_key, config_type, target_count, reward_amount, level, level_name, " +
            "min_fans, commission_rate, config_value, description, create_time, update_time " +
            "FROM revenue_config " +
            "WHERE config_type = #{configType} AND is_deleted = 0 " +
            "ORDER BY target_count ASC")
    List<RevenueConfig> selectByConfigType(@Param("configType") String configType);
} 