package com.cf.imes.module.system.controller.admin.funds.organamount;

import com.cf.imes.framework.common.pojo.CommonResult;
import com.cf.imes.module.system.controller.admin.funds.organamount.vo.ManageAmountOverviewRespVO;
import com.cf.imes.module.system.controller.admin.funds.organamount.vo.OrganFundsStatisticsReqVO;
import com.cf.imes.module.system.service.funds.organamount.OrganAmountService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
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 jakarta.annotation.Resource;
import jakarta.validation.Valid;

import java.util.Map;

import static com.cf.imes.framework.common.pojo.CommonResult.success;

/**
 * @author 组织资金
 */
@Tag(name = "管理后台 - 组织资金")
@RestController
@RequestMapping("/system/amount")
@Validated
public class OrganAmountController {


    @Resource
    private OrganAmountService organAmountService;

    @GetMapping("/manage/total")
    @Operation(summary = "获取管理端资金总览")
    public CommonResult<ManageAmountOverviewRespVO> getManageTotalAmount() {
        return success(organAmountService.getOrganAmountAll());
    }

    @GetMapping("/statistics/consumptionTrend")
    @Operation(summary = "获取组织消费趋势")
    public CommonResult<Map<String, Object>> getOrganConsumptionTrend(@Valid OrganFundsStatisticsReqVO reqVO) {
        return success(organAmountService.getConsumptionTrend(reqVO, true));
    }

    @GetMapping("/manage/statistics/consumptionTrend")
    @Operation(summary = "获取管理端消费趋势")
    public CommonResult<Map<String, Object>> getManageConsumptionTrend(@Valid OrganFundsStatisticsReqVO reqVO) {
        return success(organAmountService.getConsumptionTrend(reqVO, false));
    }
}
