大重构:weixin4j精简为weixin4j-base、weixin4j-mp、weixin4j-qy、weixin4j-server四个子工程

This commit is contained in:
jinyu
2015-04-27 21:02:51 +08:00
parent 69c9bdffa4
commit 784d1f33ea
221 changed files with 24504 additions and 0 deletions
+51
View File
@@ -0,0 +1,51 @@
* 2014-10-31
+ `TokenApi`重命名为`TokenHolder`
+ 新增`WeixinConfig`等类
* 2014-11-06
+ 删除`WeixinConfig`类只保留`WeixinAccount`
* 2014-11-15
+ 新增`aes加密解密`函数
* 2014-11-19
+ 新增`WeixinQyAccount`企业号账号信息类
* 2014-11-23
+ 新增企业号消息体以及用`Responseable`,`Notifyable`,`Massable`三个接口标记不同的可接受的消息类型
* 2014-11-24
+ 将Action跟Mapping基础类并入到项目
* 2015-01-04
+ ConfigUtil类新增获取classpath目录下的资源路径的方法
* 2015-01-10
+ 重构token实现机制
+ 新增JSTICKET支持
* 2015-03-29
+ 单行注释调整为多行文档注释
* 2015-04-01
+ 新增异步消息事件[BatchjobresultMessage](./src/main/java/com/foxinmy/weixin4j/msg/event/BatchjobresultMessage.java)
* 2015-04-13
+ 删除WeixinTokenCreator与WeixinJSTicketCreator类
* 2015-04-19
+ 删除ActionMapping相关类
@@ -0,0 +1,27 @@
package com.foxinmy.weixin4j.tuple;
import java.beans.Transient;
import java.io.Serializable;
import com.alibaba.fastjson.annotation.JSONField;
/**
* 消息元件
*
* @className Tuple
* @author jy
* @date 2015年4月19日
* @since JDK 1.7
* @see
*/
public interface Tuple extends Serializable {
/**
* 消息类型
*
* @return
*/
@Transient
@JSONField(deserialize = false, serialize = false)
public String getMessageType();
}
@@ -0,0 +1,90 @@
package com.foxinmy.weixin4j.util;
import java.io.Serializable;
import com.foxinmy.weixin4j.util.Sort.Direction;
/**
* @className Pageable
* @author jy
* @date 2014年12月27日
* @since JDK 1.7
* @see org.springframework.data.domain.Pageable
*/
public class Pageable implements Serializable {
private static final long serialVersionUID = -8051554878205756307L;
private final int page;
private final int size;
private Sort sort;
/**
*
* @param page
* must not be less than one.
* @param size
* must not be less than one.
*/
public Pageable(int page, int size) {
if (page < 1) {
throw new IllegalArgumentException(
"Page index must not be less than one!");
}
if (size < 1) {
throw new IllegalArgumentException(
"Page size must not be less than one!");
}
this.page = page;
this.size = size;
}
public Pageable(int page, int size, Direction direction,
String... properties) {
this(page, size, new Sort(direction, properties));
}
public Pageable(int page, int size, Sort sort) {
this.page = page;
this.size = size;
this.sort = sort;
}
public int getPageSize() {
return size;
}
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;
}
public boolean hasPrevious() {
return page > 1;
}
public Pageable next() {
return new Pageable(getPageNumber() + 1, getPageSize(), getSort());
}
public Pageable previous() {
return getPageNumber() == 1 ? this : new Pageable(getPageNumber() - 1,
getPageSize(), getSort());
}
public Pageable first() {
return new Pageable(0, getPageSize(), getSort());
}
@Override
public String toString() {
return "Pageable [page=" + page + ", size=" + size + ", sort=" + sort
+ "]";
}
}
@@ -0,0 +1,67 @@
package com.foxinmy.weixin4j.util;
import java.io.Serializable;
import java.util.Iterator;
import java.util.List;
public class Pagedata<T> implements Serializable, Iterable<T> {
private static final long serialVersionUID = 163159826528502864L;
private final int total;
private final Pageable pageable;
private final List<T> content;
public Pagedata(Pageable pageable, int total, List<T> content) {
this.pageable = pageable;
this.total = total;
this.content = content;
}
public int getNumber() {
return pageable == null ? 0 : pageable.getPageNumber();
}
public int getSize() {
return pageable == null ? 0 : pageable.getPageSize();
}
public int getTotalPages() {
return getSize() == 0 ? 1 : (int) Math.ceil((double) total
/ (double) getSize());
}
public int getTotalElements() {
return total;
}
public int getNumberOfElements() {
return hasContent() ? 0 : content.size();
}
public boolean hasContent() {
return content != null && !content.isEmpty();
}
public boolean hasPrevious() {
return pageable == null ? false : pageable.hasPrevious();
}
public boolean hasNext() {
return getNumber() + 1 < getTotalPages();
}
public Sort getSort() {
return pageable == null ? null : pageable.getSort();
}
@Override
public Iterator<T> iterator() {
return hasContent() ? content.iterator() : null;
}
@Override
public String toString() {
return "Pagedata [total=" + total + ", pageable=" + pageable + "]";
}
}
@@ -0,0 +1,65 @@
package com.foxinmy.weixin4j.util;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
public class Sort implements Serializable {
private static final long serialVersionUID = -4298853295391613880L;
public static final Direction DEFAULT_DIRECTION = Direction.ASC;
private Map<Direction, List<String>> orders;
public Sort() {
}
public Sort(String... properties) {
this(DEFAULT_DIRECTION, properties);
}
public Sort(Direction direction, String... properties) {
this(direction, properties == null ? new ArrayList<String>() : Arrays
.asList(properties));
}
public Sort(Direction direction, List<String> properties) {
if (properties == null || properties.isEmpty()) {
throw new IllegalArgumentException(
"You have to provide at least one property to sort by!");
}
this.orders = new LinkedHashMap<Direction, List<String>>(
properties.size());
this.orders.put(direction, properties);
}
public Map<Direction, List<String>> getOrders() {
return orders;
}
public Map.Entry<String, String> getFirst() {
if (hasSort()) {
Entry<Direction, List<String>> firstEntry = orders.entrySet()
.iterator().next();
Map<String, String> firstMap = new HashMap<String, String>();
firstMap.put(firstEntry.getKey().name().toLowerCase(), firstEntry
.getValue().get(0));
return firstMap.entrySet().iterator().next();
}
return null;
}
public boolean hasSort() {
return orders != null && !orders.isEmpty();
}
public static enum Direction {
ASC, DESC;
}
@Override
public String toString() {
return "Sort [" + orders + "]";
}
}