package cn.com.countrygarden.bi.main.controller.extension.v1;

import cn.com.countrygarden.bi.main.dto.extension.ExtensionDupDTO;
import cn.com.countrygarden.bi.main.dto.extension.ExtensionErpDTO;
import cn.com.countrygarden.bi.main.dto.extension.ExtensionReportDTO;
import cn.com.countrygarden.bi.main.service.AccessTokenService;
import cn.com.countrygarden.bi.main.service.extension.ExtensionExportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @ClassName ExtensionExportController
 * @Description  外拓绑定 --> 导出
 * @Author Sjiang
 * @Date 2019/1/23 16:17
 * @Version 1.0
 **/
@RestController
@RequestMapping("/api/extension/v1")
public class ExtensionExportController {

    @Autowired
    private ExtensionExportService service;
    @Autowired
    private AccessTokenService accessTokenService;

    /**
     * @Author Sjiang
     * @Description  签约已上会
     * @Date 20:24 2019/1/23
     * @Param [dto, response]
     * @return void
     **/
    @GetMapping(value = "/meet/export", produces = "multipart/form-data")
    public void meetDupReport(ExtensionDupDTO dto, HttpServletResponse response, HttpServletRequest request){
        try {
            service.meetDupExport(dto,accessTokenService, response, request);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    /**
     * @Author Sjiang
     * @Description  已录入ERP
     * @Date 20:24 2019/1/23
     * @Param [dto, response]
     * @return void
     **/
    @GetMapping(value = "/erp/recorded/export", produces = "multipart/form-data")
    public void erpRecordedReport(ExtensionErpDTO dto, HttpServletResponse response, HttpServletRequest request){
        try {
            service.erpRecordedExport(dto, accessTokenService, response, request);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    /**
     * @Author Sjiang
     * @Description  已绑定
     * @Date 20:24 2019/1/23
     * @Param [dto, response]
     * @return void
     **/
    @GetMapping(value = "/binding/export", produces = "multipart/form-data")
    public void bindingReport(ExtensionReportDTO dto, HttpServletResponse response, HttpServletRequest request){
        try {
            service.bindingExport(dto, accessTokenService, response, request);
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    /**
     * @Author Sjiang
     * @Description  未绑定的 DUP 数据
     * @Date 20:24 2019/1/23
     * @Param [dto, response]
     * @return void
     **/
    @GetMapping(value = "/dup/unbinding/export", produces = "multipart/form-data")
    public void dupUnbindingReport(ExtensionDupDTO dto, HttpServletResponse response, HttpServletRequest request){
        try {
            service.dupUnbindingExport(dto, accessTokenService, response, request);
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    /**
     * @Author Sjiang
     * @Description  未绑定的 ERP 数据
     * @Date 20:24 2019/1/23
     * @Param [dto, response]
     * @return void
     **/
    @GetMapping(value = "/erp/unbinding/export", produces = "multipart/form-data")
    public void erpUnbindingReport(ExtensionErpDTO dto, HttpServletResponse response, HttpServletRequest request){
        try {
            service.erpUnbindingExport(dto, accessTokenService, response, request);
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    /**
     * @Author Sjiang
     * @Description  外拓报表 导出
     * @Date 20:24 2019/1/23
     * @Param [dto, response]
     * @return void
     **/
    @GetMapping(value = "/report/export", produces = "multipart/form-data")
    public void extensionReport(ExtensionReportDTO dto, HttpServletResponse response, HttpServletRequest request){
        try {
            service.reportExport(dto, accessTokenService, response, request);
        }catch (Exception e){
            e.printStackTrace();
        }
    }



}
