Codex Assistant
2 天以前 ba94ceae1315174798ae1967ef62268c6d16cd5b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package com.rongyichuang.dashboard.api;
 
import com.rongyichuang.dashboard.dto.response.DashboardStatsResponse;
import com.rongyichuang.dashboard.dto.response.RegionRegistrationStat;
import com.rongyichuang.dashboard.dto.response.RegistrationTrendPoint;
import com.rongyichuang.dashboard.service.DashboardService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.graphql.data.method.annotation.Argument;
import org.springframework.graphql.data.method.annotation.QueryMapping;
import org.springframework.stereotype.Controller;
 
import java.util.List;
 
/**
 * Dashboard GraphQL API
 */
@Controller
public class DashboardGraphqlApi {
 
    private static final Logger log = LoggerFactory.getLogger(DashboardGraphqlApi.class);
 
    private final DashboardService dashboardService;
 
    public DashboardGraphqlApi(DashboardService dashboardService) {
        this.dashboardService = dashboardService;
    }
 
    /**
     * 获取Dashboard统计数据
     */
    @QueryMapping
    public DashboardStatsResponse dashboardStats() {
        log.info("获取Dashboard统计数据");
        return dashboardService.getDashboardStats();
    }
 
    /**
     * 获取报名趋势数据
     */
    @QueryMapping
    public List<RegistrationTrendPoint> registrationTrend(@Argument Integer days) {
        log.info("获取报名趋势,天数: {}", days);
        return dashboardService.getRegistrationTrend(days);
    }
 
    /**
     * 获取区域报名分布
     */
    @QueryMapping
    public List<RegionRegistrationStat> registrationRegionStats() {
        log.info("获取区域报名分布");
        return dashboardService.getRegionRegistrationStats();
    }
}