package com.yaoai.domain.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yaoai.domain.entity.BillingRecord;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BillingRecordMapper extends BaseMapper<BillingRecord> {

    @Select("SELECT * FROM billing_records WHERE tenant_id = #{tenantId} ORDER BY created_at DESC LIMIT #{limit} OFFSET #{offset}")
    List<BillingRecord> findByTenant(@Param("tenantId") Long tenantId,
                                     @Param("limit") int limit,
                                     @Param("offset") long offset);

    @Select("SELECT COUNT(*) FROM billing_records WHERE tenant_id = #{tenantId}")
    long countByTenant(Long tenantId);
}
