package com.hzs.report.member.controller.manage;

import com.hzs.common.core.utils.poi.ExcelUtil;
import com.hzs.common.core.web.controller.BaseController;
import com.hzs.common.core.web.page.TableDataInfo;
import com.hzs.common.security.utils.SecurityUtils;
import com.hzs.report.member.service.MemberReportService;
import com.hzs.report.member.vo.ActivationVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.List;

/**
 * @BelongsProject: hzs_java_cloud_africa
 * @BelongsPackage: com.hzs.report.member.controller.manage
 * @Author: yh
 * @CreateTime: 2024-08-02  13:51
 * @Description: 会员活跃度统计
 * @Version: 1.0
 */
@RestController
@RequestMapping("/manager/activation")
public class ActivationController extends BaseController {

    @Autowired
    private MemberReportService memberReportService;

    /**
     * 会员活跃度列表
     */
    @GetMapping("member-active-list")
    public TableDataInfo memberActiveList(Date startTime, Date endTime) {
        startPage();
        Integer pkCountry = SecurityUtils.getPkCountry();
        List<ActivationVO> activationVOList = memberReportService.memberActiveList(startTime, endTime, pkCountry);
        return getDataTable(activationVOList);
    }

    /**
     * 会员活跃度列表导出
     */
    @PostMapping("member-active-list-export")
    public void memberActiveListExport(Date startTime, Date endTime, HttpServletResponse response) {
        Integer pkCountry = SecurityUtils.getPkCountry();
        List<ActivationVO> activationVOList = memberReportService.memberActiveList(startTime, endTime, pkCountry);
        ExcelUtil<ActivationVO> util = new ExcelUtil<>(ActivationVO.class);
        util.exportExcel(response, activationVOList, "会员活跃度列表导出");
    }

}
