package com.ruoyi.ibs.task.controller;


import com.github.pagehelper.Page;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataPageInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ibs.task.domain.entity.ImportExportTask;
import com.ruoyi.ibs.task.domain.vo.AlterConfigVO;
import com.ruoyi.ibs.task.service.ImportExportTaskService;
import com.ruoyi.ibs.task.service.TaskVisitRecordService;
import com.ruoyi.system.service.OssFileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

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

@Api(tags = "下载中心接口")
@RestController
@RequestMapping("/download")
public class DownloadCenterController extends BaseController {

    @Resource
    private TaskVisitRecordService taskVisitRecordService;

    @Resource
    private ImportExportTaskService importExportTaskService;

    @ApiOperation("下载中心列表")
    @Log(title = "下载中心-列表")
    @GetMapping("/list")
    public TableDataPageInfo<ImportExportTask> getTaskList() {
        Page<Object> page = startPage();
        List<ImportExportTask> list = importExportTaskService.getTaskList();
        return getDataTable(list, page);
    }

    @ApiOperation("下载走访记录")
    @Log(title = "下载中心-下载走访记录附件")
    @GetMapping("/visit/record")
    public void downloadFile(@RequestParam String fileUrl, HttpServletResponse response) {
        taskVisitRecordService.downloadFileByUUid(fileUrl, response);
    }

}
