package com.company.agentfoundation.agent.capability; import com.company.agentfoundation.agent.AgentCapabilityResponse; import com.company.agentfoundation.agent.AgentIntent; import com.company.agentfoundation.agent.AgentRequestContext; import com.company.agentfoundation.integration.wecom.WecomStudentContactStats; import com.company.agentfoundation.integration.wecom.WecomStudentContactStatsService; import org.springframework.stereotype.Component; import java.time.Instant; import java.util.List; import java.util.Map; @Component public class CustomerDashboardDailyCapabilityHandler implements AgentCapabilityHandler { private final WecomStudentContactStatsService studentContactStatsService; public CustomerDashboardDailyCapabilityHandler(WecomStudentContactStatsService studentContactStatsService) { this.studentContactStatsService = studentContactStatsService; } @Override public AgentIntent intent() { return AgentIntent.CUSTOMER_DASHBOARD_DAILY; } @Override public AgentCapabilityResponse handle(AgentRequestContext context) { WecomStudentContactStats stats = studentContactStatsService.fetchTodayStats(); return new AgentCapabilityResponse( intent().code(), intent().title(), intent().mcpGroup(), "ready", """ 学员联系数据已从企业微信实时获取。 学员总数:%d 今日新增:%d 跟进成员数:%d 今日收款:暂未接入 """.formatted(stats.totalStudents(), stats.todayNewStudents(), stats.followUserCount()).trim(), List.of("企业微信学员联系 API"), Map.of( "totalStudents", stats.totalStudents(), "todayNewStudents", stats.todayNewStudents(), "followUserCount", stats.followUserCount() ), Instant.now() ); } }