package com.gic.haoban.manage.web.controller.data;

import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.api.dto.DownloadReportQDTQ;
import com.gic.enterprise.api.dto.security.DownloadReportDTO;
import com.gic.enterprise.api.service.DownloadReportService;
import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.haoban.common.utils.EntityUtil;
import com.gic.haoban.manage.web.qo.data.DataExportListQO;
import com.gic.haoban.manage.web.vo.content.creative.ContentMaterialVO;
import com.gic.marketing.pro.api.dto.clerktask.ClerkTaskPlanDTO;
import com.gic.marketing.pro.api.qdto.clerktask.ClerkTaskPageQDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 数据导出
 */
@Controller
@RequestMapping("data/export")
public class DataExportController {
    private static Logger logger = LoggerFactory.getLogger(DataExportController.class);

    @Autowired
    private DownloadReportService downloadReportService ;

    /**
     * 数据导出列表
     */
    @RequestMapping("page-data-export")
    @ResponseBody
    public RestResponse<Page<DownloadReportDTO>> getTaskCount(@RequestBody DataExportListQO dataExportListQO) {
        String enterpriseId = dataExportListQO.getEnterpriseId();
        String clerkId = dataExportListQO.getClerkId();
        DownloadReportQDTQ downloadReportQDTQ = new DownloadReportQDTQ();
        downloadReportQDTQ.setCurrentPage(dataExportListQO.getPageNum());
        downloadReportQDTQ.setPageSize(dataExportListQO.getPageSize());
        downloadReportQDTQ.setEnterpriseId(enterpriseId);
        downloadReportQDTQ.setApplyClerkId(clerkId);
        DateTime date = DateUtil.date();
        downloadReportQDTQ.setApplyStartTime(DateUtil.offset(date, DateField.YEAR, -1));
        downloadReportQDTQ.setApplyEndTime(date);
        downloadReportQDTQ.setProjectCode("haoban_new");
        Page<DownloadReportDTO> page = downloadReportService.listDownloadReportByPage(downloadReportQDTQ);
        return RestResponse.successResult(page) ;
    }

}
