package com.dsk.search.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.alibaba.fastjson2.JSONObject;
import com.dsk.common.core.domain.AjaxResult;
import com.dsk.common.utils.poi.ExcelUtil;
import com.dsk.jsk.domain.JskCombineSearchDto;
import com.dsk.jsk.domain.bo.ComposeQueryDto;
import com.dsk.search.service.BusinessOpportunityRadarService;
import com.dsk.search.service.ExportService;
import com.dsk.system.domain.vo.AptitudeVo;
import com.dsk.system.domain.vo.SysUserImportVo;
import com.dsk.system.service.ISysUserFileRecordService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;


/**
 * 查企业
 * @author lc
 * @ClassName ExportController
 * @Date 2023/12/06 16:40
 */
@RequestMapping("/export")
@RestController
public class ExportController {


    @Resource
    private ExportService exportService;
    @Resource
    private ISysUserFileRecordService sysUserFileRecordService;

    /**
     * 导出回调接口
     * @param object
     * @return
     */
    @PostMapping(value = "/backUrl")
    public AjaxResult exportBack(@RequestBody JSONObject object) {
        return sysUserFileRecordService.exportBack(object);
    }

    /**
     * 获取导入模板
     */
    @PostMapping("/aptitude/importTemplate")
    public void importTemplate(HttpServletResponse response) {
        List<Object> list = new ArrayList<>();
        list.add(new AptitudeVo("重庆市轨道交通（集团）有限公司"));
        ExcelUtil.exportTemplate(list, "企业数据", "excel/aptitudeImportTemplate.xlsx", response);
    }

    /*
     * 批量资质导出
     */
    @RequestMapping("/aptitude/file")
    public AjaxResult aptitudeFile(@RequestPart("file") MultipartFile file) throws Exception {
        return exportService.aptitudeFile(file);
    }

    /**
     * 集团成员列表导出
     */
    @PostMapping("/combine/memberList")
    public AjaxResult memberListExportPre(@RequestBody JskCombineSearchDto dto) throws Exception {
        return exportService.memberListExport(dto);
    }

    //集团中标业绩导出
    @PostMapping("/combine/win/bid")
    @SaCheckPermission("combine:info:export:win:bid")
    public AjaxResult exportWinBid(@RequestBody JskCombineSearchDto dto) {
        return exportService.exportWinBid(dto);
    }

    //集团招标业绩导出
    @PostMapping("/combine/bid")
    @SaCheckPermission("combine:info:export:win:bid")
    public AjaxResult exportBid(@RequestBody JskCombineSearchDto dto) {
        return exportService.exportBid(dto);
    }

}
