package com.dayou.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dayou.common.RestResponse;
import com.dayou.dto.PersonalStatisticalSelectDTO;
import com.dayou.service.IPersonalStatisticalStatementService;
import com.dayou.vo.PersonalDepEfficiencyVO;
import com.dayou.vo.PersonalEfficiencyDetailVO;
import com.dayou.vo.PersonalInwardEfficiencyVO;
import com.dayou.vo.PersonalOutwardEfficiencyVO;
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.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("personal/statisticalStatement")
public class PersonalStatisticalStatementController extends BaseController{

    @Autowired
    private IPersonalStatisticalStatementService personalStatisticalStatementService;

    /**
     * 个贷部门效率值查询
     * @param dto 查询dto
     * @return List<PersonalDepEfficiencyVO>
     */
    @GetMapping("/department/getPersonalDepEfficiencyVO")
    public RestResponse<List<PersonalDepEfficiencyVO>> getPersonalDepEfficiencyVO(PersonalStatisticalSelectDTO dto) {
        return RestResponse.data(personalStatisticalStatementService.getPersonalDepEfficiencyVO(dto));
    }

    /**
     * 个贷部门效率值导出
     * @param dto 查询dto
     */
    @GetMapping("/department/getPersonalDepEfficiencyVO/export")
    public void exportPersonalDepEfficiencyVO(PersonalStatisticalSelectDTO dto, HttpServletResponse response) throws IOException {
        List<PersonalDepEfficiencyVO> result = personalStatisticalStatementService.getPersonalDepEfficiencyVO(dto);
        exportPlus(response, "个贷部门效率值表", result,PersonalDepEfficiencyVO.class);
    }

    /**
     * 获取效率值相关个贷订单列表
     * @param page 分页
     * @param dto 查询dto
     * @return Page<PersonalEfficiencyDetailVO>
     */
    @GetMapping("/getPersonalEfficiencyDetailVO")
    public RestResponse<Page<PersonalEfficiencyDetailVO>> getPersonalEfficiencyDetailVO(Page page, PersonalStatisticalSelectDTO dto) {
        return RestResponse.data(personalStatisticalStatementService.getPersonalEfficiencyDetailVO(page, dto));
    }

    /**
     * 导出效率值相关个贷订单列表
     * @param dto 查询dto
     */
    @GetMapping("/getPersonalEfficiencyDetailVO/export")
    public void exportPersonalEfficiencyDetailVO(PersonalStatisticalSelectDTO dto, HttpServletResponse response) throws IOException {
        List<PersonalEfficiencyDetailVO> result = personalStatisticalStatementService.exportPersonalEfficiencyDetailVO(dto);
        exportPlus(response, "个贷订单列表", result,PersonalEfficiencyDetailVO.class);
    }

    /**
     * 个贷外业效率值查询
     * @param dto 查询dto
     * @return RestResponse<List<PersonalOutwardEfficiencyVO>>
     */
    @GetMapping("/outward/getPersonalOutwardEfficiencyVO")
    public RestResponse<List<PersonalOutwardEfficiencyVO>> getPersonalOutwardEfficiencyVO(PersonalStatisticalSelectDTO dto) {
        return RestResponse.data(personalStatisticalStatementService.getPersonalOutwardEfficiencyVO(dto));
    }

    /**
     * 个贷外业效率值导出
     * @param dto 查询dto
     */
    @GetMapping("/outward/getPersonalOutwardEfficiencyVO/export")
    public void exportPersonalOutwardEfficiencyVO(PersonalStatisticalSelectDTO dto, HttpServletResponse response) throws IOException {
        List<PersonalOutwardEfficiencyVO> result = personalStatisticalStatementService.getPersonalOutwardEfficiencyVO(dto);
        exportPlus(response, "个贷外业效率值表", result, PersonalOutwardEfficiencyVO.class);
    }

    /**
     * 个贷内业效率值查询
     * @param dto 查询dto
     * @return RestResponse<List<PersonalInwardEfficiencyVO>>
     */
    @GetMapping("/inward/getPersonalInwardEfficiencyVO")
    public RestResponse<List<PersonalInwardEfficiencyVO>> getPersonalInwardEfficiencyVO(PersonalStatisticalSelectDTO dto) {
        return RestResponse.data(personalStatisticalStatementService.getPersonalInwardEfficiencyVO(dto));
    }

    /**
     * 个贷内业效率值导出
     * @param dto 查询dto
     */
    @GetMapping("/inward/getPersonalInwardEfficiencyVO/export")
    public void exportersonalInwardEfficiencyVO(PersonalStatisticalSelectDTO dto, HttpServletResponse response) throws IOException {
        List<PersonalInwardEfficiencyVO> result = personalStatisticalStatementService.getPersonalInwardEfficiencyVO(dto);
        exportPlus(response, "个贷内业效率值表", result, PersonalInwardEfficiencyVO.class);
    }

}
