package jnpf.personnels.controller.web.black;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jnpf.base.ActionResult;
import jnpf.base.vo.PageListVO;
import jnpf.model.cultivate.CultivatePage;
import jnpf.model.personnels.dto.black.FtbPersonnelsBlackListHistoryDTO;
import jnpf.model.personnels.vo.black.FtbPersonnelsBlackListHistoryVO;
import jnpf.personnels.service.FtbPersonnelsBlacklistHistoryService;
import jnpf.util.excel.EasyExcelUtils;
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;

/**
 * web历史黑名单模块
 *
 * @author wcx
 * @since 2024-05-08
 */
@RestController
@RequestMapping("/ftb-personnels-blacklist-history")
public class FtbPersonnelsBlacklistHistoryController {

    @Autowired
    private FtbPersonnelsBlacklistHistoryService ftbPersonnelsBlacklistHistoryService;

    /**
     * 历史黑名单列表
     *
     * @return {@link ActionResult }
     */
    @GetMapping(value = "/list")
    public ActionResult<PageListVO<FtbPersonnelsBlackListHistoryVO>> listDropDown(CultivatePage cultivatePage
            , FtbPersonnelsBlackListHistoryDTO dto) {
        Page<FtbPersonnelsBlackListHistoryVO> page = cultivatePage.coverCultivatePage("a.F_CreatorTime");
        page = ftbPersonnelsBlacklistHistoryService.listDropDown(page, dto);
        PageListVO<FtbPersonnelsBlackListHistoryVO> result = CultivatePage.coverPageList(page);
        return ActionResult.success(result);
    }

    /**
     * 历史黑名单列表导出
     *
     * @return {@link ActionResult }
     */
    @GetMapping(value = "/list-export")
    public void listExport(CultivatePage cultivatePage
            , FtbPersonnelsBlackListHistoryDTO dto, HttpServletResponse response) throws IOException {
        Page<FtbPersonnelsBlackListHistoryVO> page = cultivatePage.coverCultivatePage("a.F_CreatorTime");
        page.setSize(-1);
        page = ftbPersonnelsBlacklistHistoryService.listDropDown(page, dto);
        EasyExcelUtils.exportExcel(response, "历史黑名单", page.getRecords(), FtbPersonnelsBlackListHistoryVO.class);
    }

}
