package com.erp.example.seata.mapper;

import com.erp.example.seata.entity.TransactionLog;
import org.apache.ibatis.annotations.*;

@Mapper
public interface TransactionLogMapper {
    
    @Insert("INSERT INTO transaction_log (tx_no, order_no, customer_id, amount, type, status, create_time) " +
            "VALUES (#{txNo}, #{orderNo}, #{customerId}, #{amount}, #{type}, #{status}, #{createTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(TransactionLog log);
    
    @Select("SELECT * FROM transaction_log WHERE order_no = #{orderNo}")
    @Results({
        @Result(property = "id", column = "id"),
        @Result(property = "txNo", column = "tx_no"),
        @Result(property = "orderNo", column = "order_no"),
        @Result(property = "customerId", column = "customer_id"),
        @Result(property = "amount", column = "amount"),
        @Result(property = "type", column = "type"),
        @Result(property = "status", column = "status"),
        @Result(property = "createTime", column = "create_time"),
        @Result(property = "completeTime", column = "complete_time")
    })
    java.util.List<TransactionLog> findByOrderNo(@Param("orderNo") String orderNo);
}
