package com.pig4cloud.pig.marketing.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pig4cloud.pig.common.core.util.R;
import com.pig4cloud.pig.common.security.annotation.Inner;
import com.pig4cloud.pig.marketing.api.dto.data.MarketingDataReportDTO;
import com.pig4cloud.pig.marketing.api.dto.data.PageSecondLevelDataDTO;
import com.pig4cloud.pig.marketing.api.vo.data.MarketingDataReportVO;
import com.pig4cloud.pig.marketing.api.dto.data.PageFirstLevelDataDTO;
import com.pig4cloud.pig.marketing.api.vo.data.PageFirstLevelDataVO;
import com.pig4cloud.pig.marketing.api.vo.data.PageSecondLevelDataVO;
import com.pig4cloud.pig.marketing.service.MarketingDataService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import lombok.AllArgsConstructor;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;


/**
 * @author: lwh
 * @date: 2025-07-21
 * @description: 营销数据统计
 */
@RestController
@AllArgsConstructor
@RequestMapping("/data")
@Tag(description = "marketingData", name = "营销数据统计")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class MarketingDataController {

	private final MarketingDataService dataService;

	@Inner(value = false)
	@PostMapping("/report")
	@Operation(summary = "上报营销数据")
	public R<MarketingDataReportVO> reportMarketingData(@RequestBody MarketingDataReportDTO reqDto, HttpServletRequest request) {
		MarketingDataReportVO result= dataService.reportMarketingData(reqDto, request);
		return R.ok(result);
	}

	@GetMapping("/page")
	@Operation(summary = "分页统计一级营销数据")
	public R<Page<PageFirstLevelDataVO>> pageFirstLevelData(@ParameterObject PageFirstLevelDataDTO reqDto) {
		return R.ok(dataService.pageFirstLevelData(reqDto));
	}

	@GetMapping("/detail")
	@Operation(summary = "分页统计二级营销数据")
	public R<Page<PageSecondLevelDataVO>> pageSecondLevelData(@ParameterObject PageSecondLevelDataDTO reqDto) {
		return R.ok(dataService.pageSecondLevelData(reqDto));
	}

}
