package com.nursinghome.mapper;

import com.nursinghome.entity.PaymentRecord;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface PaymentRecordMapper {
    @Insert("INSERT INTO payment_record(bill_id, family_id, amount, method, paid_at) VALUES(#{billId}, #{familyId}, #{amount}, #{method}, #{paidAt})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(PaymentRecord record);

    @Select("SELECT * FROM payment_record WHERE bill_id = #{billId} ORDER BY paid_at DESC")
    List<PaymentRecord> listByBillId(Long billId);
}
