/**
   * 설문템플릿를 수정처리 한다.
   *
   * @param multiRequest
   * @param searchVO
   * @param commandMap
   * @param qustnrTmplatManageVO
   * @param bindingResult
   * @param model
   * @return "/uss/olp/qtm/EgovQustnrTmplatManageModifyActor"
   * @throws Exception
   */
  @RequestMapping(value = "/uss/olp/qtm/EgovQustnrTmplatManageModifyActor.do")
  public String QustnrTmplatManageModifyActor(
      final MultipartHttpServletRequest multiRequest,
      @ModelAttribute("searchVO") ComDefaultVO searchVO,
      Map commandMap,
      @ModelAttribute("qustnrTmplatManageVO") QustnrTmplatManageVO qustnrTmplatManageVO,
      BindingResult bindingResult,
      ModelMap model)
      throws Exception {

    // 0. Spring Security 사용자권한 처리
    Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated();
    if (!isAuthenticated) {
      model.addAttribute("message", egovMessageSource.getMessage("fail.common.login"));
      return "uat/uia/EgovLoginUsr";
    }

    // 로그인 객체 선언
    LoginVO loginVO = (LoginVO) EgovUserDetailsHelper.getAuthenticatedUser();

    // 서버  validate 체크
    beanValidator.validate(qustnrTmplatManageVO, bindingResult);
    if (bindingResult.hasErrors()) {
      model.addAttribute(
          "resultList",
          egovQustnrTmplatManageService.selectQustnrTmplatManageDetail(qustnrTmplatManageVO));
      return "/uss/olp/qtm/EgovQustnrTmplatManageModify";
    }

    // 아이디 설정
    qustnrTmplatManageVO.setFrstRegisterId((String) loginVO.getUniqId());
    qustnrTmplatManageVO.setLastUpdusrId((String) loginVO.getUniqId());

    final Map<String, MultipartFile> files = multiRequest.getFileMap();

    if (!files.isEmpty()) {
      for (MultipartFile file : files.values()) {
        System.out.println("getName =>" + file.getName());
        System.out.println("getOriginalFilename =>" + file.getOriginalFilename());
        // log.info("getOriginalFilename =>" + file.getOriginalFilename() );
        if (file.getName().equals("qestnrTmplatImage") && !file.getOriginalFilename().equals("")) {
          qustnrTmplatManageVO.setQestnrTmplatImagepathnm(file.getBytes());
        }
      }
    }
    egovQustnrTmplatManageService.updateQustnrTmplatManage(qustnrTmplatManageVO);

    return "redirect:/uss/olp/qtm/EgovQustnrTmplatManageList.do";
  }
  /**
   * 설문템플릿를 수정한다.
   *
   * @param searchVO
   * @param commandMap
   * @param qustnrTmplatManageVO
   * @param model
   * @return "/uss/olp/qtm/EgovQustnrTmplatManageModify"
   * @throws Exception
   */
  @RequestMapping(value = "/uss/olp/qtm/EgovQustnrTmplatManageModify.do")
  public String QustnrTmplatManageModify(
      @ModelAttribute("searchVO") ComDefaultVO searchVO,
      Map commandMap,
      QustnrTmplatManageVO qustnrTmplatManageVO,
      ModelMap model)
      throws Exception {
    String sLocationUrl = "/uss/olp/qtm/EgovQustnrTmplatManageModify";

    String sCmd = commandMap.get("cmd") == null ? "" : (String) commandMap.get("cmd");

    // List sampleList =
    // egovQustnrTmplatManageService.selectQustnrTmplatManageDetail(qustnrTmplatManageVO);
    model.addAttribute(
        "resultList",
        egovQustnrTmplatManageService.selectQustnrTmplatManageDetail(qustnrTmplatManageVO));

    return sLocationUrl;
  }
  /**
   * 설문템플릿 목록을 상세조회 조회한다.
   *
   * @param searchVO
   * @param qustnrTmplatManageVO
   * @param commandMap
   * @param model
   * @return "/uss/olp/qtm/EgovQustnrTmplatManageDetail"
   * @throws Exception
   */
  @RequestMapping(value = "/uss/olp/qtm/EgovQustnrTmplatManageDetail.do")
  public String EgovQustnrTmplatManageDetail(
      @ModelAttribute("searchVO") ComDefaultVO searchVO,
      QustnrTmplatManageVO qustnrTmplatManageVO,
      Map commandMap,
      ModelMap model)
      throws Exception {

    String sLocationUrl = "/uss/olp/qtm/EgovQustnrTmplatManageDetail";

    String sCmd = commandMap.get("cmd") == null ? "" : (String) commandMap.get("cmd");

    if (sCmd.equals("del")) {
      egovQustnrTmplatManageService.deleteQustnrTmplatManage(qustnrTmplatManageVO);
      sLocationUrl = "redirect:/uss/olp/qtm/EgovQustnrTmplatManageList.do";
    } else {
      model.addAttribute(
          "resultList",
          egovQustnrTmplatManageService.selectQustnrTmplatManageDetail(qustnrTmplatManageVO));
    }

    return sLocationUrl;
  }