From 0f810febc7fc55836ee97a67d5e5a205d9a6d382 Mon Sep 17 00:00:00 2001 From: "rui.zhang" Date: Fri, 21 Dec 2018 16:20:28 +0800 Subject: [PATCH] edit readme and alter Change-Id: I6530ff2a3c6614a6aab6d861c51a05adcfac1f07 --- README.md | 28 +++++++++++++++---- .../org/chobit/wp/model/response/Author.java | 7 ++--- .../org/chobit/wp/model/response/Post.java | 6 ++-- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 84dee6d..e62f8a8 100644 --- a/README.md +++ b/README.md @@ -15,10 +15,10 @@ WordPress Client是一个Java版的WordPress客户端操作库, 主要基于[W org.chobit.wp wordpress-client - 0.1.1 + x.x.x ``` -目前wp-client的版本是0.1.1。请尽量使用最新版本。 +目前wp-client的版本是0.1.2。请尽量使用最新版本。 ## 创建WordPress操作实例 @@ -77,12 +77,12 @@ getAuthors()方法返回的是用户相关的信息: ```json [ { - "user_id": "1", + "user_id": 1, "user_login": "zhyea", "display_name": "白42" }, { - "user_id": "2", + "user_id": 2, "user_login": "robin", "display_name": "robin" } @@ -133,11 +133,11 @@ getPosts方法如下: ```json [ { - "post_id": "2174", + "post_id": 2174, "post_title": "sbt下载加速方案" }, { - "post_id": "2170", + "post_id": 2170, "post_title": "Java 中文字符按Unicode排序" } ] @@ -157,7 +157,23 @@ getPost方法如下: ## 编辑文章 +编辑文章调用editPost()方法。 +```java + PostRequest post = new PostRequest(); + post.setPostTitle("测试编辑" + System.currentTimeMillis()); + post.setPostContent("这是一段编辑后的测试内容:" + System.currentTimeMillis()); + boolean result = wp.editPost(29, post); +``` +编辑文章时需要通过PostRequest实例完成。 + +注意,**只需要**为要修改的PostRequest属性赋值,不需修改的属性保留默认值即可。 ## 删除文章 +删除文章通过调用deletePost方法并传递postId来完成。 + +```java + int postId = 26; + boolean result = wp.deletePost(postId); +``` diff --git a/src/main/java/org/chobit/wp/model/response/Author.java b/src/main/java/org/chobit/wp/model/response/Author.java index 6246c8a..6f68abe 100644 --- a/src/main/java/org/chobit/wp/model/response/Author.java +++ b/src/main/java/org/chobit/wp/model/response/Author.java @@ -6,7 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; public class Author { @JsonProperty("user_id") - private String userId; + private Integer userId; @JsonProperty("user_login") private String userLogin; @@ -15,12 +15,11 @@ public class Author { @JsonProperty("display_name") private String displayName; - - public String getUserId() { + public Integer getUserId() { return userId; } - public void setUserId(String userId) { + public void setUserId(Integer userId) { this.userId = userId; } diff --git a/src/main/java/org/chobit/wp/model/response/Post.java b/src/main/java/org/chobit/wp/model/response/Post.java index 37c8c16..bb80467 100644 --- a/src/main/java/org/chobit/wp/model/response/Post.java +++ b/src/main/java/org/chobit/wp/model/response/Post.java @@ -9,7 +9,7 @@ import java.util.List; public class Post { @JsonProperty("post_id") - private String postId; + private Integer postId; @JsonProperty("post_title") private String postTitle; @@ -79,11 +79,11 @@ public class Post { private Enclosure enclosure; - public String getPostId() { + public Integer getPostId() { return postId; } - public void setPostId(String postId) { + public void setPostId(Integer postId) { this.postId = postId; }