package com.fs.store.mapper;

import com.fs.store.domain.FsCouponScheduleLog;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 优惠券发放计划日志表Mapper接口
 *
 * @author example
 */
@Mapper
public interface FsCouponScheduleLogMapper {

    /**
     * 根据日志ID查询日志信息
     *
     * @param logId 日志ID
     * @return 日志信息
     */
    @Select("SELECT * FROM fs_coupon_schedule_log WHERE log_id = #{logId}")
    FsCouponScheduleLog selectByLogId(@Param("logId") Integer logId);

    /**
     * 插入一条日志记录
     *
     * @param log 日志信息
     * @return 插入的行数
     */
    @Insert("INSERT INTO fs_coupon_schedule_log (schedule_id, user_id, order_id, status_before, status_after, send_time_before, send_time_after, actual_send_time, error_message, retry_count_before, retry_count_after, operation_type, operation_time, operator, remark) " +
            "VALUES (#{scheduleId}, #{userId}, #{orderId}, #{statusBefore}, #{statusAfter}, #{sendTimeBefore}, #{sendTimeAfter}, #{actualSendTime}, #{errorMessage}, #{retryCountBefore}, #{retryCountAfter}, #{operationType}, #{operationTime}, #{operator}, #{remark})")
    int insert(FsCouponScheduleLog log);

    /**
     * 更新日志信息
     *
     * @param log 日志信息
     * @return 更新的行数
     */
    @Update("UPDATE fs_coupon_schedule_log SET schedule_id = #{scheduleId}, user_id = #{userId}, order_id = #{orderId}, status_before = #{statusBefore}, status_after = #{statusAfter}, send_time_before = #{sendTimeBefore}, send_time_after = #{sendTimeAfter}, actual_send_time = #{actualSendTime}, error_message = #{errorMessage}, retry_count_before = #{retryCountBefore}, retry_count_after = #{retryCountAfter}, operation_type = #{operationType}, operation_time = #{operationTime}, operator = #{operator}, remark = #{remark} WHERE log_id = #{logId}")
    int update(FsCouponScheduleLog log);

    /**
     * 根据schedule_id查询日志列表
     *
     * @param scheduleId fs_coupon_schedule 表的主键ID
     * @return 日志列表
     */
    @Select("SELECT * FROM fs_coupon_schedule_log WHERE schedule_id = #{scheduleId}")
    List<FsCouponScheduleLog> selectByScheduleId(@Param("scheduleId") Integer scheduleId);

    /**
     * 批量插入日志记录
     *
     * @param logs 日志信息列表
     * @return 插入的行数
     */
    int batchInsert(@Param("logs") List<FsCouponScheduleLog> logs);
}
