package com.erp.ai.mapper;

import com.erp.ai.model.AiAgentApiKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface AiAgentApiKeyMapper {
    List<AiAgentApiKey> listAll();

    List<AiAgentApiKey> listByUser(@Param("userId") String userId);

    AiAgentApiKey getById(@Param("id") long id);

    AiAgentApiKey getByKeyHash(@Param("keyHash") String keyHash);

    int insert(AiAgentApiKey key);

    int delete(@Param("id") long id, @Param("userId") String userId);

    int updateLastUsed(@Param("id") long id);

    int addTokenUsage(@Param("id") long id, @Param("tokens") long tokens);

    int countActive();
}
