package com.gzzm.lobster.tool.mcp;

import net.cyan.thunwind.annotation.OQL;
import net.cyan.thunwind.dao.GeneralDao;

import java.util.List;

public abstract class McpCallLogDao extends GeneralDao {

    @OQL("select l from McpCallLog l where l.callId=:1")
    public abstract McpCallLog getLog(String callId) throws Exception;

    @OQL("select l from McpCallLog l where l.runId=:1 order by l.createTime desc")
    public abstract List<McpCallLog> listByRun(String runId) throws Exception;

    @OQL("select l from McpCallLog l where l.runId=:1 order by l.createTime desc limit :2,:3")
    public abstract List<McpCallLog> listByRun(String runId, int offset, int limit) throws Exception;

    @OQL("select count(l) from McpCallLog l where l.runId=:1")
    public abstract long countByRun(String runId) throws Exception;

    @OQL("select l from McpCallLog l where l.threadId=:1 order by l.createTime desc limit :2,:3")
    public abstract List<McpCallLog> listByThread(String threadId, int offset, int limit) throws Exception;

    @OQL("select count(l) from McpCallLog l where l.threadId=:1")
    public abstract long countByThread(String threadId) throws Exception;

    @OQL("select l from McpCallLog l where l.serverId=:1 order by l.createTime desc limit :2,:3")
    public abstract List<McpCallLog> listByServer(String serverId, int offset, int limit) throws Exception;

    @OQL("select count(l) from McpCallLog l where l.serverId=:1")
    public abstract long countByServer(String serverId) throws Exception;

    @OQL("select l from McpCallLog l where l.toolCallId=:1 order by l.createTime desc limit :2,:3")
    public abstract List<McpCallLog> listByToolCall(String toolCallId, int offset, int limit) throws Exception;

    @OQL("select count(l) from McpCallLog l where l.toolCallId=:1")
    public abstract long countByToolCall(String toolCallId) throws Exception;

    @OQL("select l from McpCallLog l order by l.createTime desc limit :1,:2")
    public abstract List<McpCallLog> listAll(int offset, int limit) throws Exception;

    @OQL("select count(l) from McpCallLog l")
    public abstract long countAll() throws Exception;
}
