package com.jeesharp.business.modules.finance.platformrevenue.controller;

import com.jeesharp.business.modules.finance.platformrevenue.application.PlatformRevenueApplicationService;
import com.jeesharp.business.modules.finance.platformrevenue.dto.PlatformRevenueRollupDTO;
import com.jeesharp.business.modules.finance.platformrevenue.vo.PlatformRevenueRollupResultVO;
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 jakarta.validation.Valid;
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-29
 */
@RestController
@RequestMapping(value = "${jeesharp.web.adminPath}/finance/platformRevenue/v1")
@Tag(name = "平台收入日汇总")
@AllArgsConstructor
public class PlatformRevenueController extends BaseController {

    private final PlatformRevenueApplicationService platformRevenueApplicationService;

    @PostMapping("rollup")
    @Operation(summary = "手动触发平台收入日汇总")
    @PreAuthorize("@ss.hasPermission('manager:business:finance:platformRevenue:rollup')")
    public AjaxResult<PlatformRevenueRollupResultVO> rollup(@RequestBody @Valid PlatformRevenueRollupDTO dto) {
        return AjaxResult.okData(platformRevenueApplicationService.rollupManually(dto));
    }
}
