package com.css.simulation.resource.server.infra.db.mysql.mapper;

import api.common.pojo.param.scene.SceneEvaluationRuleParam;
import api.common.pojo.po.scene.SceneEvaluationRulePO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;


@Mapper
@Repository
public interface SceneEvaluationRuleMapper {

    void saveSceneEvaluationRule(SceneEvaluationRulePO params);

    void updateSceneEvaluationRule(SceneEvaluationRulePO params);

    List<SceneEvaluationRulePO> querySceneEvaluationRuleList(SceneEvaluationRuleParam params);

    @Select("<script>" +
            "select rule_name\n" +
            "from scene_evaluation_rule\n" +
            "where rule_name = #{ruleName}  \n" +
            "<if test='ruleId != null'>" +
            " AND rule_id != #{ruleId}" +
            "</if>" +
            "</script>")
    int querySceneEvaluationRuleOnly(@Param("ruleName") String ruleName, @Param("ruleId") String ruleId);

}
