weixin4j-[mp|qy]:媒体接口类(MediaApi)查询素材接口调整:去掉offset,count替换为Pageable类
This commit is contained in:
@@ -32,7 +32,7 @@ public class MediaRecord implements Serializable {
|
||||
/**
|
||||
* 媒体类型
|
||||
*/
|
||||
@JSONField(serialize = false)
|
||||
@JSONField(serialize = false, deserialize = false)
|
||||
private MediaType mediaType;
|
||||
/**
|
||||
* 媒体信息
|
||||
@@ -40,6 +40,12 @@ public class MediaRecord implements Serializable {
|
||||
@JSONField(name = "item")
|
||||
private List<MediaItem> items;
|
||||
|
||||
/**
|
||||
* 分页信息
|
||||
*/
|
||||
@JSONField(serialize = false, deserialize = false)
|
||||
private Pageable pageable;
|
||||
|
||||
public int getTotalCount() {
|
||||
return totalCount;
|
||||
}
|
||||
@@ -72,10 +78,23 @@ public class MediaRecord implements Serializable {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
public Pageable getPageable() {
|
||||
return pageable;
|
||||
}
|
||||
|
||||
public void setPageable(Pageable pageable) {
|
||||
this.pageable = pageable;
|
||||
}
|
||||
|
||||
@JSONField(serialize = false)
|
||||
public Pagedata<MediaItem> getPagedata() {
|
||||
return new Pagedata<MediaItem>(pageable, totalCount, items);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MediaRecord [totalCount=" + totalCount + ", itemCount="
|
||||
+ itemCount + ", mediaType=" + mediaType + ", items=" + items
|
||||
+ "]";
|
||||
+ ", pageable=" + pageable + "]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,11 +5,12 @@ import java.io.Serializable;
|
||||
import com.foxinmy.weixin4j.model.Sort.Direction;
|
||||
|
||||
/**
|
||||
* 分页数据(页码从1开始
|
||||
*
|
||||
* @className Pageable
|
||||
* @author jy
|
||||
* @date 2014年12月27日
|
||||
* @since JDK 1.7
|
||||
* @see com.foxinmy.weixin4j.model.springframework.data.domain.Pageable
|
||||
*/
|
||||
public class Pageable implements Serializable {
|
||||
|
||||
@@ -38,6 +39,7 @@ public class Pageable implements Serializable {
|
||||
this.page = page;
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public Pageable(int page, int size, Direction direction,
|
||||
String... properties) {
|
||||
this(page, size, new Sort(direction, properties));
|
||||
@@ -49,6 +51,15 @@ public class Pageable implements Serializable {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
/**
|
||||
* page=1,size=20
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Pageable get() {
|
||||
return new Pageable(1, 20);
|
||||
}
|
||||
|
||||
public int getPageSize() {
|
||||
return size;
|
||||
}
|
||||
@@ -56,12 +67,15 @@ public class Pageable implements Serializable {
|
||||
public int getPageNumber() {
|
||||
return page;
|
||||
}
|
||||
|
||||
public Sort getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
public void setSort(Sort sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
public int getOffset() {
|
||||
return (page - 1) * size;
|
||||
}
|
||||
@@ -82,6 +96,7 @@ public class Pageable implements Serializable {
|
||||
public Pageable first() {
|
||||
return new Pageable(0, getPageSize(), getSort());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Pageable [page=" + page + ", size=" + size + ", sort=" + sort
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.foxinmy.weixin4j.tuple;
|
||||
|
||||
/**
|
||||
* 聊天消息元件
|
||||
* 企业号会话消息元件
|
||||
*
|
||||
* @className ChatTuple
|
||||
* @author jy
|
||||
|
||||
@@ -58,15 +58,33 @@ public class MpArticle implements Serializable {
|
||||
@JSONField(name = "cover_url")
|
||||
private String coverUrl;
|
||||
|
||||
@JSONCreator
|
||||
public MpArticle(@JSONField(name = "thumb_media_id") String thumbMediaId,
|
||||
@JSONField(name = "title") String title,
|
||||
@JSONField(name = "content") String content) {
|
||||
public MpArticle(String thumbMediaId, String title, String content) {
|
||||
this.thumbMediaId = thumbMediaId;
|
||||
this.title = title;
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
@JSONCreator
|
||||
public MpArticle(@JSONField(name = "thumbMediaId") String thumbMediaId,
|
||||
@JSONField(name = "author") String author,
|
||||
@JSONField(name = "title") String title,
|
||||
@JSONField(name = "sourceUrl") String sourceUrl,
|
||||
@JSONField(name = "content") String content,
|
||||
@JSONField(name = "digest") String digest,
|
||||
@JSONField(name = "showCoverPic") String showCoverPic,
|
||||
@JSONField(name = "contentUrl") String contentUrl,
|
||||
@JSONField(name = "coverUrl") String coverUrl) {
|
||||
this.thumbMediaId = thumbMediaId;
|
||||
this.author = author;
|
||||
this.title = title;
|
||||
this.sourceUrl = sourceUrl;
|
||||
this.content = content;
|
||||
this.digest = digest;
|
||||
this.showCoverPic = showCoverPic;
|
||||
this.contentUrl = contentUrl;
|
||||
this.coverUrl = coverUrl;
|
||||
}
|
||||
|
||||
public String getThumbMediaId() {
|
||||
return thumbMediaId;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user