package com.icomsys.main_vm.biz.rcp.learningTest.controller;

import com.icomsys.main_vm.biz.rcp.learningTest.service.LearningTestInferenceService;
import com.icomsys.main_vm.db.mybatis.alias.LoginVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import org.springframework.web.servlet.view.json.MappingJackson2JsonView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@Slf4j
@RequiredArgsConstructor
@RequestMapping("/admin/rcp/learningTest")
public class LearningTestInferenceController {

    @Resource
    MappingJackson2JsonView ajaxMainView;

    private final LearningTestInferenceService learningTestInferenceService;

    @GetMapping("/inference/manage.do")
    public String inference(){
        return "/adm/rcp/learningTest/inference";
    }

    /**
     * @Name inferenceTest
     * @Description 의도추론테스트 업로드, 다운로드
     * @Author 장동희
     * @CreateDate 2023. 3. 6.
     */
    @RequestMapping(value ="/inference/inferenceTest.do",method = RequestMethod.POST)
    public void inferenceTest(MultipartHttpServletRequest request, HttpServletResponse response, @RequestParam Map<String, String> dataMap) throws Exception {
        HashMap eMap = new HashMap();
        eMap.putAll(dataMap);
        try {
            learningTestInferenceService.testInferenceExcel(request, response, eMap);
        } catch (Exception e) {
            log.error("error download excel", e);
        }
    }

}
