예제 #1
0
  public void saveArticle(WxArticle wxArticle) {
    String createtime = DateUtil.dateToString(wxArticle.getCreatetime(), null);
    String sql =
        "INSERT INTO `wxarticle`(title, summary, type, content, status, price, createtime) "
            + "VALUES('TITLE','SUMMARY','TYPE','CONTENT','1', PRICE, 'CREATETIME');";

    sql =
        sql.replace("TITLE", wxArticle.getTitle())
            .replace("SUMMARY", wxArticle.getSummary())
            .replace("TYPE", wxArticle.getType())
            .replace("CONTENT", wxArticle.getContent())
            .replace("PRICE", wxArticle.getPrice() + "")
            .replace("CREATETIME", createtime);

    jdbcTemplate.execute(sql);
  }
예제 #2
0
  public void updateArticle(WxArticle wxArticle) {
    String createtime = DateUtil.dateToString(wxArticle.getCreatetime(), null);
    String sql =
        "UPDATE `wxarticle` SET title='TITLE', summary='SUMMARY', type='TYPE', content='CONTENT', price=PRICE, createtime='CREATETIME' "
            + "where id=ID;";

    sql =
        sql.replace("TITLE", wxArticle.getTitle())
            .replace("SUMMARY", wxArticle.getSummary())
            .replace("TYPE", wxArticle.getType())
            .replace("CONTENT", wxArticle.getContent())
            .replace("PRICE", wxArticle.getPrice() + "")
            .replace("CREATETIME", createtime)
            .replace("ID", wxArticle.getId() + "");

    jdbcTemplate.execute(sql);
  }