package com.icomsys.main_vm.biz.rcp.oprManage;

import com.icomsys.main_vm.biz.rcp.conversation.service.NlpSettingService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@Controller
@Transactional
@Slf4j
@RequiredArgsConstructor
@RequestMapping("/admin/rcp/oprmanage")
public class OprManageNlpSettingController {


    private final NlpSettingService nlpSettingService;

    @GetMapping("/nlpSetting/manage.do")
    public String NlpSettingView(){
    return "adm/rcp/oprmanage/nlpSetting";
    }

    /**
     * @Name serviceNameList
     * @Description 유사도 조회
     * @Author 유관선
     * @CreateDate 2022. 5. 25.
     */
    @RequestMapping("/nlpSetting/selectSimilarityCriteria.do")
    public ModelAndView similarityCriteria(@RequestParam Map<String, String> dataMap) {

        log.info("dataMap -> {}", dataMap);
        return nlpSettingService.similarityCriteria(dataMap);
    }

    /**
     * @Name serviceNameList
     * @Description 프로젝트 설정 업데이트
     * @Author 유관선
     * @CreateDate 2022. 5. 25.
     */

    @RequestMapping("/nlpSetting/updateSimilarityCriteria.do")
    public ModelAndView updateUser(@RequestParam Map<String, String> dataMap) {
        return nlpSettingService.updateUser(dataMap);
    }

    /**
     * @Name trainingStartApi
     * @Description 시뮬레이터 학습 시작 API
     * @Author dongheejang
     * @CreateDate 2022. 10. 6.
     */
    @RequestMapping(value = "/nlpSetting/trainingStart.do", method = RequestMethod.GET)
    @ResponseBody
    public ModelAndView trainingStartApi(HttpServletRequest request, @RequestParam String serviceGroup, String custCode) {

        return nlpSettingService.trainingStart(custCode + "_RCP_" + serviceGroup);
    }

    /**
     * @Name trainingApplyApi
     * @Description 시뮬레이터 모델 반영 API
     * @Author dongheejang
     * @CreateDate 2022. 10. 6.
     */
    @RequestMapping(value = "/nlpSetting/trainingApply.do", method = RequestMethod.GET)
    @ResponseBody
    public ModelAndView trainingApplyApi(HttpServletRequest request, @RequestParam String serviceGroup, String custCode) {

        return nlpSettingService.trainingApply(custCode + "_RCP_" + serviceGroup);
    }

}
