package com.erp.skumatch.repository;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.erp.skumatch.entity.SkuMatchRule;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SkuMatchRuleRepository extends BaseMapper<SkuMatchRule> {
    
    @Select("<script>" +
            "SELECT * FROM sku_match_rule WHERE 1=1 " +
            "<if test='platform != null and platform != \"\"'> AND platform = #{platform} </if>" +
            "ORDER BY priority DESC, id ASC" +
            "</script>")
    List<SkuMatchRule> selectEnabledRules(@Param("platform") String platform);
    
    @Select("SELECT * FROM sku_match_rule WHERE enabled = 1 ORDER BY priority DESC, id ASC")
    List<SkuMatchRule> selectAllEnabled();
}
