/**
  * 설문문항를(을) 등록한다.
  *
  * @param searchVO - 조회할 정보가 담긴 VO
  * @throws Exception
  */
 public void insertQustnrQestnManage(QustnrQestnManageVO qustnrQestnManageVO) throws Exception {
   egovQustnrQestnManageService.insertQustnrQestnManage(qustnrQestnManageVO);
 }
  /**
   * 설문문항를 등록한다.
   *
   * @param searchVO
   * @param commandMap
   * @param qustnrQestnManageVO
   * @param bindingResult
   * @param model
   * @return "egovframework/com/uss/olp/qqm/EgovQustnrQestnManageRegist"
   * @throws Exception
   */
  @RequestMapping(value = "/uss/olp/qqm/EgovQustnrQestnManageRegist.do")
  public String qustnrQestnManageRegist(
      @ModelAttribute("searchVO") ComDefaultVO searchVO,
      Map commandMap,
      @ModelAttribute("qustnrQestnManageVO") QustnrQestnManageVO qustnrQestnManageVO,
      BindingResult bindingResult,
      ModelMap model)
      throws Exception {
    // 0. Spring Security 사용자권한 처리
    Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated();
    if (!isAuthenticated) {
      model.addAttribute("message", egovMessageSource.getMessage("fail.common.login"));
      return "egovframework/com/uat/uia/EgovLoginUsr";
    }

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

    String sLocationUrl = "egovframework/com/uss/olp/qqm/EgovQustnrQestnManageRegist";

    String sCmd = commandMap.get("cmd") == null ? "" : (String) commandMap.get("cmd");
    log.info("cmd =>" + sCmd);

    // 공통코드 질문유형 조회
    ComDefaultCodeVO voComCode = new ComDefaultCodeVO();
    voComCode.setCodeId("COM018");
    List listComCode = cmmUseService.selectCmmCodeDetail(voComCode);
    model.addAttribute("cmmCode018", listComCode);

    if (sCmd.equals("save")) {

      // 서버  validate 체크
      beanValidator.validate(qustnrQestnManageVO, bindingResult);
      if (bindingResult.hasErrors()) {
        // 설문제목가져오기
        String sQestnrId =
            commandMap.get("qestnrId") == null ? "" : (String) commandMap.get("qestnrId");
        String sQestnrTmplatId =
            commandMap.get("qestnrTmplatId") == null
                ? ""
                : (String) commandMap.get("qestnrTmplatId");

        log.info("sQestnrId =>" + sQestnrId);
        log.info("sQestnrTmplatId =>" + sQestnrTmplatId);
        if (!sQestnrId.equals("") && !sQestnrTmplatId.equals("")) {

          Map mapQustnrManage = new HashMap();
          mapQustnrManage.put("qestnrId", sQestnrId);
          mapQustnrManage.put("qestnrTmplatId", sQestnrTmplatId);

          model.addAttribute(
              "qestnrInfo",
              (Map) egovQustnrQestnManageService.selectQustnrManageQestnrSj(mapQustnrManage));
        }

        return "egovframework/com/uss/olp/qqm/EgovQustnrQestnManageRegist";
      }

      // 아이디 설정
      qustnrQestnManageVO.setFrstRegisterId((String) loginVO.getUniqId());
      qustnrQestnManageVO.setLastUpdusrId((String) loginVO.getUniqId());
      /** 목록으로갈때 검색조건 유지 */
      egovQustnrQestnManageService.insertQustnrQestnManage(qustnrQestnManageVO);
      sLocationUrl = "redirect:/uss/olp/qqm/EgovQustnrQestnManageList.do?";
      sLocationUrl = sLocationUrl + "searchMode=" + qustnrQestnManageVO.getSearchMode();
      sLocationUrl = sLocationUrl + "&qestnrId=" + qustnrQestnManageVO.getQestnrId();
      sLocationUrl = sLocationUrl + "&qestnrTmplatId=" + qustnrQestnManageVO.getQestnrTmplatId();

    } else {

      // 설문제목가져오기
      String sQestnrId =
          commandMap.get("qestnrId") == null ? "" : (String) commandMap.get("qestnrId");
      String sQestnrTmplatId =
          commandMap.get("qestnrTmplatId") == null ? "" : (String) commandMap.get("qestnrTmplatId");

      log.info("sQestnrId =>" + sQestnrId);
      log.info("sQestnrTmplatId =>" + sQestnrTmplatId);
      if (!sQestnrId.equals("") && !sQestnrTmplatId.equals("")) {

        Map mapQustnrManage = new HashMap();
        mapQustnrManage.put("qestnrId", sQestnrId);
        mapQustnrManage.put("qestnrTmplatId", sQestnrTmplatId);

        model.addAttribute(
            "qestnrInfo",
            (Map) egovQustnrQestnManageService.selectQustnrManageQestnrSj(mapQustnrManage));
      }
    }

    return sLocationUrl;
  }