public static String updateComment(String table, Comment comment) { return new Sql() .update(table) .setValues( valueIf("target_id", comment.getTarget().id, comment.getTarget().id != null), valueIf("target_type", comment.getTarget().type, comment.getTarget().type > 0), valueIf("destroyed_time", comment.getDestroyedTime(), comment.getDestroyedTime() > 0), valueIf("commenter", comment.getCommenterId(), comment.getCommenterId() > 0), valueIf("message", comment.getMessage(), comment.getMessage() != null), valueIf("can_like", comment.getCanLike(), true)) .where("comment_id=:comment_id AND destroyed_time=0", "comment_id", comment.getCommentId()) .and(" commenter=:commenter", "commenter", comment.getCommenterId()) .toString(); }
public static String saveComment(String table, Comment comment) { return new Sql() .insertInto(table) .values( value("comment_id", comment.getCommentId()), value("can_like", comment.getCanLike()), value("commenter", comment.getCommenterId()), value("created_time", comment.getCreatedTime()), value("destroyed_time", 0), value("device", comment.getDevice()), value("message", comment.getMessage()), value("target_id", comment.getTarget().id), value("target_type", comment.getTarget().type), value( "add_to", comment.getAddTo() != null ? StringHelper.join(comment.getAddTo().getIds(PeopleId.USER), ",") : "")) .toString(); }