package com.hfkj.dao;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * mapper扩展类
 */
public interface BsOilPriceQuizRewardMapperExt {

    @Select({
            "<script>" + 
            " SELECT " +
            " a.*," +
            " discount_name discountName," +
            " discount_type discountType," +
            " discount_price discountPrice," +
            " discount_condition discountCondition" +
            " FROM `bs_oil_price_quiz_reward` a" +
            " LEFT JOIN bs_discount b on b.id = a.discount_id" +
            " where <![CDATA[  a.`status` <> 0 ]]>" +
            " <if test='param.id != null'> and a.id = #{param.id} </if>" +
            " <if test='param.priceAdjustDateId != null'> and a.price_adjust_date_id = #{param.priceAdjustDateId} </if>" +
            " <if test='param.priceAdjustDate != null'> and a.price_adjust_date = #{param.priceAdjustDate} </if>" +
            " <if test='param.type != null'> and a.type = #{param.type} </if>" +
            "ORDER BY a.create_time desc" +
            "</script>"
    })
    @Results({
            @Result(column="id", property="id", jdbcType= JdbcType.BIGINT, id=true),
            @Result(column="price_adjust_date_id", property="priceAdjustDateId", jdbcType=JdbcType.BIGINT),
            @Result(column="price_adjust_date", property="priceAdjustDate", jdbcType=JdbcType.DATE),
            @Result(column="type", property="type", jdbcType=JdbcType.INTEGER),
            @Result(column="discount_id", property="discountId", jdbcType=JdbcType.BIGINT),
            @Result(column="discount_no", property="discountNo", jdbcType=JdbcType.VARCHAR),
            @Result(column="number", property="number", jdbcType=JdbcType.INTEGER),
            @Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
            @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR),
            @Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR),
            @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR)
    })
    List<HashMap<String,Object>> queryList(@Param("param") Map<String,Object> param);

}
