Change-Id: I8dc305f944f8454795237abbfbe35048864d6b00
This commit is contained in:
rui.zhang 2019-01-14 22:17:56 +08:00
parent 5bbbcb9baf
commit 4b5e28016f
5 changed files with 93 additions and 10 deletions

View File

@ -0,0 +1,35 @@
package org.chobit.wp.enums;
import com.fasterxml.jackson.annotation.JsonValue;
/**
* @author robin
*/
public enum CommentStatus {
/**
* 允许评论
*/
OPEN("open"),
/**
* 不允许评论
*/
CLOSED("closed"),
/**
* 仅允许注册用户评论
*/
REGISTERED_ONLY("registered_only"),
;
public final String status;
CommentStatus(String status) {
this.status = status;
}
@JsonValue
public String getStatus() {
return status;
}
}

View File

@ -0,0 +1,30 @@
package org.chobit.wp.enums;
import com.fasterxml.jackson.annotation.JsonValue;
/**
* @author robin
*/
public enum PingStatus {
/**
* 打开pingback功能
*/
OPEN("open"),
/**
* 关闭pingback功能
*/
CLOSED("closed"),
;
public final String status;
PingStatus(String alias) {
this.status = alias;
}
@JsonValue
public String getStatus() {
return status;
}
}

View File

@ -1,5 +1,7 @@
package org.chobit.wp.enums;
import com.fasterxml.jackson.annotation.JsonValue;
/**
* @author robin
*/
@ -45,4 +47,9 @@ public enum PostStatus {
PostStatus(String alias) {
this.status = alias;
}
@JsonValue
public String getStatus() {
return status;
}
}

View File

@ -1,6 +1,8 @@
package org.chobit.wp.model.request;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.chobit.wp.enums.CommentStatus;
import org.chobit.wp.enums.PingStatus;
import org.chobit.wp.enums.PostStatus;
import org.chobit.wp.model.interval.Enclosure;
@ -25,7 +27,7 @@ public class PostRequest extends Request {
private String postType;
@JsonProperty("post_status")
private String postStatus = PostStatus.PUBLISH.status;
private PostStatus postStatus = PostStatus.PUBLISH;
@JsonProperty("post_title")
private String postTitle;
@ -52,10 +54,10 @@ public class PostRequest extends Request {
private String postPassword;
@JsonProperty("comment_status")
private String commentStatus;
private CommentStatus commentStatus = CommentStatus.OPEN;
@JsonProperty("ping_status")
private String pingStatus;
private PingStatus pingStatus = PingStatus.OPEN;
private Integer sticky;
@ -81,11 +83,11 @@ public class PostRequest extends Request {
this.postType = postType;
}
public String getPostStatus() {
public PostStatus getPostStatus() {
return postStatus;
}
public void setPostStatus(String postStatus) {
public void setPostStatus(PostStatus postStatus) {
this.postStatus = postStatus;
}
@ -153,19 +155,19 @@ public class PostRequest extends Request {
this.postPassword = postPassword;
}
public String getCommentStatus() {
public CommentStatus getCommentStatus() {
return commentStatus;
}
public void setCommentStatus(String commentStatus) {
public void setCommentStatus(CommentStatus commentStatus) {
this.commentStatus = commentStatus;
}
public String getPingStatus() {
public PingStatus getPingStatus() {
return pingStatus;
}
public void setPingStatus(String pingStatus) {
public void setPingStatus(PingStatus pingStatus) {
this.pingStatus = pingStatus;
}

View File

@ -1,6 +1,10 @@
package org.chobit.wp;
import org.chobit.wp.model.request.PostRequest;
import org.chobit.wp.tools.JsonKit;
import java.io.IOException;
import java.util.Map;
/**
* @author robin
@ -8,7 +12,12 @@ import java.io.IOException;
public class Test {
public static void main(String[] args) throws IOException {
System.out.println((char)(0X87));
PostRequest request = new PostRequest();
request.setPostName("ceshi");
request.setPostTitle("测试");
Map<String, Object> m = request.toMap();
System.out.println(JsonKit.toJson(m));
}
}