agent-foundation/src/main/java/com/company/agentfoundation/agent/capability/CustomerDashboardDailyCapabilityHandler.java

53 lines
1.8 KiB
Java
Raw Normal View History

2026-06-08 18:29:56 +08:00
package com.company.agentfoundation.agent.capability;
2026-06-12 10:40:13 +08:00
import com.company.agentfoundation.agent.AgentCapabilityResponse;
2026-06-08 18:29:56 +08:00
import com.company.agentfoundation.agent.AgentIntent;
2026-06-12 10:40:13 +08:00
import com.company.agentfoundation.agent.AgentRequestContext;
import com.company.agentfoundation.integration.wecom.WecomStudentContactStats;
import com.company.agentfoundation.integration.wecom.WecomStudentContactStatsService;
2026-06-08 18:29:56 +08:00
import org.springframework.stereotype.Component;
2026-06-12 10:40:13 +08:00
import java.time.Instant;
2026-06-08 18:29:56 +08:00
import java.util.List;
2026-06-12 10:40:13 +08:00
import java.util.Map;
2026-06-08 18:29:56 +08:00
@Component
2026-06-12 10:40:13 +08:00
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()
2026-06-08 18:29:56 +08:00
);
}
}