package sgc.portal.base.web;

import sgc.portal.base.service.ReportToFileService;
import sgc.portal.base.storage.model.FileBucket;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * <pre>
 * 시스템명   : Common
 * 프로그램ID :
 * 프로그램명  :
 * 설명 :
 * </pre>
 *
 * @author 이범근
 * @version 2020.04.08
 * @see kr.co.sgc.com.cmm.web
 * @since JDK1.8
 */
@RestController
@RequestMapping("/report")
public class ReportToFileController {
    @Autowired
    private ReportToFileService reportToFileService;

    @RequestMapping(value = "/toFile", method = RequestMethod.POST)
    public FileBucket makeFile(@RequestBody Map<String, Object> reportInfo) {

        String fileId = reportInfo.get("fileId").toString();
        String ozrName = reportInfo.get("ozrName").toString();
        String[] ozrParamVal = reportInfo.get("ozrParamVal").toString().split(",");
        String odiName = reportInfo.get("odiName").toString();
        String[] odiParamVal = reportInfo.get("odiParamVal").toString().split(",");
        String exportFormat = reportInfo.get("exportFormat").toString();
        String exportFileName = reportInfo.get("exportFileName").toString();

        return reportToFileService.makeFile(fileId, ozrName, ozrParamVal, odiName, odiParamVal, exportFormat, exportFileName);
    }

}
