package com.pig4cloud.pig.statistics.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pig4cloud.pig.common.core.util.R;
import com.pig4cloud.pig.statistics.api.dto.retention.GetFreshnessTrendDTO;
import com.pig4cloud.pig.statistics.api.dto.retention.GetRetentionTrendDTO;
import com.pig4cloud.pig.statistics.api.dto.retention.PageQueryRetentionDTO;
import com.pig4cloud.pig.statistics.api.vo.retention.GetFreshnessTrendVO;
import com.pig4cloud.pig.statistics.api.vo.retention.GetRetentionTrendVO;
import com.pig4cloud.pig.statistics.api.vo.retention.PageQueryRetentionVO;
import com.pig4cloud.pig.statistics.service.RetentionAnalyseService;
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.validation.Valid;
import lombok.AllArgsConstructor;
import org.springframework.http.HttpHeaders;
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;

/**
 * @author: lwh
 * @date: 2025-08-22
 * @description: 留存分析
 */
@RestController
@AllArgsConstructor
@RequestMapping("/retn")
@Tag(description = "retentionAnalyse", name = "留存分析")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class RetentionAnalyseController
{
	private final RetentionAnalyseService retentionAnalyseService;

/***************************************** 留存用户 *****************************************/

	@PostMapping("/view")
	@Operation(summary = "分页查询留存详情")
	public R<Page<PageQueryRetentionVO>> pageRetentionDetail(@Valid @RequestBody PageQueryRetentionDTO reqDto) {
		Page<PageQueryRetentionVO> page = retentionAnalyseService.pageRetentionDetail(reqDto);
		return R.ok(page);
	}

	@PostMapping("/trend")
	@Operation(summary = "查询留存趋势")
	public R<GetRetentionTrendVO> getRetentionTrend(@Valid @RequestBody GetRetentionTrendDTO reqDto) {
		GetRetentionTrendVO result = retentionAnalyseService.getRetentionTrend(reqDto);
		return R.ok(result);
	}

	@PostMapping("/view/export")
	@Operation(summary = "导出留存详情")
	public R exportRetentionDetail(@Valid @RequestBody GetRetentionTrendDTO reqDto) {
		return R.ok();
	}

/***************************************** 用户新鲜度 *****************************************/

	@PostMapping("/freshness/trend")
	@Operation(summary = "查询用户新鲜度趋势")
	public R<GetFreshnessTrendVO> getFreshnessTrend(@Valid @RequestBody GetFreshnessTrendDTO reqDto) {
		GetFreshnessTrendVO result = retentionAnalyseService.getFreshnessTrend(reqDto);
		return R.ok(result);
	}

	@PostMapping("/freshness/export")
	@Operation(summary = "导出用户新鲜度趋势")
	public R exportFreshnessTrend(@Valid @RequestBody GetFreshnessTrendDTO reqDto) {
		return R.ok();
	}

/***************************************** 用户活跃度 *****************************************/

	@PostMapping("/engagement/trend")
	@Operation(summary = "查询用户活跃度趋势")
	public R<GetFreshnessTrendVO> getEngagementTrend(@Valid @RequestBody GetFreshnessTrendDTO reqDto) {
		GetFreshnessTrendVO result = retentionAnalyseService.getEngagementTrend(reqDto);
		return R.ok(result);
	}

	@PostMapping("/engagement/export")
	@Operation(summary = "导出用户活跃度趋势")
	public R exportEngagementTrend(@Valid @RequestBody GetFreshnessTrendDTO reqDto) {
		return R.ok();
	}

}
