package jnpf.cultivate.controller.web.promotion;

import jnpf.base.ActionResult;
import jnpf.base.vo.PageListVO;
import jnpf.cultivate.service.FtbCultivatePromotionService;
import jnpf.model.cultivate.dto.promotion.FtbMapsOrgWisdomStatisticDTO;
import jnpf.model.cultivate.dto.promotion.FtbMapsPersonWisdomStatisticDTO;
import jnpf.model.cultivate.vo.promotion.FtbCultivateMapsOrgWisdomStatisticVO;
import jnpf.model.cultivate.vo.promotion.FtbCultivateMapsPersonWisdomStatisticVO;
import jnpf.util.EasyExcelUtil;
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;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * web学习地图统计
 * @author hao.peng
 */
@RestController
@RequestMapping("/cul_pro/statistic")
public class FtbCultivateMapsController {

    @Resource
    FtbCultivatePromotionService service;

    /**
     * 组织维度统计
     * @param statisticDTO
     * @return
     */
    @PostMapping("/org-list-statistics")
    public ActionResult<PageListVO<FtbCultivateMapsOrgWisdomStatisticVO>> organizationListStatistics(
            @RequestBody FtbMapsOrgWisdomStatisticDTO statisticDTO){
        PageListVO<FtbCultivateMapsOrgWisdomStatisticVO> listVO = service.organizationListStatistics(statisticDTO);
        return ActionResult.success(listVO);
    }
    /**
     * 组织维度统计 导出
     * @param statisticDTO
     */
    @PostMapping("/org-list-statistics/export")
    public void exportInformationorganization(@RequestBody FtbMapsOrgWisdomStatisticDTO statisticDTO, HttpServletResponse response) throws IOException {
        PageListVO<FtbCultivateMapsOrgWisdomStatisticVO> listVO = service.organizationListStatistics(statisticDTO);
        EasyExcelUtil.simpleWrite(listVO.getList(), "组织维度统计", FtbCultivateMapsOrgWisdomStatisticVO.class, response);
    }
    /**
     * 个人维度统计
     * @param personWisdomStatisticDTO
     * @return
     */
    @PostMapping("/person-list-statistics")
    public ActionResult<PageListVO<FtbCultivateMapsPersonWisdomStatisticVO>> personListStatistics(@RequestBody FtbMapsPersonWisdomStatisticDTO personWisdomStatisticDTO){
        PageListVO<FtbCultivateMapsPersonWisdomStatisticVO> listVO = service.personListStatistics(personWisdomStatisticDTO);
        return ActionResult.success(listVO);
    }

    /**
     * 个人维度统计导出信息
     * @param personWisdomStatisticDTO
     */
    @PostMapping("/person-list-statistics/export")
    public void exportInformationPerson(@RequestBody FtbMapsPersonWisdomStatisticDTO personWisdomStatisticDTO, HttpServletResponse response) throws IOException {
        PageListVO<FtbCultivateMapsPersonWisdomStatisticVO> listVO = service.personListStatistics(personWisdomStatisticDTO);
        EasyExcelUtil.simpleWrite(listVO.getList(), "个人维度统计", FtbCultivateMapsPersonWisdomStatisticVO.class, response);
    }
}
