/**
   * 메일템플릿보기
   *
   * @param templateID
   * @return
   * @throws DataAccessException
   */
  public MailTemplate viewMailTemplate(int templateID) throws DataAccessException {
    MailTemplate mailTemplate = new MailTemplate();
    Map<String, Object> resultMap = null;
    String sql =
        QueryUtil.getStringQuery(
            "content_sql", "content.mailtemplate.view"); // 쿼리 프로퍼티파일의 키값에 해당되는 sql문을 읽어온다.
    Map<String, Object> param = new HashMap<String, Object>();
    param.put("templateID", new Integer(templateID));

    // SQL문이 실행된다.
    try {
      resultMap = getSimpleJdbcTemplate().queryForMap(sql, param);
    } catch (EmptyResultDataAccessException e1) {
    }

    if (resultMap != null) {
      mailTemplate.setTemplateID(Integer.parseInt(String.valueOf(resultMap.get("templateID"))));
      mailTemplate.setTemplateName((String) resultMap.get("templateName"));
      mailTemplate.setTemplateContent((String) resultMap.get("templateContent"));
      mailTemplate.setShareGroupID((String) resultMap.get("shareGroupID"));
      mailTemplate.setUserID((String) resultMap.get("userID"));
      mailTemplate.setUserName((String) resultMap.get("userName"));
      mailTemplate.setUseYN((String) resultMap.get("useYN"));
      mailTemplate.setGroupName((String) resultMap.get("groupName"));
      mailTemplate.setRegistDate(String.valueOf(resultMap.get("registDate")));
      mailTemplate.setTemplateType((String) resultMap.get("templateType"));
    }

    return mailTemplate;
  }
  /**
   * 사용자그룹(tm_usergroup)에서 보여준다
   *
   * @param groupID
   * @return
   * @throws DataAccessException
   */
  public Group viewGroup(String groupID) throws DataAccessException {

    Group group = new Group();
    Map<String, Object> resultMap = null;
    String sql =
        QueryUtil.getStringQuery(
            "admin_sql", "admin.usergroup.viewgroup"); // 쿼리 프로퍼티파일의 키값에 해당되는 sql문을 읽어온다.

    // 넘겨받은 파라미터를 세팅한다.
    Map<String, Object> param = new HashMap<String, Object>();
    param.put("groupID", groupID);

    // SQL문이 실행된다.
    try {
      resultMap = getSimpleJdbcTemplate().queryForMap(sql, param);
    } catch (EmptyResultDataAccessException e1) {
    }
    if (resultMap != null) {
      group.setGroupID((String) (resultMap.get("groupID")));
      group.setGroupName((String) (resultMap.get("groupName")));
      group.setDescription((String) (resultMap.get("description")));

    } else {
      group.setGroupID("0");
    }
    return group;
  }
  /**
   * 회원정보UI 기본정보 불러오기
   *
   * @param id
   * @return
   * @throws DataAccessException
   */
  public TargetUIList viewTargetUI(int id) throws DataAccessException {
    TargetUIList targetUIList = new TargetUIList();

    Map<String, Object> resultMap = null;

    String sql = QueryUtil.getStringQuery("targetlist_sql", "target.targetui.view");

    Map<String, Object> param = new HashMap<String, Object>();
    param.put("targetUIManagerID", new Integer(id));

    try {
      resultMap = getSimpleJdbcTemplate().queryForMap(sql, param);
    } catch (EmptyResultDataAccessException e1) {
    }

    if (resultMap != null) {
      targetUIList.setTargetUIManagerID(
          Integer.parseInt(String.valueOf(resultMap.get("targetUIManagerID"))));
      targetUIList.setTargetUIManagerName((String) resultMap.get("targetUIManagerName"));
      targetUIList.setDbID((String) resultMap.get("dbID"));
      targetUIList.setDescription((String) resultMap.get("description"));
      targetUIList.setSelectText((String) resultMap.get("selectText"));
      targetUIList.setFromText((String) resultMap.get("fromText"));
      targetUIList.setWhereText((String) resultMap.get("whereText"));
    }

    return targetUIList;
  }
  /**
   * 그룹의 기본 권한을 가져온다
   *
   * @param groupID
   * @return
   * @throws DataAccessException
   */
  public User viewGroupAuth(String groupID) throws DataAccessException {

    User user = new User();
    Map<String, Object> resultMap = null;
    String sql =
        QueryUtil.getStringQuery(
            "admin_sql", "admin.usergroup.groupAuth"); // 쿼리 프로퍼티파일의 키값에 해당되는 sql문을 읽어온다.
    // 넘겨받은 파라미터를 세팅한다.

    Map<String, Object> param = new HashMap<String, Object>();
    param.put("groupID", groupID);

    // SQL문이 실행된다.
    try {
      resultMap = getSimpleJdbcTemplate().queryForMap(sql, param);
    } catch (EmptyResultDataAccessException e1) {
    }

    if (resultMap != null) {

      user.setAuthCSV((String) (resultMap.get("auth_csv")));
      user.setAuthDirect((String) (resultMap.get("auth_direct")));
      user.setAuthRelated((String) (resultMap.get("auth_related")));
      user.setAuthQuery((String) (resultMap.get("auth_query")));
      user.setAuthSendMail((String) (resultMap.get("auth_send_mail")));
      user.setAuthWriteMail((String) (resultMap.get("auth_write_mail")));
      user.setAuthSendSMS((String) (resultMap.get("auth_send_sms")));
      user.setAuthWriteSMS((String) (resultMap.get("auth_write_sms")));
    }
    return user;
  }
  public User viewHelper() throws DataAccessException {

    User user = new User();
    Map<String, Object> resultMap = null;
    String sql =
        QueryUtil.getStringQuery(
            "admin_sql", "admin.usergroup.viewhelper"); // 쿼리 프로퍼티파일의 키값에 해당되는 sql문을 읽어온다.

    // 넘겨받은 파라미터를 세팅한다.
    Map<String, Object> param = new HashMap<String, Object>();

    // SQL문이 실행된다.
    try {
      resultMap = getSimpleJdbcTemplate().queryForMap(sql, param);
    } catch (EmptyResultDataAccessException e1) {
    }

    if (resultMap != null) {

      user.setUserID((String) (resultMap.get("userID")));

    } else {
      user.setUserID("");
    }
    return user;
  }
  /**
   * 회원정보UI Where절 정보 불러오기
   *
   * @param id
   * @return
   * @throws DataAccessException
   */
  @SuppressWarnings("unchecked")
  public List<TargetUIWhere> getMakeWhere(int id) throws DataAccessException {

    String sql = QueryUtil.getStringQuery("targetlist_sql", "target.targetui.viewmakewhere");

    ParameterizedRowMapper rowMapper =
        new ParameterizedRowMapper() {
          public Object mapRow(ResultSet rs, int rownum) throws SQLException {
            TargetUIWhere targetUIWhere = new TargetUIWhere();
            targetUIWhere.setTargetUIManagerID(rs.getInt("targetUIManagerID"));
            targetUIWhere.setWhereID(rs.getInt("whereID"));
            targetUIWhere.setWhereUIName(rs.getString("whereUIName"));
            targetUIWhere.setWhereFieldName(rs.getString("whereFieldName"));
            targetUIWhere.setWhereType(rs.getInt("whereType"));
            targetUIWhere.setDataType(rs.getString("dataType"));
            targetUIWhere.setExceptYN(rs.getString("exceptYN"));
            targetUIWhere.setCheckName(rs.getString("checkName"));
            targetUIWhere.setCheckValue(rs.getString("checkValue"));
            targetUIWhere.setPeriodStartType(rs.getString("periodStartType"));
            targetUIWhere.setPeriodEndType(rs.getString("periodEndType"));
            targetUIWhere.setDescription(
                (rs.getString("description") == null) ? "" : rs.getString("description"));

            return targetUIWhere;
          }
        };

    Map<String, Object> param = new HashMap<String, Object>();
    param.put("targetUIManagerID", new Integer(id));

    return getSimpleJdbcTemplate().query(sql, rowMapper, param);
  }
  /**
   * p>사용자그룹(tm_usergroup)에서 수정한다.
   *
   * @param groupID
   * @return
   * @throws DataAccessException
   */
  public int updateUser(User user) throws DataAccessException {

    String sql =
        QueryUtil.getStringQuery(
            "admin_sql", "admin.usergroup.updateuser"); // 쿼리 프로퍼티파일의 키값에 해당되는 sql문을 읽어온다.
    // 넘겨받은 파라미터를 세팅한다.

    Map<String, Object> param = new HashMap<String, Object>();
    param.put("userPWD", user.getUserPWD());
    param.put("userName", user.getUserName());
    param.put("groupID", user.getGroupID());
    param.put("userLevel", user.getUserLevel());
    param.put("description", user.getDescription());
    param.put("useYN", user.getUseYN());
    param.put("userID", user.getUserID());
    param.put("isHelper", user.getIsHelper());
    param.put("senderName", user.getSenderName());
    param.put("email", user.getEmail());
    param.put("cellPhone", user.getCellPhone());
    param.put("senderEmail", user.getSenderEmail());
    param.put("senderCellPhone", user.getSenderCellPhone());

    // SQL문이 실행된다.
    return getSimpleJdbcTemplate().update(sql, param);
  }
  /**
   * tm_target_ui_select 에서 원투원 정보 가져오기
   *
   * @param id
   * @return
   */
  @SuppressWarnings("unchecked")
  public List<TargetUIOneToOne> getSelectOneToOne(int id) throws DataAccessException {

    String sql = QueryUtil.getStringQuery("targetlist_sql", "target.targetui.getSelectOneToOne");

    ParameterizedRowMapper rowMapper =
        new ParameterizedRowMapper() {
          public Object mapRow(ResultSet rs, int rownum) throws SQLException {
            TargetUIOneToOne targetUIOneToOne = new TargetUIOneToOne();
            targetUIOneToOne.setTargetUIManagerID(rs.getInt("targetUIManagerID"));
            targetUIOneToOne.setSelectID(rs.getInt("selectID"));
            targetUIOneToOne.setSelectFieldName(rs.getString("selectFieldName"));
            targetUIOneToOne.setOnetooneID(rs.getInt("onetooneID"));
            targetUIOneToOne.setSelectDescription(rs.getString("selectDescription"));
            targetUIOneToOne.setCsvColumnPos(rs.getInt("csvColumnPos"));

            return targetUIOneToOne;
          }
        };

    Map<String, Object> param = new HashMap<String, Object>();
    param.put("targetUIManagerID", new Integer(id));

    return getSimpleJdbcTemplate().query(sql, rowMapper, param);
  }
  /**
   * 트리에 이용할 그룹별 사용자의 데이타를 불러온다
   *
   * @return
   * @throws DataAccessException
   */
  @SuppressWarnings("unchecked")
  public List<User> treeUser(String groupID) {

    String sql = QueryUtil.getStringQuery("admin_sql", "admin.usergroup.selectuser");
    sql += " WHERE u.groupID = '" + groupID + "' AND u.useYN='Y' ORDER BY u.userLevel, u.userName";

    ParameterizedRowMapper rowMapper =
        new ParameterizedRowMapper() {

          public Object mapRow(ResultSet rs, int rownum) throws SQLException {
            User user = new User();
            user.setUserID(rs.getString("userID"));
            user.setUserPWD(rs.getString("userPWD"));
            user.setGroupID(rs.getString("groupID"));
            user.setGroupName(rs.getString("groupName"));
            user.setUserName(rs.getString("userName"));
            user.setUserLevel(rs.getString("userLevel"));
            user.setEmail(rs.getString("email"));
            user.setCellPhone(rs.getString("cellPhone"));
            user.setDescription(rs.getString("description"));
            user.setUseYN(rs.getString("useYN"));
            user.setRegistDate(rs.getString("registDate"));
            user.setIsAdmin(rs.getString("isAdmin"));
            return user;
          }
        };

    return getSimpleJdbcTemplate().query(sql, rowMapper);
  }
  /**
   * targetID로 TargetManagerID를 가져온다
   *
   * @return
   * @throws DataAccessException
   */
  public int getTargetManagerID(int targetID) throws DataAccessException {
    String sql = QueryUtil.getStringQuery("targetlist_sql", "target.targetui.gettargetmanagerid");
    Map<String, Object> param = new HashMap<String, Object>();
    param.put("targetID", targetID);

    return getSimpleJdbcTemplate().queryForInt(sql, param);
  }
 /**
  * 대상자그룹등록
  *
  * @param targetList
  * @return
  * @throws DataAccessException
  */
 public int insertTargetList(TargetList targetList) throws DataAccessException {
   String sql = QueryUtil.getStringQuery("targetlist_sql", "target.targetui.insert");
   Map<String, Object> param = new HashMap<String, Object>();
   param.put("targetName", targetList.getTargetName());
   param.put("description", targetList.getDescription());
   param.put("userID", targetList.getUserID());
   param.put("bookMark", targetList.getBookMark());
   param.put("shareType", targetList.getShareType());
   param.put("shareID", targetList.getShareID());
   param.put("targetType", targetList.getTargetType());
   param.put("upload_key", targetList.getUploadKey());
   param.put("dbID", targetList.getDbID());
   param.put("queryText", targetList.getQueryText());
   param.put("countQuery", targetList.getCountQuery());
   param.put("targetCount", targetList.getTargetCount());
   param.put("directText", targetList.getDirectText());
   param.put("state", targetList.getState());
   param.put("sendedDate", targetList.getSendedDate());
   param.put("successYN", targetList.getSuccessYN());
   param.put("openYN", targetList.getOpenYN());
   param.put("clickYN", targetList.getClickYN());
   param.put("rejectcallYN", targetList.getRejectcallYN());
   param.put("connectedDbID", targetList.getConnectedDbID());
   param.put("massmailGroupID", targetList.getMassmailGroupID());
   param.put("targetGroupID", targetList.getTargetGroupID());
   param.put("targetUIID", targetList.getTargetUIID());
   return getSimpleJdbcTemplate().update(sql, param);
 }
  /**
   * 대상자를 보여준다.
   *
   * @param targetID
   * @return
   * @throws DataAccessException
   */
  public TargetList viewTargetList(int targetID) throws DataAccessException {
    TargetList targetList = new TargetList();
    Map<String, Object> resultMap = null;

    String sql = QueryUtil.getStringQuery("targetlist_sql", "target.targetui.viewtargetinfo");

    Map<String, Object> param = new HashMap<String, Object>();
    param.put("targetID", new Integer(targetID));

    // SQL문이 실행된다.
    try {
      resultMap = getSimpleJdbcTemplate().queryForMap(sql, param);
    } catch (EmptyResultDataAccessException e1) {
    }

    if (resultMap != null) {
      targetList.setTargetID(Integer.parseInt(String.valueOf(resultMap.get("targetID"))));
      targetList.setTargetName((String) resultMap.get("targetName"));
      targetList.setDescription((String) resultMap.get("description"));
      targetList.setUserID((String) resultMap.get("userID"));
      targetList.setGroupID((String) resultMap.get("groupID"));
      targetList.setBookMark((String) resultMap.get("bookMark"));
      targetList.setShareType((String) resultMap.get("shareType"));
      targetList.setShareID((String) resultMap.get("shareID"));
      targetList.setTargetType((String) resultMap.get("targetType"));
      targetList.setTargetGroupID(Integer.parseInt(String.valueOf(resultMap.get("targetGroupID"))));
    }
    return targetList;
  }
  /**
   * 계정의 총카운트를 구해온다.
   *
   * @return
   * @throws DataAccessException
   */
  public int getUserTotalCount(
      Map<String, String> searchMap, String groupID, String userLevel, String useYN)
      throws DataAccessException {

    String searchType = searchMap.get("searchType");
    String searchName = searchMap.get("searchName");
    String sql =
        QueryUtil.getStringQuery(
            "admin_sql", "admin.usergroup.totaluser"); // 쿼리 프로퍼티파일의 키값에 해당되는 sql문을 읽어온다.

    String sqlWhere = " WHERE 1=1 ";

    sql += sqlWhere;
    // 검색조건이 있다면
    if (searchName != null && !searchName.equals("")) {
      sql += " AND  " + searchType + " LIKE :searchName ";
    }

    if (groupID != null && !groupID.equals("")) {
      sql += " AND u.groupID = '" + groupID + "'";
    }

    if (userLevel != null && !userLevel.equals("")) {
      sql += " AND u.userLevel = '" + userLevel + "'";
    }

    if (useYN != null && !useYN.equals("")) {
      sql += " AND u.useYN = '" + useYN + "'";
    }

    Map<String, Object> param = new HashMap<String, Object>();
    param.put("searchName", "%" + searchName + "%");

    return getSimpleJdbcTemplate().queryForInt(sql, param);
  }
  /**
   * 모든 사용자 IsHelper 값 N으로 변경
   *
   * @return
   * @throws DataAccessException
   */
  public int setIsHelperN() throws DataAccessException {

    String sql =
        QueryUtil.getStringQuery(
            "admin_sql", "admin.usergroup.setishelpern"); // 쿼리 프로퍼티파일의 키값에 해당되는 sql문을 읽어온다.
    // SQL문이 실행된다.
    return getSimpleJdbcTemplate().update(sql);
  }
 /**
  * 사용자 ID 사용 제한 해제
  *
  * @param userID
  * @return
  * @throws DataAccessException
  */
 public int updateDerestrict(String userID) throws DataAccessException {
   String sql =
       QueryUtil.getStringQuery(
           "admin_sql", "admin.usergroup.updateDerestrict"); // 쿼리 프로퍼티파일의 키값에 해당되는 sql문을 읽어온다.
   // 넘겨받은 파라미터를 세팅한다.
   Map<String, Object> param = new HashMap<String, Object>();
   param.put("userID", userID);
   return getSimpleJdbcTemplate().update(sql, param);
 }
 public int deleteTargetUIGeneralInfo(int targetID, int targetUIManagerID)
     throws DataAccessException {
   String sql =
       QueryUtil.getStringQuery("targetlist_sql", "target.targetui.deletetargetgeneralinfo");
   sql = "delete from tm_target_ui_general_" + targetUIManagerID + " " + sql;
   Map<String, Object> param = new HashMap<String, Object>();
   param.put("targetID", new Integer(targetID));
   return getSimpleJdbcTemplate().update(sql, param);
 }
  /**
   * 사용자를 (ez_users)에서 보여준다
   *
   * @param groupID
   * @return
   * @throws DataAccessException
   */
  public User viewUser(String userID) throws DataAccessException {

    User user = new User();
    Map<String, Object> resultMap = null;
    String sql =
        QueryUtil.getStringQuery(
            "admin_sql", "admin.usergroup.viewuser"); // 쿼리 프로퍼티파일의 키값에 해당되는 sql문을 읽어온다.

    // 넘겨받은 파라미터를 세팅한다.
    Map<String, Object> param = new HashMap<String, Object>();
    param.put("userID", userID);

    // SQL문이 실행된다.
    try {
      resultMap = getSimpleJdbcTemplate().queryForMap(sql, param);
    } catch (EmptyResultDataAccessException e1) {
    }

    if (resultMap != null) {

      user.setUserID((String) (resultMap.get("userID")));
      user.setUserPWD((String) (resultMap.get("userPWD")));
      user.setUserName((String) (resultMap.get("userName")));
      user.setGroupID((String) (resultMap.get("groupID")));
      user.setGroupName((String) (resultMap.get("groupName")));
      user.setUserLevel((String) (resultMap.get("userLevel")));
      user.setEmail((String) (resultMap.get("email") == null ? "" : resultMap.get("email")));
      user.setCellPhone(
          (String) (resultMap.get("cellPhone") == null ? "" : resultMap.get("cellPhone")));
      user.setDescription(
          (String) (resultMap.get("description") == null ? "" : resultMap.get("description")));
      user.setUseYN((String) (resultMap.get("useYN")));
      user.setRegistDate(String.valueOf(resultMap.get("registDate")));
      user.setIsAdmin((String) (resultMap.get("isAdmin")));
      user.setAuthCSV((String) (resultMap.get("auth_csv")));
      user.setAuthDirect((String) (resultMap.get("auth_direct")));
      user.setAuthRelated((String) (resultMap.get("auth_related")));
      user.setAuthQuery((String) (resultMap.get("auth_query")));
      user.setAuthSendMail((String) (resultMap.get("auth_send_mail")));
      user.setAuthWriteMail((String) (resultMap.get("auth_write_mail")));
      user.setIsHelper((String) (resultMap.get("isHelper")));
      user.setSenderName(
          (String) (resultMap.get("senderName") == null ? "" : resultMap.get("senderName")));
      user.setSenderEmail(
          (String) (resultMap.get("senderEmail") == null ? "" : resultMap.get("senderEmail")));
      user.setSenderCellPhone(
          (String)
              (resultMap.get("senderCellPhone") == null ? "" : resultMap.get("senderCellPhone")));
      user.setAuthSendSMS((String) (resultMap.get("auth_send_sms")));
      user.setAuthWriteSMS((String) (resultMap.get("auth_write_sms")));
      user.setFailCount(Integer.parseInt(String.valueOf(resultMap.get("failCount"))));
    } else {
      user.setUserID("");
    }
    return user;
  }
 /**
  * 사용자의 데이타 권한을 삭제한다
  *
  * @param subMenuIDs
  * @return
  * @throws DataAccessException
  */
 public int deleteUserDataAuth(String userID, String dbID) throws DataAccessException {
   String sql =
       QueryUtil.getStringQuery(
           "admin_sql", "admin.usergroup.deleteDataAuth"); // 쿼리 프로퍼티파일의 키값에 해당되는 sql문을 읽어온다.
   Map<String, Object> param = new HashMap<String, Object>();
   param.put("userID", userID);
   param.put("dbID", dbID);
   // SQL문이 실행된다.
   return getSimpleJdbcTemplate().update(sql, param);
 }
  /**
   * p>그룹의 메뉴 권한을 삭제한다
   *
   * @param subMenuIDs
   * @return
   * @throws DataAccessException
   */
  public int deleteGroupAllMenuAuth(String groupID) throws DataAccessException {
    String sql =
        QueryUtil.getStringQuery(
            "admin_sql", "admin.usergroup.deleteAllMenuAuth"); // 쿼리 프로퍼티파일의 키값에 해당되는 sql문을 읽어온다.

    Map<String, Object> param = new HashMap<String, Object>();
    param.put("_group", "_group_" + groupID);

    // SQL문이 실행된다.
    return getSimpleJdbcTemplate().update(sql, param);
  }
  /**
   * 대상자에 대한 원투원정보를 인서트한다.
   *
   * @param onetooneTarget
   * @return
   * @throws DataAccessException
   */
  public int insertOnetooneTarget(OnetooneTarget onetooneTarget) throws DataAccessException {
    String sql = QueryUtil.getStringQuery("targetlist_sql", "target.targetui.insertonetoonetarget");
    Map<String, Object> param = new HashMap<String, Object>();
    param.put("targetID", onetooneTarget.getTargetID());
    param.put("fieldName", onetooneTarget.getFieldName());
    param.put("onetooneID", onetooneTarget.getOnetooneID());
    param.put("fieldDesc", onetooneTarget.getFieldDesc());
    param.put("csvColumnPos", onetooneTarget.getCsvColumnPos());

    return getSimpleJdbcTemplate().update(sql, param);
  }
  /**
   * 메일템플릿 입력
   *
   * @param mailTemplate
   * @return
   * @throws DataAccessException
   */
  public int insertMailTemplate(MailTemplate mailTemplate) throws DataAccessException {
    String sql = QueryUtil.getStringQuery("content_sql", "content.mailtemplate.insert");
    Map<String, Object> param = new HashMap<String, Object>();
    param.put("templateName", mailTemplate.getTemplateName());
    param.put("templateContent", mailTemplate.getTemplateContent());
    param.put("shareGroupID", mailTemplate.getShareGroupID());
    param.put("userID", mailTemplate.getUserID());
    param.put("useYN", mailTemplate.getUseYN());
    param.put("templateType", mailTemplate.getTemplateType());

    return getSimpleJdbcTemplate().update(sql, param);
  }
  /**
   * 사용자ID의 메뉴별권한
   *
   * @param userID
   * @param mainMenuID
   * @param subMenuID
   * @return
   * @throws DataAccessException
   */
  public Map<String, Object> getUserAuth(String userID, String mainMenuID, String subMenuID)
      throws DataAccessException {
    String sql =
        QueryUtil.getStringQuery(
            "admin_sql", "admin.usergroup.getauth"); // 쿼리 프로퍼티파일의 키값에 해당되는 sql문을 읽어온다.

    Map<String, Object> param = new HashMap<String, Object>();
    param.put("userID", userID);
    param.put("mainMenuID", mainMenuID);
    param.put("subMenuID", subMenuID);

    return getSimpleJdbcTemplate().queryForMap(sql, param);
  }
  /**
   * 사용자그룹(tm_usergroup) 리스트를 보여준다. //사용안하고 있음. 확실해지면 삭제 예정
   *
   * @return
   * @throws DataAccessException
   */
  @SuppressWarnings("unchecked")
  public List<Group> listGroup(int currentPage, int countPerPage, Map<String, String> searchMap)
      throws DataAccessException {
    int start = (currentPage - 1) * countPerPage;
    String searchType = searchMap.get("searchType");
    String searchName = searchMap.get("searchName");

    String sql = QueryUtil.getStringQuery("admin_sql", "admin.usergroup.selectgroup");

    // 검색조건이 있다면
    if (searchName != null && !searchName.equals("")) {
      sql += " WHERE " + searchType + " LIKE :searchName ";
    }

    String sqlTail = QueryUtil.getStringQuery("admin_sql", "admin.usergroup.grouptail");
    sql += sqlTail;

    ParameterizedRowMapper rowMapper =
        new ParameterizedRowMapper() {

          public Object mapRow(ResultSet rs, int rownum) throws SQLException {
            Group group = new Group();
            group.setGroupID(rs.getString("groupID"));
            group.setGroupName(rs.getString("groupName"));
            group.setDescription(rs.getString("description"));
            group.setUserCount(rs.getInt("userCount"));
            group.setRegistDate(rs.getString("registDate"));
            group.setIsAdmin(rs.getString("isAdmin"));
            return group;
          }
        };

    Map<String, Object> param = new HashMap<String, Object>();
    param.put("start", new Integer(start));
    param.put("countPerPage", new Integer(countPerPage));
    param.put("searchName", "%" + searchName + "%");

    return getSimpleJdbcTemplate().query(sql, rowMapper, param);
  }
  /**
   * p>사용자의 데이타 권한을 그룹의 데이타 권한으로 추가한다.
   *
   * @param subMenuIDs
   * @return
   * @throws DataAccessException
   */
  public int insertUserDataDefaultAuth(String userID) throws DataAccessException {

    String sql =
        QueryUtil.getStringQuery(
            "admin_sql",
            "admin.usergroup.insertDataDefaultAuth"); // 쿼리 프로퍼티파일의 키값에 해당되는 sql문을 읽어온다.
    // 넘겨받은 파라미터를 세팅한다.
    Map<String, Object> param = new HashMap<String, Object>();
    param.put("userID", userID);

    // SQL문이 실행된다.
    return getSimpleJdbcTemplate().update(sql, param);
  }
  /**
   * tm_usergroup에 그룹을 인서트한다.
   *
   * @param group
   * @return
   * @throws DataAccessException
   */
  public int insertGroup(Group group) throws DataAccessException {

    String sql =
        QueryUtil.getStringQuery(
            "admin_sql", "admin.usergroup.insertgroup"); // 쿼리 프로퍼티파일의 키값에 해당되는 sql문을 읽어온다.
    // 넘겨받은 파라미터를 세팅한다.

    Map<String, Object> param = new HashMap<String, Object>();
    param.put("groupID", group.getGroupID());
    param.put("groupName", group.getGroupName());
    param.put("description", group.getDescription());

    return getSimpleJdbcTemplate().update(sql, param);
  }
  /**
   * p>그룹의 메뉴 권한을 수정한다.
   *
   * @param subMenuIDs
   * @return
   * @throws DataAccessException
   */
  public int insertGroupMenuAuth(String groupID, String subMenuID) throws DataAccessException {

    String sql =
        QueryUtil.getStringQuery(
            "admin_sql", "admin.usergroup.insertGroupMenuAuth"); // 쿼리 프로퍼티파일의 키값에 해당되는 sql문을 읽어온다.
    // 넘겨받은 파라미터를 세팅한다.
    Map<String, Object> param = new HashMap<String, Object>();
    param.put("_groupID", "_group_" + groupID);
    param.put("subMenuID", subMenuID);
    param.put("groupID", groupID);

    // SQL문이 실행된다.
    return getSimpleJdbcTemplate().update(sql, param);
  }
  /**
   * 메일템플릿 카운트
   *
   * @param currentPage
   * @param countPerPage
   * @param searchMap
   * @return
   * @throws DataAccessException
   */
  public int getCountMailTemplate(
      String userID, String groupID, String userAuth, Map<String, String> searchMap)
      throws DataAccessException {
    String sql = QueryUtil.getStringQuery("content_sql", "content.mailtemplate.selectcount");

    String searchType = searchMap.get("sSearchType");
    String searchText = searchMap.get("sSearchText");
    String useYN = searchMap.get("sUseYN");
    String selectedGroupID = searchMap.get("sSelectedGroupID");

    // 소속관리자라면
    if (userAuth.equals(Constant.USER_LEVEL_MASTER)) {
      sql += QueryUtil.getStringQuery("content_sql", "content.mailtemplate.selectbygroup");
    }
    // 일반사용자라면
    else if (userAuth.equals(Constant.USER_LEVEL_USER)) {
      sql += QueryUtil.getStringQuery("content_sql", "content.mailtemplate.selectbyuser");
    }

    // 검색조건이 있다면
    if (searchText != null && !searchText.equals("")) {
      sql += " AND  " + searchType + " LIKE :searchText ";
    }
    if (useYN != null && !useYN.equals("")) {
      sql += " AND  t.useYN ='" + useYN + "' ";
    }

    if (selectedGroupID != null && !selectedGroupID.equals("")) {
      sql += " AND  shareGroupID ='" + selectedGroupID + "' ";
    }

    Map<String, Object> param = new HashMap<String, Object>();
    param.put("userID", userID);
    param.put("groupID", groupID);
    param.put("searchText", "%" + searchText + "%");
    return getSimpleJdbcTemplate().queryForInt(sql, param);
  }
  /**
   * 그룹의 총카운트를 구해온다.
   *
   * @return
   * @throws DataAccessException
   */
  public int getGroupTotalCount(Map<String, String> searchMap) throws DataAccessException {

    String searchType = searchMap.get("searchType");
    String searchName = searchMap.get("searchName");
    String sql =
        QueryUtil.getStringQuery(
            "admin_sql", "admin.usergroup.totalgroup"); // 쿼리 프로퍼티파일의 키값에 해당되는 sql문을 읽어온다.
    if (searchName != null && !searchName.equals("")) {
      sql += " WHERE " + searchType + " LIKE :searchName ";
    }
    Map<String, Object> param = new HashMap<String, Object>();
    param.put("searchName", "%" + searchName + "%");

    return getSimpleJdbcTemplate().queryForInt(sql, param);
  }
  /**
   * 회원정보UI 입력값을 저장한다
   *
   * @param targetUIGeneralInfo
   * @return
   * @throws DataAccessException
   */
  public int insertTargetUIGeneralInfo(
      int targetUIManagerID, TargetUIGeneralInfo targetUIGeneralInfo) throws DataAccessException {
    String sql = QueryUtil.getStringQuery("targetlist_sql", "target.targetui.insertgeneralinfo");
    sql = "insert into tm_target_ui_general_" + targetUIManagerID + sql;
    Map<String, Object> param = new HashMap<String, Object>();
    param.put("targetID", targetUIGeneralInfo.getTargetID());
    param.put("whereID", targetUIGeneralInfo.getWhereID());
    param.put("whereType", targetUIGeneralInfo.getWhereType());
    param.put("checkedItems", targetUIGeneralInfo.getCheckedItems());
    param.put("periodStartValue", targetUIGeneralInfo.getPeriodStartValue());
    param.put("periodEndValue", targetUIGeneralInfo.getPeriodEndValue());
    param.put("inputValue", targetUIGeneralInfo.getInputValue());

    return getSimpleJdbcTemplate().update(sql, param);
  }
 public int updateTargetList(TargetList targetList) throws DataAccessException {
   String sql = QueryUtil.getStringQuery("targetlist_sql", "target.targetui.update");
   Map<String, Object> param = new HashMap<String, Object>();
   param.put("targetID", targetList.getTargetID());
   param.put("targetName", targetList.getTargetName());
   param.put("description", targetList.getDescription());
   param.put("shareType", targetList.getShareType());
   param.put("shareID", targetList.getShareID());
   param.put("targetType", targetList.getTargetType());
   param.put("dbID", targetList.getDbID());
   param.put("queryText", targetList.getQueryText());
   param.put("countQuery", targetList.getCountQuery());
   param.put("targetCount", targetList.getTargetCount());
   param.put("targetGroupID", targetList.getTargetGroupID());
   return getSimpleJdbcTemplate().update(sql, param);
 }