package com.jeesharp.business.modules.marketing.stats.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.jeesharp.business.modules.marketing.stats.application.MarketingStatsApplicationService;
import com.jeesharp.business.modules.marketing.stats.vo.MarketingStatsOverviewVO;
import com.jeesharp.business.modules.marketing.stats.vo.MarketingStatsQueryVO;
import com.jeesharp.framework.pojo.AjaxResult;
import com.jeesharp.framework.web.controller.BaseController;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 会员营销统计 REST 接口。
 *
 * @author jeesharp
 * @since 2026-06-25
 */
@RestController
@RequestMapping(value = "${jeesharp.web.adminPath}/marketing/stats/v1")
@Tag(name = "会员营销统计", description = "入会、领券、核销数据概览")
@AllArgsConstructor
public class MarketingStatsController extends BaseController {

    private final MarketingStatsApplicationService marketingStatsApplicationService;

    @ApiOperationSupport(order = 1)
    @Operation(summary = "统计概览")
    @PreAuthorize("@ss.hasPermission('marketing:stats:overview')")
    @PostMapping("overview")
    public AjaxResult<MarketingStatsOverviewVO> overview(@RequestBody MarketingStatsQueryVO query) {
        return AjaxResult.okData(marketingStatsApplicationService.overview(query));
    }
}
