Пример #1
0
  /**
   * @Description: 组织sql
   *
   * @param note
   * @return:void
   */
  private String genSql(Note note) {
    // 组装sql
    StringBuilder sb = new StringBuilder();
    sb.append(" update tcnote  set ");

    if (note.getAuthorName() != null) {
      sb.append(" author_name='" + note.getAuthorName() + "', ");
    }
    if (note.getFromUrl() != null) {
      sb.append(" from_Url='" + note.getFromUrl() + "', ");
    }
    if (note.getNoteName() != null) {
      sb.append(" note_name='" + note.getNoteName() + "', ");
    }
    // flag=0防止note里面字段都是空的
    sb.append(" flag=0 where note_id= " + note.getNoteId());

    return sb.toString();
  }
Пример #2
0
  /**
   * @Description: 组装key值
   *
   * @param note
   * @return:void
   */
  private String[] genKeys(Note note) {
    String[] string = null;
    StringBuilder sb = new StringBuilder();

    if (note.getAuthorName() != null) {
      sb.append("," + "Note:authorName:" + note.getAuthorName());
    }
    if (note.getFromUrl() != null) {
      sb.append("," + "Note:fromUrl:" + note.getFromUrl() + ",");
    }
    if (note.getFlag() != null) {
      sb.append("," + "Note:flag:" + note.getFlag() + ",");
    }

    if (null != sb.toString()) {
      // 去除第一个逗号
      String replaceString = sb.toString().replaceFirst(",", "");
      string = replaceString.split(",");
    }
    return string;
  }
Пример #3
0
 private String insertSql(Note note) {
   // 组装sql
   StringBuilder sb = new StringBuilder();
   sb.append(
       "insert into tcnote (note_id,note_name,author_name,from_url,flag,noteBook,noteBookGroup) values ( ");
   sb.append(note.getNoteId() + ", ");
   sb.append("'" + note.getNoteName() + "', ");
   sb.append("'" + note.getAuthorName() + "', ");
   sb.append("'" + note.getFromUrl() + "', ");
   sb.append(note.getFlag() + ", ");
   sb.append(" 1, ");
   sb.append(" 1 )");
   return sb.toString();
 }