package com.ruoyi.web.controller.clock;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.clock.domain.vo.AgentRankVo;
import com.ruoyi.clock.domain.vo.DashboardStatisticVo;
import com.ruoyi.clock.domain.vo.ShopRankVo;
import com.ruoyi.clock.service.IClockRecordService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 仪表板控制器
 *
 * @author pengc
 * @date 2026-03-04
 */
@Validated
@Api(value = "仪表板控制器", tags = {"仪表板统计"})
@RequiredArgsConstructor
@RestController
@RequestMapping("/clock/dashboard")
public class DashboardController extends BaseController {

    private final IClockRecordService iClockRecordService;

    /**
     * 查询仪表板顶部统计数据
     * 包括：活动总数量、目前开展活动数量、昨日打卡人数、今日打卡人数
     */
    @ApiOperation("查询仪表板统计数据")
    @SaCheckPermission("clock:dashboard:statistic")
    @GetMapping("/statistic")
    public R<DashboardStatisticVo> statistic() {
        return R.ok(iClockRecordService.queryDashboardStatistic());
    }

    /**
     * 查询昨日代理商活动参与人数排行
     */
    @ApiOperation("昨日代理商活动参与人数排行")
    @SaCheckPermission("clock:dashboard:rank")
    @GetMapping("/agentRank")
    public R<List<AgentRankVo>> agentRank() {
        return R.ok(iClockRecordService.queryYesterdayAgentRank());
    }

    /**
     * 查询昨日门店活动参与人数排行
     */
    @ApiOperation("昨日门店活动参与人数排行")
    @SaCheckPermission("clock:dashboard:rank")
    @GetMapping("/shopRank")
    public R<List<ShopRankVo>> shopRank() {
        return R.ok(iClockRecordService.queryYesterdayShopRank());
    }

}
