系统配置类抽象化
This commit is contained in:
parent
f6c12e07f3
commit
18303642f2
@ -699,4 +699,6 @@
|
||||
|
||||
+ weixin4j-base:删除AbstractTokenCreator,引入CacheCreator<T>类
|
||||
|
||||
+ weixin4j-base:修改Memcached-Java-Client的依赖
|
||||
+ weixin4j-base:修改Memcached-Java-Client的依赖
|
||||
|
||||
+ weixin4j-base:系统配置类抽象化
|
||||
@ -41,7 +41,7 @@ public class WeixinException extends Exception {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getErrorMsg() {
|
||||
public String getErrorDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
@ -51,8 +51,8 @@ public class WeixinException extends Exception {
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
if (StringUtil.isNotBlank(code)) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append(code).append(" >> ").append(desc);
|
||||
String text = getErrorText();
|
||||
if (StringUtil.isNotBlank(text)) {
|
||||
|
||||
@ -36,11 +36,11 @@ import com.foxinmy.weixin4j.payment.mch.RedpacketSendResult;
|
||||
import com.foxinmy.weixin4j.payment.mch.RefundRecord;
|
||||
import com.foxinmy.weixin4j.payment.mch.RefundResult;
|
||||
import com.foxinmy.weixin4j.payment.mch.SettlementRecord;
|
||||
import com.foxinmy.weixin4j.setting.Weixin4jSettings;
|
||||
import com.foxinmy.weixin4j.type.BillType;
|
||||
import com.foxinmy.weixin4j.type.CurrencyType;
|
||||
import com.foxinmy.weixin4j.type.CustomsCity;
|
||||
import com.foxinmy.weixin4j.type.IdQuery;
|
||||
import com.foxinmy.weixin4j.util.Weixin4jSettings;
|
||||
|
||||
/**
|
||||
* 微信支付接口实现
|
||||
@ -85,14 +85,14 @@ public class WeixinPayProxy {
|
||||
*
|
||||
* @param settings
|
||||
* 支付相关配置信息
|
||||
* @see com.foxinmy.weixin4j.util.Weixin4jSettings
|
||||
* @see com.foxinmy.weixin4j.setting.Weixin4jSettings
|
||||
*/
|
||||
public WeixinPayProxy(Weixin4jSettings settings) {
|
||||
this.settings = settings;
|
||||
this.payApi = new PayApi(settings.getWeixinPayAccount());
|
||||
this.couponApi = new CouponApi(settings.getWeixinPayAccount());
|
||||
this.cashApi = new CashApi(settings.getWeixinPayAccount());
|
||||
this.customsApi = new CustomsApi(settings.getWeixinPayAccount());
|
||||
this.payApi = new PayApi(settings.getPayAccount());
|
||||
this.couponApi = new CouponApi(settings.getPayAccount());
|
||||
this.cashApi = new CashApi(settings.getPayAccount());
|
||||
this.customsApi = new CustomsApi(settings.getPayAccount());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -100,8 +100,8 @@ public class WeixinPayProxy {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public WeixinPayAccount getPayAccount() {
|
||||
return this.settings.getWeixinPayAccount();
|
||||
public WeixinPayAccount getWeixinPayAccount() {
|
||||
return this.settings.getPayAccount();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -0,0 +1,90 @@
|
||||
package com.foxinmy.weixin4j.setting;
|
||||
|
||||
import com.foxinmy.weixin4j.http.HttpParams;
|
||||
import com.foxinmy.weixin4j.token.FileTokenStorager;
|
||||
import com.foxinmy.weixin4j.token.TokenStorager;
|
||||
|
||||
/**
|
||||
* 系统配置相关
|
||||
*
|
||||
* @className SystemSettings
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2016年1月28日
|
||||
* @since JDK 1.6
|
||||
* @see
|
||||
*/
|
||||
public abstract class SystemSettings<T> {
|
||||
/**
|
||||
* 账号信息
|
||||
*/
|
||||
private T account;
|
||||
/**
|
||||
* Http参数
|
||||
*/
|
||||
private HttpParams httpParams;
|
||||
/**
|
||||
* token存储方式 默认为FileTokenStorager
|
||||
*/
|
||||
private TokenStorager tokenStorager;
|
||||
/**
|
||||
* 系统临时目录
|
||||
*/
|
||||
private String tmpdir;
|
||||
|
||||
/**
|
||||
* @param account
|
||||
*/
|
||||
public SystemSettings(T account) {
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
public T getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public HttpParams getHttpParams() {
|
||||
return httpParams;
|
||||
}
|
||||
|
||||
public HttpParams getHttpParams0() {
|
||||
if (httpParams == null) {
|
||||
return new HttpParams();
|
||||
}
|
||||
return httpParams;
|
||||
}
|
||||
|
||||
public String getTmpdir() {
|
||||
return tmpdir;
|
||||
}
|
||||
|
||||
public abstract String getTmpdir0();
|
||||
|
||||
public TokenStorager getTokenStorager() {
|
||||
return tokenStorager;
|
||||
}
|
||||
|
||||
public TokenStorager getTokenStorager0() {
|
||||
if (tokenStorager == null) {
|
||||
return new FileTokenStorager(getTmpdir0());
|
||||
}
|
||||
return tokenStorager;
|
||||
}
|
||||
|
||||
public void setHttpParams(HttpParams httpParams) {
|
||||
this.httpParams = httpParams;
|
||||
}
|
||||
|
||||
public void setTmpdir(String tmpdir) {
|
||||
this.tmpdir = tmpdir;
|
||||
}
|
||||
|
||||
public void setTokenStorager(TokenStorager tokenStorager) {
|
||||
this.tokenStorager = tokenStorager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "account=" + account + ", httpParams=" + httpParams
|
||||
+ ",tokenStorager=" + tokenStorager + ", tmpdir=" + tmpdir;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,106 @@
|
||||
package com.foxinmy.weixin4j.setting;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.foxinmy.weixin4j.model.WeixinAccount;
|
||||
import com.foxinmy.weixin4j.model.WeixinPayAccount;
|
||||
import com.foxinmy.weixin4j.util.StringUtil;
|
||||
import com.foxinmy.weixin4j.util.Weixin4jConfigUtil;
|
||||
|
||||
/**
|
||||
* 微信配置相关
|
||||
*
|
||||
* @className Weixin4jSettings
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2016年1月28日
|
||||
* @since JDK 1.6
|
||||
* @see
|
||||
*/
|
||||
public class Weixin4jSettings extends SystemSettings<WeixinAccount> {
|
||||
/**
|
||||
* 微信支付账号信息
|
||||
*/
|
||||
private WeixinPayAccount weixinPayAccount;
|
||||
/**
|
||||
* 支付接口需要的证书文件(*.p12)
|
||||
*/
|
||||
private String certificateFile;
|
||||
|
||||
/**
|
||||
* 默认使用weixin4j.properties配置的信息
|
||||
*/
|
||||
public Weixin4jSettings() {
|
||||
this(JSON.parseObject(Weixin4jConfigUtil.getValue("account"),
|
||||
WeixinPayAccount.class), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付代理接口
|
||||
*
|
||||
* @param weixinPayAccount
|
||||
* 商户信息
|
||||
* @param certificateFile
|
||||
* 支付接口需要的证书文件(*.p12),比如退款接口
|
||||
*/
|
||||
public Weixin4jSettings(WeixinPayAccount weixinPayAccount,
|
||||
String certificateFile) {
|
||||
this(weixinPayAccount);
|
||||
this.certificateFile = certificateFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付代理接口
|
||||
*
|
||||
* @param weixinPayAccount
|
||||
* 商户信息
|
||||
*/
|
||||
public Weixin4jSettings(WeixinPayAccount weixinPayAccount) {
|
||||
this(new WeixinAccount(weixinPayAccount.getId(),
|
||||
weixinPayAccount.getSecret()));
|
||||
this.weixinPayAccount = weixinPayAccount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 账号信息
|
||||
*
|
||||
* @param account
|
||||
*/
|
||||
public Weixin4jSettings(WeixinAccount account) {
|
||||
super(account);
|
||||
}
|
||||
|
||||
public WeixinPayAccount getPayAccount() {
|
||||
return weixinPayAccount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTmpdir0() {
|
||||
if (StringUtil.isBlank(getTmpdir())) {
|
||||
return Weixin4jConfigUtil.getClassPathValue("weixin4j.tmpdir",
|
||||
System.getProperty("java.io.tmpdir"));
|
||||
}
|
||||
return getTmpdir();
|
||||
}
|
||||
|
||||
public String getCertificateFile() {
|
||||
return certificateFile;
|
||||
}
|
||||
|
||||
public String getCertificateFile0() {
|
||||
if (StringUtil.isBlank(certificateFile)) {
|
||||
return Weixin4jConfigUtil.getClassPathValue(
|
||||
"weixin4j.certificate.file", "classpath:ca.p12");
|
||||
}
|
||||
return certificateFile;
|
||||
}
|
||||
|
||||
public void setCertificateFile(String certificateFile) {
|
||||
this.certificateFile = certificateFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Weixin4jSettings [weixinPayAccount=" + weixinPayAccount
|
||||
+ ", certificateFile=" + certificateFile + ", "
|
||||
+ super.toString() + "]";
|
||||
}
|
||||
}
|
||||
@ -22,7 +22,8 @@ public interface CacheCreator<T> {
|
||||
/**
|
||||
* 创建Cache
|
||||
*
|
||||
* @return
|
||||
* @throws WeixinException
|
||||
* @return 缓存对象
|
||||
*/
|
||||
public T create() throws WeixinException;
|
||||
}
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
package com.foxinmy.weixin4j.token;
|
||||
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
|
||||
/**
|
||||
* Cache的存储
|
||||
*
|
||||
@ -18,9 +16,8 @@ public interface CacheStorager<T> {
|
||||
* @param key
|
||||
* 缓存key
|
||||
* @return 缓存对象
|
||||
* @throws WeixinException
|
||||
*/
|
||||
T lookup(String key) throws WeixinException;
|
||||
T lookup(String key);
|
||||
|
||||
/**
|
||||
* 缓存新的对象
|
||||
@ -30,9 +27,8 @@ public interface CacheStorager<T> {
|
||||
*
|
||||
* @param cache
|
||||
* 将要缓存的对象
|
||||
* @throws WeixinException
|
||||
*/
|
||||
void caching(String key, T cache) throws WeixinException;
|
||||
void caching(String key, T cache);
|
||||
|
||||
/**
|
||||
* 移除缓存对象
|
||||
@ -41,10 +37,10 @@ public interface CacheStorager<T> {
|
||||
* 缓存key
|
||||
* @return 移除的对象
|
||||
*/
|
||||
T evict(String key) throws WeixinException;
|
||||
T evict(String key);
|
||||
|
||||
/**
|
||||
* 清除所有缓存对象(<font color="red">请慎重</font>)
|
||||
*/
|
||||
void clear() throws WeixinException;
|
||||
void clear();
|
||||
}
|
||||
|
||||
@ -6,14 +6,13 @@ import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.model.Token;
|
||||
import com.foxinmy.weixin4j.util.FileUtil;
|
||||
import com.foxinmy.weixin4j.xml.XmlStream;
|
||||
|
||||
/**
|
||||
* 用File形式保存Token信息
|
||||
*
|
||||
*
|
||||
* @className FileTokenStorager
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2015年1月9日
|
||||
@ -28,7 +27,7 @@ public class FileTokenStorager implements TokenStorager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Token lookup(String cacheKey) throws WeixinException {
|
||||
public Token lookup(String cacheKey) {
|
||||
File token_file = new File(String.format("%s/%s.xml", cachePath,
|
||||
cacheKey));
|
||||
try {
|
||||
@ -45,24 +44,24 @@ public class FileTokenStorager implements TokenStorager {
|
||||
}
|
||||
return null;
|
||||
} catch (IOException e) {
|
||||
throw new WeixinException(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void caching(String cacheKey, Token token) throws WeixinException {
|
||||
public void caching(String cacheKey, Token token) {
|
||||
try {
|
||||
XmlStream.toXML(
|
||||
token,
|
||||
new FileOutputStream(new File(String.format("%s/%s.xml",
|
||||
cachePath, cacheKey))));
|
||||
} catch (IOException e) {
|
||||
throw new WeixinException(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Token evict(String cacheKey) throws WeixinException {
|
||||
public Token evict(String cacheKey) {
|
||||
Token token = null;
|
||||
File token_file = new File(String.format("%s/%s.xml", cachePath,
|
||||
cacheKey));
|
||||
@ -79,7 +78,7 @@ public class FileTokenStorager implements TokenStorager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() throws WeixinException {
|
||||
public void clear() {
|
||||
File[] files = new File(cachePath).listFiles(new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File file) {
|
||||
|
||||
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.model.Token;
|
||||
import com.whalin.MemCached.MemCachedClient;
|
||||
import com.whalin.MemCached.SockIOPool;
|
||||
@ -28,12 +27,12 @@ public class MemcacheTokenStorager implements TokenStorager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Token lookup(String cacheKey) throws WeixinException {
|
||||
public Token lookup(String cacheKey) {
|
||||
return (Token) mc.get(cacheKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void caching(String cacheKey, Token token) throws WeixinException {
|
||||
public void caching(String cacheKey, Token token) {
|
||||
if (token.getExpiresIn() > 0) {
|
||||
mc.set(cacheKey, token,
|
||||
new Date(token.getCreateTime() + token.getExpiresIn()
|
||||
@ -44,14 +43,14 @@ public class MemcacheTokenStorager implements TokenStorager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Token evict(String cacheKey) throws WeixinException {
|
||||
public Token evict(String cacheKey) {
|
||||
Token token = lookup(cacheKey);
|
||||
mc.delete(cacheKey);
|
||||
return token;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() throws WeixinException {
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
||||
@ -3,12 +3,11 @@ package com.foxinmy.weixin4j.token;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.model.Token;
|
||||
|
||||
/**
|
||||
* 用内存保存Token信息(不推荐使用)
|
||||
*
|
||||
*
|
||||
* @className MemoryTokenStorager
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2016年1月24日
|
||||
@ -24,7 +23,7 @@ public class MemoryTokenStorager implements TokenStorager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Token lookup(String cacheKey) throws WeixinException {
|
||||
public Token lookup(String cacheKey) {
|
||||
Token token = this.CONMAP.get(cacheKey);
|
||||
if (token != null) {
|
||||
if ((token.getCreateTime() + (token.getExpiresIn() * 1000l) - CUTMS) > System
|
||||
@ -36,17 +35,17 @@ public class MemoryTokenStorager implements TokenStorager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void caching(String cacheKey, Token token) throws WeixinException {
|
||||
public void caching(String cacheKey, Token token) {
|
||||
this.CONMAP.put(cacheKey, token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Token evict(String cacheKey) throws WeixinException {
|
||||
public Token evict(String cacheKey) {
|
||||
return this.CONMAP.remove(cacheKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() throws WeixinException {
|
||||
public void clear() {
|
||||
this.CONMAP.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,6 @@ import redis.clients.jedis.JedisPool;
|
||||
import redis.clients.jedis.JedisPoolConfig;
|
||||
import redis.clients.jedis.Pipeline;
|
||||
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.model.Token;
|
||||
|
||||
/**
|
||||
@ -56,7 +55,7 @@ public class RedisTokenStorager implements TokenStorager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Token lookup(String cacheKey) throws WeixinException {
|
||||
public Token lookup(String cacheKey) {
|
||||
Jedis jedis = null;
|
||||
try {
|
||||
jedis = jedisPool.getResource();
|
||||
@ -73,7 +72,7 @@ public class RedisTokenStorager implements TokenStorager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void caching(String cacheKey, Token token) throws WeixinException {
|
||||
public void caching(String cacheKey, Token token) {
|
||||
Jedis jedis = null;
|
||||
try {
|
||||
jedis = jedisPool.getResource();
|
||||
@ -112,7 +111,7 @@ public class RedisTokenStorager implements TokenStorager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Token evict(String cacheKey) throws WeixinException {
|
||||
public Token evict(String cacheKey) {
|
||||
Token token = lookup(cacheKey);
|
||||
Jedis jedis = null;
|
||||
try {
|
||||
@ -127,7 +126,7 @@ public class RedisTokenStorager implements TokenStorager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() throws WeixinException {
|
||||
public void clear() {
|
||||
Jedis jedis = null;
|
||||
try {
|
||||
jedis = jedisPool.getResource();
|
||||
|
||||
@ -1,158 +0,0 @@
|
||||
package com.foxinmy.weixin4j.util;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.foxinmy.weixin4j.http.HttpParams;
|
||||
import com.foxinmy.weixin4j.model.WeixinAccount;
|
||||
import com.foxinmy.weixin4j.model.WeixinPayAccount;
|
||||
import com.foxinmy.weixin4j.token.FileTokenStorager;
|
||||
import com.foxinmy.weixin4j.token.TokenStorager;
|
||||
|
||||
/**
|
||||
* 微信配置相关
|
||||
*
|
||||
* @className Weixin4jSettings
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2016年1月28日
|
||||
* @since JDK 1.6
|
||||
* @see
|
||||
*/
|
||||
public class Weixin4jSettings {
|
||||
/**
|
||||
* 微信支付账号信息
|
||||
*/
|
||||
private WeixinPayAccount weixinPayAccount;
|
||||
/**
|
||||
* 微信账号信息
|
||||
*/
|
||||
private WeixinAccount weixinAccount;
|
||||
/**
|
||||
* Http参数
|
||||
*/
|
||||
private HttpParams httpParams;
|
||||
/**
|
||||
* token存储方式 默认为FileTokenStorager
|
||||
*/
|
||||
private TokenStorager tokenStorager;
|
||||
/**
|
||||
* 系统临时目录
|
||||
*/
|
||||
private String tmpdir;
|
||||
/**
|
||||
* 支付接口需要的证书文件(*.p12)
|
||||
*/
|
||||
private String certificateFile;
|
||||
|
||||
/**
|
||||
* 默认使用weixin4j.properties配置的信息
|
||||
*/
|
||||
public Weixin4jSettings() {
|
||||
this(JSON.parseObject(Weixin4jConfigUtil.getValue("account"), WeixinPayAccount.class), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付代理接口
|
||||
*
|
||||
* @param weixinPayAccount
|
||||
* 商户信息
|
||||
* @param certificateFile
|
||||
* 支付接口需要的证书文件(*.p12),比如退款接口
|
||||
*/
|
||||
public Weixin4jSettings(WeixinPayAccount weixinPayAccount, String certificateFile) {
|
||||
this(weixinPayAccount);
|
||||
this.certificateFile = certificateFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付代理接口
|
||||
*
|
||||
* @param weixinPayAccount
|
||||
* 商户信息
|
||||
*/
|
||||
public Weixin4jSettings(WeixinPayAccount weixinPayAccount) {
|
||||
this.weixinPayAccount = weixinPayAccount;
|
||||
this.weixinAccount = new WeixinAccount(weixinPayAccount.getId(), weixinPayAccount.getSecret());
|
||||
}
|
||||
|
||||
/**
|
||||
* 普通代理接口
|
||||
*
|
||||
* @param weixinAccount
|
||||
*/
|
||||
public Weixin4jSettings(WeixinAccount weixinAccount) {
|
||||
this.weixinAccount = weixinAccount;
|
||||
}
|
||||
|
||||
public WeixinPayAccount getWeixinPayAccount() {
|
||||
return weixinPayAccount;
|
||||
}
|
||||
|
||||
public WeixinAccount getWeixinAccount() {
|
||||
return weixinAccount;
|
||||
}
|
||||
|
||||
public HttpParams getHttpParams() {
|
||||
return httpParams;
|
||||
}
|
||||
|
||||
public HttpParams getHttpParams0() {
|
||||
if (httpParams == null) {
|
||||
return new HttpParams();
|
||||
}
|
||||
return httpParams;
|
||||
}
|
||||
|
||||
public String getTmpdir() {
|
||||
return tmpdir;
|
||||
}
|
||||
|
||||
public String getTmpdir0() {
|
||||
if (StringUtil.isBlank(tmpdir)) {
|
||||
return Weixin4jConfigUtil.getClassPathValue("weixin4j.tmpdir", System.getProperty("java.io.tmpdir"));
|
||||
}
|
||||
return tmpdir;
|
||||
}
|
||||
|
||||
public TokenStorager getTokenStorager() {
|
||||
return tokenStorager;
|
||||
}
|
||||
|
||||
public TokenStorager getTokenStorager0() {
|
||||
if (tokenStorager == null) {
|
||||
return new FileTokenStorager(getTmpdir0());
|
||||
}
|
||||
return tokenStorager;
|
||||
}
|
||||
|
||||
public String getCertificateFile() {
|
||||
return certificateFile;
|
||||
}
|
||||
|
||||
public String getCertificateFile0() {
|
||||
if (StringUtil.isBlank(certificateFile)) {
|
||||
return Weixin4jConfigUtil.getClassPathValue("weixin4j.certificate.file", "classpath:ca.p12");
|
||||
}
|
||||
return certificateFile;
|
||||
}
|
||||
|
||||
public void setHttpParams(HttpParams httpParams) {
|
||||
this.httpParams = httpParams;
|
||||
}
|
||||
|
||||
public void setTmpdir(String tmpdir) {
|
||||
this.tmpdir = tmpdir;
|
||||
}
|
||||
|
||||
public void setTokenStorager(TokenStorager tokenStorager) {
|
||||
this.tokenStorager = tokenStorager;
|
||||
}
|
||||
|
||||
public void setCertificateFile(String certificateFile) {
|
||||
this.certificateFile = certificateFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Weixin4jSettings [weixinAccount=" + weixinAccount + ", httpParams=" + httpParams + ",tokenStorager="
|
||||
+ tokenStorager + ", tmpdir=" + tmpdir + ", certificateFile= " + certificateFile + "]";
|
||||
}
|
||||
}
|
||||
@ -21,12 +21,12 @@ import com.foxinmy.weixin4j.payment.mch.Order;
|
||||
import com.foxinmy.weixin4j.payment.mch.PrePay;
|
||||
import com.foxinmy.weixin4j.payment.mch.RefundRecord;
|
||||
import com.foxinmy.weixin4j.payment.mch.RefundResult;
|
||||
import com.foxinmy.weixin4j.setting.Weixin4jSettings;
|
||||
import com.foxinmy.weixin4j.sign.WeixinPaymentSignature;
|
||||
import com.foxinmy.weixin4j.sign.WeixinSignature;
|
||||
import com.foxinmy.weixin4j.type.IdQuery;
|
||||
import com.foxinmy.weixin4j.type.IdType;
|
||||
import com.foxinmy.weixin4j.type.TradeType;
|
||||
import com.foxinmy.weixin4j.util.Weixin4jSettings;
|
||||
|
||||
/**
|
||||
* 支付测试(商户平台)
|
||||
|
||||
@ -50,6 +50,7 @@ import com.foxinmy.weixin4j.mp.token.WeixinTokenCreator;
|
||||
import com.foxinmy.weixin4j.mp.type.DatacubeType;
|
||||
import com.foxinmy.weixin4j.mp.type.IndustryType;
|
||||
import com.foxinmy.weixin4j.mp.type.Lang;
|
||||
import com.foxinmy.weixin4j.setting.Weixin4jSettings;
|
||||
import com.foxinmy.weixin4j.token.TokenHolder;
|
||||
import com.foxinmy.weixin4j.tuple.MassTuple;
|
||||
import com.foxinmy.weixin4j.tuple.MpArticle;
|
||||
@ -57,11 +58,10 @@ import com.foxinmy.weixin4j.tuple.MpVideo;
|
||||
import com.foxinmy.weixin4j.tuple.Tuple;
|
||||
import com.foxinmy.weixin4j.type.MediaType;
|
||||
import com.foxinmy.weixin4j.type.TicketType;
|
||||
import com.foxinmy.weixin4j.util.Weixin4jSettings;
|
||||
|
||||
/**
|
||||
* 微信公众平台接口实现
|
||||
*
|
||||
*
|
||||
* @className WeixinProxy
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2014年3月23日
|
||||
@ -135,21 +135,21 @@ public class WeixinProxy {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param settings
|
||||
* 微信配置信息
|
||||
* @see com.foxinmy.weixin4j.util.Weixin4jSettings
|
||||
* @see com.foxinmy.weixin4j.setting.Weixin4jSettings
|
||||
*/
|
||||
public WeixinProxy(Weixin4jSettings settings) {
|
||||
this(new TokenHolder(new WeixinTokenCreator(settings.getWeixinAccount()
|
||||
.getId(), settings.getWeixinAccount().getSecret()),
|
||||
this(new TokenHolder(new WeixinTokenCreator(settings.getAccount()
|
||||
.getId(), settings.getAccount().getSecret()),
|
||||
settings.getTokenStorager0()));
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注意:TokenCreator 需为 <font color="red">WeixinTokenCreator</font>
|
||||
*
|
||||
*
|
||||
* @see com.foxinmy.weixin4j.mp.token.WeixinTokenCreator
|
||||
* @param tokenHolder
|
||||
*/
|
||||
@ -171,16 +171,16 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 获取微信账号信息
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public WeixinAccount getWeixinAccount() {
|
||||
return this.settings.getWeixinAccount();
|
||||
return this.settings.getAccount();
|
||||
}
|
||||
|
||||
/**
|
||||
* token获取
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public TokenHolder getTokenHolder() {
|
||||
@ -189,7 +189,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 获取JSSDK Ticket的tokenHolder
|
||||
*
|
||||
*
|
||||
* @param ticketType
|
||||
* 票据类型
|
||||
* @return
|
||||
@ -203,7 +203,7 @@ public class WeixinProxy {
|
||||
/**
|
||||
* 上传图文消息内的图片获取URL
|
||||
* 请注意,本接口所上传的图片不占用公众号的素材库中图片数量的5000个的限制。图片仅支持jpg/png格式,大小必须在1MB以下。
|
||||
*
|
||||
*
|
||||
* @param is
|
||||
* 图片数据流
|
||||
* @param fileName
|
||||
@ -219,7 +219,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 上传群发中的视频素材
|
||||
*
|
||||
*
|
||||
* @param is
|
||||
* 图片数据流
|
||||
* @param fileName
|
||||
@ -244,7 +244,7 @@ public class WeixinProxy {
|
||||
/**
|
||||
* 上传媒体文件 </br> <font color="red">此接口只包含图片、语音、缩略图、视频(临时)四种媒体类型的上传</font>
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param isMaterial
|
||||
* 是否永久上传
|
||||
* @param is
|
||||
@ -270,7 +270,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 下载媒体文件
|
||||
*
|
||||
*
|
||||
* @param mediaId
|
||||
* 媒体ID
|
||||
* @param isMaterial
|
||||
@ -297,7 +297,7 @@ public class WeixinProxy {
|
||||
* 、新增的永久素材也可以在公众平台官网素材管理模块中看到,永久素材的数量是有上限的,请谨慎新增。图文消息素材和图片素材的上限为5000,
|
||||
* 其他类型为1000
|
||||
* </P>
|
||||
*
|
||||
*
|
||||
* @param articles
|
||||
* 图文列表
|
||||
* @return 上传到微信服务器返回的媒体标识
|
||||
@ -315,7 +315,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 下载永久图文素材
|
||||
*
|
||||
*
|
||||
* @param mediaId
|
||||
* 媒体ID
|
||||
* @return 图文列表
|
||||
@ -331,7 +331,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 更新永久图文素材
|
||||
*
|
||||
*
|
||||
* @param mediaId
|
||||
* 要修改的图文消息的id
|
||||
* @param index
|
||||
@ -353,7 +353,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 删除永久媒体素材
|
||||
*
|
||||
*
|
||||
* @param mediaId
|
||||
* 媒体素材的media_id
|
||||
* @return 处理结果
|
||||
@ -370,7 +370,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 上传永久视频素材
|
||||
*
|
||||
*
|
||||
* @param is
|
||||
* 大小不超过1M且格式为MP4的视频文件
|
||||
* @param fileName
|
||||
@ -393,7 +393,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 获取永久媒体素材的总数</br> .图片和图文消息素材(包括单图文和多图文)的总数上限为5000,其他素材的总数上限为1000
|
||||
*
|
||||
*
|
||||
* @return 总数对象
|
||||
* @throws WeixinException
|
||||
* @see com.foxinmy.weixin4j.mp.model.MediaCounter
|
||||
@ -408,7 +408,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 获取媒体素材记录列表
|
||||
*
|
||||
*
|
||||
* @param mediaType
|
||||
* 素材的类型,图片(image)、视频(video)、语音 (voice)、图文(news)
|
||||
* @param pageable
|
||||
@ -432,7 +432,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 获取全部的媒体素材
|
||||
*
|
||||
*
|
||||
* @param mediaType
|
||||
* 媒体类型
|
||||
* @return 素材列表
|
||||
@ -447,7 +447,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 发送客服消息(在48小时内不限制发送次数)
|
||||
*
|
||||
*
|
||||
* @param notify
|
||||
* 客服消息对象
|
||||
* @return 处理结果
|
||||
@ -460,7 +460,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 发送客服消息(在48小时内不限制发送次数)
|
||||
*
|
||||
*
|
||||
* @param notify
|
||||
* 客服消息对象
|
||||
* @param kfAccount
|
||||
@ -485,7 +485,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 客服聊天记录
|
||||
*
|
||||
*
|
||||
* @param startTime
|
||||
* 查询开始时间
|
||||
* @param endTime
|
||||
@ -507,7 +507,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 获取公众号中所设置的客服基本信息,包括客服工号、客服昵称、客服登录账号
|
||||
*
|
||||
*
|
||||
* @param isOnline
|
||||
* 是否在线 为ture时可以可以获取客服在线状态(手机在线、PC客户端在线、手机和PC客户端全都在线)、客服自动接入最大值、
|
||||
* 客服当前接待客户数
|
||||
@ -529,7 +529,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 新增客服账号
|
||||
*
|
||||
*
|
||||
* @param id
|
||||
* 完整客服账号,格式为:账号前缀@公众号微信号,账号前缀最多10个字符,必须是英文或者数字字符。如果没有公众号微信号,
|
||||
* 请前往微信公众平台设置。
|
||||
@ -551,7 +551,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 更新客服账号
|
||||
*
|
||||
*
|
||||
* @param id
|
||||
* 完整客服账号,格式为:账号前缀@公众号微信号,账号前缀最多10个字符,必须是英文或者数字字符。如果没有公众号微信号,
|
||||
* 请前往微信公众平台设置。
|
||||
@ -575,7 +575,7 @@ public class WeixinProxy {
|
||||
* 邀请绑定客服帐号
|
||||
* 新添加的客服帐号是不能直接使用的,只有客服人员用微信号绑定了客服账号后,方可登录Web客服进行操作。此接口发起一个绑定邀请到客服人员微信号
|
||||
* ,客服人员需要在微信客户端上用该微信号确认后帐号才可用。尚未绑定微信号的帐号可以进行绑定邀请操作,邀请未失效时不能对该帐号进行再次绑定微信号邀请。
|
||||
*
|
||||
*
|
||||
* @param kfAccount
|
||||
* 完整客服帐号,格式为:帐号前缀@公众号微信号
|
||||
* @param inviteAccount
|
||||
@ -594,7 +594,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 上传客服头像
|
||||
*
|
||||
*
|
||||
* @param accountId
|
||||
* 完整客服账号,格式为:账号前缀@公众号微信号
|
||||
* @param is
|
||||
@ -615,7 +615,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 删除客服账号
|
||||
*
|
||||
*
|
||||
* @param id
|
||||
* 完整客服账号,格式为:账号前缀@公众号微信号
|
||||
* @return 处理结果
|
||||
@ -635,7 +635,7 @@ public class WeixinProxy {
|
||||
* 开发者可以使用本接口,为多客服的客服工号创建会话,将某个客户直接指定给客服工号接待,需要注意此接口不会受客服自动接入数以及自动接入开关限制。
|
||||
* 只能为在线的客服(PC客户端在线,或者已绑定多客服助手)创建会话。
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param userOpenId
|
||||
* 用户的userOpenId
|
||||
* @param kfAccount
|
||||
@ -656,7 +656,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 关闭客服会话
|
||||
*
|
||||
*
|
||||
* @param userOpenId
|
||||
* 用户的userOpenId
|
||||
* @param kfAccount
|
||||
@ -677,7 +677,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 获取客户的会话状态:获取客户当前的会话状态。
|
||||
*
|
||||
*
|
||||
* @param userOpenId
|
||||
* 用户的openid
|
||||
* @return 会话对象
|
||||
@ -694,7 +694,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 获取客服的会话列表:获取某个客服正在接待的会话列表。
|
||||
*
|
||||
*
|
||||
* @param kfAccount
|
||||
* 完整客服账号,格式为:账号前缀@公众号微信号,账号前缀最多10个字符,必须是英文或者数字字符。
|
||||
* @return 会话列表
|
||||
@ -712,7 +712,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 获取未接入会话列表:获取当前正在等待队列中的会话列表,此接口最多返回最早进入队列的100个未接入会话
|
||||
*
|
||||
*
|
||||
* @return 会话列表
|
||||
* @throws WeixinException
|
||||
* @see com.foxinmy.weixin4j.mp.api.CustomApi
|
||||
@ -728,7 +728,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 上传群发的图文消息,一个图文消息支持1到10条图文
|
||||
*
|
||||
*
|
||||
* @param articles
|
||||
* 图片消息
|
||||
* @return 媒体ID
|
||||
@ -750,7 +750,7 @@ public class WeixinProxy {
|
||||
* 在返回成功时,意味着群发任务提交成功,并不意味着此时群发已经结束,所以,仍有可能在后续的发送过程中出现异常情况导致用户未收到消息,
|
||||
* 如消息有时会进行审核、服务器不稳定等,此外,群发任务一般需要较长的时间才能全部发送完毕
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param MassTuple
|
||||
* 消息元件
|
||||
* @param isToAll
|
||||
@ -780,7 +780,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 分组ID群发图文消息
|
||||
*
|
||||
*
|
||||
* @param articles
|
||||
* 图文列表
|
||||
* @param groupId
|
||||
@ -800,12 +800,12 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* openId群发
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* 在返回成功时,意味着群发任务提交成功,并不意味着此时群发已经结束,所以,仍有可能在后续的发送过程中出现异常情况导致用户未收到消息,
|
||||
* 如消息有时会进行审核、服务器不稳定等,此外,群发任务一般需要较长的时间才能全部发送完毕
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param tuple
|
||||
* 消息元件
|
||||
* @param openIds
|
||||
@ -832,7 +832,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 根据openid群发图文消息
|
||||
*
|
||||
*
|
||||
* @param articles
|
||||
* 图文列表
|
||||
* @param openIds
|
||||
@ -855,7 +855,7 @@ public class WeixinProxy {
|
||||
* <p>
|
||||
* 请注意,只有已经发送成功的消息才能删除删除消息只是将消息的图文详情页失效,已经收到的用户,还是能在其本地看到消息卡片
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param msgid
|
||||
* 发送出去的消息ID
|
||||
* @throws WeixinException
|
||||
@ -865,7 +865,7 @@ public class WeixinProxy {
|
||||
* @see com.foxinmy.weixin4j.mp.api.MassApi
|
||||
* @see {@link #massByGroupId(Tuple, int)}
|
||||
* @see {@link #massByOpenIds(Tuple, String...)
|
||||
*
|
||||
*
|
||||
*/
|
||||
public JsonResult deleteMassNews(String msgid) throws WeixinException {
|
||||
return massApi.deleteMassNews(msgid);
|
||||
@ -873,7 +873,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 预览群发消息</br> 开发者可通过该接口发送消息给指定用户,在手机端查看消息的样式和排版
|
||||
*
|
||||
*
|
||||
* @param toUser
|
||||
* 接收用户的openID
|
||||
* @param toWxName
|
||||
@ -895,7 +895,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 查询群发发送状态
|
||||
*
|
||||
*
|
||||
* @param msgId
|
||||
* 消息ID
|
||||
* @return 消息发送状态
|
||||
@ -911,7 +911,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*
|
||||
*
|
||||
* @param openId
|
||||
* 用户对应的ID
|
||||
* @return 用户对象
|
||||
@ -933,7 +933,7 @@ public class WeixinProxy {
|
||||
* 在关注者与公众号产生消息交互后,公众号可获得关注者的OpenID(加密后的微信号,每个用户对每个公众号的OpenID是唯一的,对于不同公众号,
|
||||
* 同一用户的openid不同),公众号可通过本接口来根据OpenID获取用户基本信息,包括昵称、头像、性别、所在城市、语言和关注时间
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param openId
|
||||
* 用户对应的ID
|
||||
* @param lang
|
||||
@ -953,7 +953,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 批量获取用户信息
|
||||
*
|
||||
*
|
||||
* @param openIds
|
||||
* 用户ID
|
||||
* @return 用户列表
|
||||
@ -971,7 +971,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 批量获取用户信息
|
||||
*
|
||||
*
|
||||
* @param lang
|
||||
* 国家地区语言版本
|
||||
* @param openIds
|
||||
@ -992,7 +992,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 获取公众号一定数量(10000)的关注者列表 <font corlor="red">请慎重使用</font>
|
||||
*
|
||||
*
|
||||
* @param nextOpenId
|
||||
* 下一次拉取数据的openid 不填写则默认从头开始拉取
|
||||
* @return 关注者信息 <font color="red">包含用户的详细信息</font>
|
||||
@ -1013,7 +1013,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 获取公众号一定数量(10000)的关注者列表
|
||||
*
|
||||
*
|
||||
* @param nextOpenId
|
||||
* 下一次拉取数据的openid 不填写则默认从头开始拉取
|
||||
* @return 关注者信息 <font color="red">不包含用户的详细信息</font>
|
||||
@ -1035,7 +1035,7 @@ public class WeixinProxy {
|
||||
* 当公众号关注者数量超过10000时,可通过填写next_openid的值,从而多次拉取列表的方式来满足需求,
|
||||
* 将上一次调用得到的返回中的next_openid值,作为下一次调用中的next_openid值
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @return 用户对象集合
|
||||
* @throws WeixinException
|
||||
* @see <a href=
|
||||
@ -1059,7 +1059,7 @@ public class WeixinProxy {
|
||||
* 当公众号关注者数量超过10000时,可通过填写next_openid的值,从而多次拉取列表的方式来满足需求,
|
||||
* 将上一次调用得到的返回中的next_openid值,作为下一次调用中的next_openid值
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @return 用户openid集合
|
||||
* @throws WeixinException
|
||||
* @see <a href=
|
||||
@ -1074,7 +1074,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 设置用户备注名
|
||||
*
|
||||
*
|
||||
* @param openId
|
||||
* 用户ID
|
||||
* @param remark
|
||||
@ -1092,7 +1092,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 创建分组
|
||||
*
|
||||
*
|
||||
* @param name
|
||||
* 组名称
|
||||
* @return group对象
|
||||
@ -1110,7 +1110,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 查询所有分组
|
||||
*
|
||||
*
|
||||
* @return 组集合
|
||||
* @throws WeixinException
|
||||
* @see <a href=
|
||||
@ -1125,7 +1125,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 查询用户所在分组
|
||||
*
|
||||
*
|
||||
* @param openId
|
||||
* 用户对应的ID
|
||||
* @return 组ID
|
||||
@ -1142,7 +1142,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 修改分组名
|
||||
*
|
||||
*
|
||||
* @param groupId
|
||||
* 组ID
|
||||
* @param name
|
||||
@ -1161,7 +1161,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 移动用户到分组
|
||||
*
|
||||
*
|
||||
* @param groupId
|
||||
* 组ID
|
||||
* @param openId
|
||||
@ -1180,7 +1180,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 批量移动分组
|
||||
*
|
||||
*
|
||||
* @param groupId
|
||||
* 组ID
|
||||
* @param openIds
|
||||
@ -1199,7 +1199,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 删除用户分组,所有该分组内的用户自动进入默认分组.
|
||||
*
|
||||
*
|
||||
* @param groupId
|
||||
* 组ID
|
||||
* @throws WeixinException
|
||||
@ -1215,7 +1215,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 自定义菜单
|
||||
*
|
||||
*
|
||||
* @param buttons
|
||||
* 菜单列表
|
||||
* @throws WeixinException
|
||||
@ -1232,7 +1232,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 查询菜单
|
||||
*
|
||||
*
|
||||
* @return 菜单集合
|
||||
* @throws WeixinException
|
||||
* @see <a href=
|
||||
@ -1247,7 +1247,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 查询全部菜单(包含个性化菜单)
|
||||
*
|
||||
*
|
||||
* @return 菜单集合
|
||||
* @throws WeixinException
|
||||
* @see <a href=
|
||||
@ -1266,7 +1266,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 删除菜单
|
||||
*
|
||||
*
|
||||
* @throws WeixinException
|
||||
* @see <a href=
|
||||
* "https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141015&token=&lang=zh_CN">
|
||||
@ -1280,7 +1280,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 创建个性化菜单
|
||||
*
|
||||
*
|
||||
* @param buttons
|
||||
* 菜单列表
|
||||
* @param matchRule
|
||||
@ -1300,7 +1300,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 删除个性化菜单
|
||||
*
|
||||
*
|
||||
* @throws WeixinException
|
||||
* @see <a href=
|
||||
* "https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1455782296&token=&lang=zh_CN">
|
||||
@ -1314,7 +1314,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 测试个性化菜单匹配结果
|
||||
*
|
||||
*
|
||||
* @param userId
|
||||
* 可以是粉丝的OpenID,也可以是粉丝的微信号。
|
||||
* @see <a href=
|
||||
@ -1331,7 +1331,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 生成带参数的二维码
|
||||
*
|
||||
*
|
||||
* @param parameter
|
||||
* 二维码参数
|
||||
* @return 二维码结果对象
|
||||
@ -1349,7 +1349,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 设置所属行业(每月可修改行业1次,账号仅可使用所属行业中相关的模板)
|
||||
*
|
||||
*
|
||||
* @param industryTypes
|
||||
* 所处行业 目前不超过两个
|
||||
* @return 操作结果
|
||||
@ -1367,7 +1367,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 获取模板ID
|
||||
*
|
||||
*
|
||||
* @param shortId
|
||||
* 模板库中模板的编号,有“TM**”和“OPENTMTM**”等形式
|
||||
* @return 模板ID
|
||||
@ -1383,7 +1383,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 获取模板列表
|
||||
*
|
||||
*
|
||||
* @return 模板列表
|
||||
* @see com.foxinmy.weixin4j.mp.model.TemplateMessageInfo
|
||||
* @see <a href=
|
||||
@ -1398,7 +1398,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 删除模板
|
||||
*
|
||||
*
|
||||
* @param templateId
|
||||
* 公众帐号下模板消息ID
|
||||
* @return 处理结果
|
||||
@ -1414,7 +1414,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 发送模板消息
|
||||
*
|
||||
*
|
||||
* @param tplMessage
|
||||
* 模板消息主体
|
||||
* @return 发送结果
|
||||
@ -1436,7 +1436,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 长链接转短链接
|
||||
*
|
||||
*
|
||||
* @param url
|
||||
* 待转换的链接
|
||||
* @return 短链接
|
||||
@ -1452,7 +1452,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 语义理解
|
||||
*
|
||||
*
|
||||
* @param semQuery
|
||||
* 语义理解协议
|
||||
* @return 语义理解结果
|
||||
@ -1470,7 +1470,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 获取微信服务器IP地址
|
||||
*
|
||||
*
|
||||
* @return IP地址
|
||||
* @see <a href=
|
||||
* "https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140187&token=&lang=zh_CN">
|
||||
@ -1485,7 +1485,7 @@ public class WeixinProxy {
|
||||
/**
|
||||
* 获取公众号当前使用的自定义菜单的配置,如果公众号是通过API调用设置的菜单,则返回菜单的开发配置,
|
||||
* 而如果公众号是在公众平台官网通过网站功能发布菜单,则本接口返回运营者设置的菜单配置。
|
||||
*
|
||||
*
|
||||
* @return 菜单集合
|
||||
* @see {@link #getMenu()}
|
||||
* @see <a href=
|
||||
@ -1503,7 +1503,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 获取公众号当前使用的自动回复规则,包括关注后自动回复、消息自动回复(60分钟内触发一次)、关键词自动回复。
|
||||
*
|
||||
*
|
||||
* @see com.foxinmy.weixin4j.mp.model.AutoReplySetting
|
||||
* @see com.foxinmy.weixin4j.mp.api.HelperApi
|
||||
* @see <a href=
|
||||
@ -1517,7 +1517,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 数据统计
|
||||
*
|
||||
*
|
||||
* @param datacubeType
|
||||
* 数据统计类型
|
||||
* @param beginDate
|
||||
@ -1555,7 +1555,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 数据统计
|
||||
*
|
||||
*
|
||||
* @param datacubeType
|
||||
* 统计类型
|
||||
* @param beginDate
|
||||
@ -1573,7 +1573,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 数据统计
|
||||
*
|
||||
*
|
||||
* @param datacubeType
|
||||
* 统计类型
|
||||
* @param offset
|
||||
@ -1591,7 +1591,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 查询日期跨度为0的统计数据(当天)
|
||||
*
|
||||
*
|
||||
* @param datacubeType
|
||||
* 统计类型
|
||||
* @param date
|
||||
@ -1607,7 +1607,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 创建标签
|
||||
*
|
||||
*
|
||||
* @param name
|
||||
* 标签名(30个字符以内)
|
||||
* @return 标签对象
|
||||
@ -1623,7 +1623,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 获取标签
|
||||
*
|
||||
*
|
||||
* @return 标签列表
|
||||
* @throws WeixinException
|
||||
* @see com.foxinmy.weixin4j.mp.api.TagApi
|
||||
@ -1637,7 +1637,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 更新标签
|
||||
*
|
||||
*
|
||||
* @param tag
|
||||
* 标签对象
|
||||
* @return 操作结果
|
||||
@ -1653,7 +1653,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 删除标签
|
||||
*
|
||||
*
|
||||
* @param tagId
|
||||
* 标签id
|
||||
* @return 操作结果
|
||||
@ -1668,7 +1668,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 批量为用户打标签:标签功能目前支持公众号为用户打上最多三个标签
|
||||
*
|
||||
*
|
||||
* @param tagId
|
||||
* 标签ID
|
||||
* @param openIds
|
||||
@ -1686,7 +1686,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 批量为用户取消标签
|
||||
*
|
||||
*
|
||||
* @param tagId
|
||||
* 标签ID
|
||||
* @param openIds
|
||||
@ -1704,7 +1704,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 获取标签下粉丝列表
|
||||
*
|
||||
*
|
||||
* @param tagId
|
||||
* 标签ID
|
||||
* @param nextOpenId
|
||||
@ -1722,7 +1722,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 获取标签下粉丝列表 <font corlor="red">请慎重使用</font>
|
||||
*
|
||||
*
|
||||
* @param tagId
|
||||
* 标签ID
|
||||
* @param nextOpenId
|
||||
@ -1740,7 +1740,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 获取标签下全部的粉丝列表 <font corlor="red">请慎重使用</font>
|
||||
*
|
||||
*
|
||||
* @param tagId
|
||||
* 标签ID
|
||||
* @return 用户openid列表
|
||||
@ -1757,7 +1757,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 获取标签下全部的粉丝列表 <font corlor="red">请慎重使用</font>
|
||||
*
|
||||
*
|
||||
* @param tagId
|
||||
* 标签ID
|
||||
* @return 被打标签者信息 <font color="red">包含用户的详细信息</font>
|
||||
@ -1773,7 +1773,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 获取用户身上的标签列表
|
||||
*
|
||||
*
|
||||
* @param openId
|
||||
* 用户ID
|
||||
* @return 标签ID集合
|
||||
|
||||
@ -47,7 +47,7 @@ import com.foxinmy.weixin4j.util.StringUtil;
|
||||
|
||||
/**
|
||||
* 素材相关API
|
||||
*
|
||||
*
|
||||
* @className MediaApi
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2014年9月25日
|
||||
@ -64,7 +64,7 @@ public class MediaApi extends MpApi {
|
||||
/**
|
||||
* 上传图片获取URL
|
||||
* 请注意,本接口所上传的图片不占用公众号的素材库中图片数量的5000个的限制。图片仅支持jpg/png格式,大小必须在1MB以下。
|
||||
*
|
||||
*
|
||||
* @param is
|
||||
* 图片数据流
|
||||
* @param fileName
|
||||
@ -91,7 +91,7 @@ public class MediaApi extends MpApi {
|
||||
|
||||
/**
|
||||
* 上传群发中的视频素材
|
||||
*
|
||||
*
|
||||
* @param is
|
||||
* 图片数据流
|
||||
* @param fileName
|
||||
@ -130,7 +130,7 @@ public class MediaApi extends MpApi {
|
||||
* 正常情况下返回{"type":"TYPE","media_id":"MEDIA_ID","created_at":123456789},
|
||||
* 否则抛出异常.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param isMaterial
|
||||
* 是否永久上传
|
||||
* @param is
|
||||
@ -222,13 +222,13 @@ public class MediaApi extends MpApi {
|
||||
|
||||
/**
|
||||
* 下载媒体素材
|
||||
*
|
||||
*
|
||||
* @param mediaId
|
||||
* 媒体ID
|
||||
* @param isMaterial
|
||||
* 是否下载永久素材
|
||||
* @return 媒体下载结果
|
||||
*
|
||||
*
|
||||
* @throws WeixinException
|
||||
* @see com.foxinmy.weixin4j.model.MediaDownloadResult
|
||||
* @see <a
|
||||
@ -299,7 +299,7 @@ public class MediaApi extends MpApi {
|
||||
* 、新增的永久素材也可以在公众平台官网素材管理模块中看到,永久素材的数量是有上限的,请谨慎新增。图文消息素材和图片素材的上限为5000,
|
||||
* 其他类型为1000
|
||||
* </P>
|
||||
*
|
||||
*
|
||||
* @param articles
|
||||
* 图文列表
|
||||
* @return 上传到微信服务器返回的媒体标识
|
||||
@ -323,7 +323,7 @@ public class MediaApi extends MpApi {
|
||||
|
||||
/**
|
||||
* 下载永久图文素材
|
||||
*
|
||||
*
|
||||
* @param mediaId
|
||||
* 媒体ID
|
||||
* @return 图文列表
|
||||
@ -342,7 +342,7 @@ public class MediaApi extends MpApi {
|
||||
|
||||
/**
|
||||
* 更新永久图文素材
|
||||
*
|
||||
*
|
||||
* @param mediaId
|
||||
* 要修改的图文消息的id
|
||||
* @param index
|
||||
@ -372,7 +372,7 @@ public class MediaApi extends MpApi {
|
||||
|
||||
/**
|
||||
* 删除永久媒体素材
|
||||
*
|
||||
*
|
||||
* @param mediaId
|
||||
* 媒体素材的media_id
|
||||
* @return 处理结果
|
||||
@ -395,7 +395,7 @@ public class MediaApi extends MpApi {
|
||||
|
||||
/**
|
||||
* 上传永久视频素材
|
||||
*
|
||||
*
|
||||
* @param is
|
||||
* 大小不超过1M且格式为MP4的视频文件
|
||||
* @param fileName
|
||||
@ -446,7 +446,7 @@ public class MediaApi extends MpApi {
|
||||
|
||||
/**
|
||||
* 获取永久媒体素材的总数</br> .图片和图文消息素材(包括单图文和多图文)的总数上限为5000,其他素材的总数上限为1000
|
||||
*
|
||||
*
|
||||
* @return 总数对象
|
||||
* @throws WeixinException
|
||||
* @see com.foxinmy.weixin4j.model.MediaCounter
|
||||
@ -465,7 +465,7 @@ public class MediaApi extends MpApi {
|
||||
|
||||
/**
|
||||
* 获取媒体素材记录列表
|
||||
*
|
||||
*
|
||||
* @param mediaType
|
||||
* 素材的类型,图片(image)、视频(video)、语音 (voice)、图文(news)
|
||||
* @param pageable
|
||||
@ -518,7 +518,7 @@ public class MediaApi extends MpApi {
|
||||
|
||||
/**
|
||||
* 获取全部的媒体素材
|
||||
*
|
||||
*
|
||||
* @param mediaType
|
||||
* 媒体类型
|
||||
* @return 素材列表
|
||||
|
||||
@ -6,12 +6,12 @@ import org.junit.Test;
|
||||
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.mp.token.WeixinTokenCreator;
|
||||
import com.foxinmy.weixin4j.setting.Weixin4jSettings;
|
||||
import com.foxinmy.weixin4j.token.TokenHolder;
|
||||
import com.foxinmy.weixin4j.util.Weixin4jSettings;
|
||||
|
||||
/**
|
||||
* token测试
|
||||
*
|
||||
*
|
||||
* @className TokenTest
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2014年4月10日
|
||||
@ -26,7 +26,7 @@ public class TokenTest {
|
||||
public void setUp() {
|
||||
this.settings = new Weixin4jSettings();
|
||||
tokenHolder = new TokenHolder(new WeixinTokenCreator(settings
|
||||
.getWeixinAccount().getId(), settings.getWeixinAccount()
|
||||
.getAccount().getId(), settings.getAccount()
|
||||
.getSecret()), settings.getTokenStorager0());
|
||||
}
|
||||
|
||||
|
||||
@ -46,15 +46,15 @@ import com.foxinmy.weixin4j.qy.type.ChatType;
|
||||
import com.foxinmy.weixin4j.qy.type.InviteType;
|
||||
import com.foxinmy.weixin4j.qy.type.KfType;
|
||||
import com.foxinmy.weixin4j.qy.type.UserStatus;
|
||||
import com.foxinmy.weixin4j.setting.Weixin4jSettings;
|
||||
import com.foxinmy.weixin4j.token.TokenHolder;
|
||||
import com.foxinmy.weixin4j.tuple.MpArticle;
|
||||
import com.foxinmy.weixin4j.type.MediaType;
|
||||
import com.foxinmy.weixin4j.type.TicketType;
|
||||
import com.foxinmy.weixin4j.util.Weixin4jSettings;
|
||||
|
||||
/**
|
||||
* 微信企业号接口实现
|
||||
*
|
||||
*
|
||||
* @className WeixinProxy
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2014年11月19日
|
||||
@ -120,21 +120,21 @@ public class WeixinProxy {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param settings
|
||||
* 微信配置信息
|
||||
* @see com.foxinmy.weixin4j.util.Weixin4jSettings
|
||||
* @see com.foxinmy.weixin4j.setting.Weixin4jSettings
|
||||
*/
|
||||
public WeixinProxy(Weixin4jSettings settings) {
|
||||
this(new TokenHolder(
|
||||
new WeixinTokenCreator(settings.getWeixinAccount().getId(), settings.getWeixinAccount().getSecret()),
|
||||
this(new TokenHolder(new WeixinTokenCreator(settings.getAccount()
|
||||
.getId(), settings.getAccount().getSecret()),
|
||||
settings.getTokenStorager0()));
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* 第三方套件(永久授权码机制)
|
||||
*
|
||||
*
|
||||
* @param perCodeHolder
|
||||
* 第三方套件永久授权码
|
||||
* {@link com.foxinmy.weixin4j.qy.api.SuiteApi#getPerCodeHolder(String)}
|
||||
@ -144,16 +144,18 @@ public class WeixinProxy {
|
||||
* @see com.foxinmy.weixin4j.qy.api.SuiteApi
|
||||
* @see WeixinSuiteProxy#getWeixinProxy(String, String)
|
||||
*/
|
||||
public WeixinProxy(SuitePerCodeHolder perCodeHolder, TokenHolder suiteTokenHolder) {
|
||||
this(new TokenHolder(new WeixinTokenSuiteCreator(perCodeHolder, suiteTokenHolder),
|
||||
perCodeHolder.getTokenStorager()));
|
||||
this.settings = new Weixin4jSettings(new WeixinAccount(perCodeHolder.getAuthCorpId(), null));
|
||||
public WeixinProxy(SuitePerCodeHolder perCodeHolder,
|
||||
TokenHolder suiteTokenHolder) {
|
||||
this(new TokenHolder(new WeixinTokenSuiteCreator(perCodeHolder,
|
||||
suiteTokenHolder), perCodeHolder.getTokenStorager()));
|
||||
this.settings = new Weixin4jSettings(new WeixinAccount(
|
||||
perCodeHolder.getAuthCorpId(), null));
|
||||
}
|
||||
|
||||
/**
|
||||
* 注意:TokenCreator 需为
|
||||
* <font color="red">WeixinTokenCreator或WeixinTokenSuiteCreator</font>
|
||||
*
|
||||
* 注意:TokenCreator 需为 <font
|
||||
* color="red">WeixinTokenCreator或WeixinTokenSuiteCreator</font>
|
||||
*
|
||||
* @see com.foxinmy.weixin4j.qy.token.WeixinTokenCreator
|
||||
* @param tokenHolder
|
||||
*/
|
||||
@ -173,7 +175,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* token获取
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public TokenHolder getTokenHolder() {
|
||||
@ -182,22 +184,23 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 获取微信账号信息
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public WeixinAccount getWeixinAccount() {
|
||||
return this.settings.getWeixinAccount();
|
||||
return this.settings.getAccount();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取JSSDK Ticket的tokenHolder
|
||||
*
|
||||
*
|
||||
* @param ticketType
|
||||
* 票据类型
|
||||
* @return
|
||||
*/
|
||||
public TokenHolder getTicketHolder(TicketType ticketType) {
|
||||
return new TokenHolder(new WeixinTicketCreator(getWeixinAccount().getId(), ticketType, this.tokenHolder),
|
||||
return new TokenHolder(new WeixinTicketCreator(getWeixinAccount()
|
||||
.getId(), ticketType, this.tokenHolder),
|
||||
this.settings.getTokenStorager0());
|
||||
}
|
||||
|
||||
@ -208,12 +211,11 @@ public class WeixinProxy {
|
||||
* 2)发送人员不在通讯录权限范围内:不执行发送任务,返回首个出错的userid</br>
|
||||
* 3)发送人员不在应用可见范围内:不执行发送任务,返回首个出错的userid</br>
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param message
|
||||
* 客服消息对象
|
||||
* @return 如果对应用或收件人、部门、标签任何一个无权限,则本次发送失败;如果收件人、部门或标签不存在,发送仍然执行,但返回无效的部分
|
||||
* </br>
|
||||
* { "errcode": 0, "errmsg": "ok", "invaliduser": "UserID1",
|
||||
* </br> { "errcode": 0, "errmsg": "ok", "invaliduser": "UserID1",
|
||||
* "invalidparty":"PartyID1", "invalidtag":"TagID1" }
|
||||
* @throws WeixinException
|
||||
* @see com.foxinmy.weixin4j.qy.api.NotifyApi
|
||||
@ -232,13 +234,14 @@ public class WeixinProxy {
|
||||
* @see com.foxinmy.weixin4j.tuple.MpNews
|
||||
* @see com.foxinmy.weixin4j.qy.model.IdParameter
|
||||
*/
|
||||
public IdParameter sendNotifyMessage(NotifyMessage message) throws WeixinException {
|
||||
public IdParameter sendNotifyMessage(NotifyMessage message)
|
||||
throws WeixinException {
|
||||
return notifyApi.sendNotifyMessage(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送客服消息
|
||||
*
|
||||
*
|
||||
* @param message
|
||||
* 客服消息对象
|
||||
* @return 发送结果
|
||||
@ -254,13 +257,14 @@ public class WeixinProxy {
|
||||
* @see com.foxinmy.weixin4j.qy.message.CustomeMessage
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public JsonResult sendCustomeMessage(CustomeMessage message) throws WeixinException {
|
||||
public JsonResult sendCustomeMessage(CustomeMessage message)
|
||||
throws WeixinException {
|
||||
return notifyApi.sendCustomeMessage(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取客服列表
|
||||
*
|
||||
*
|
||||
* @param kfType
|
||||
* 客服类型 为空时返回全部类型的客服
|
||||
* @return 第一个元素为内部客服(internal),第二个参数为外部客服(external)
|
||||
@ -277,10 +281,10 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 自定义菜单(管理员须拥有应用的管理权限 并且应用必须设置在回调模式)
|
||||
*
|
||||
*
|
||||
* @param agentid
|
||||
* 应用ID
|
||||
*
|
||||
*
|
||||
* @param buttons
|
||||
* 菜单列表
|
||||
* @throws WeixinException
|
||||
@ -290,13 +294,14 @@ public class WeixinProxy {
|
||||
* 创建自定义菜单</a>
|
||||
* @see com.foxinmy.weixin4j.model.Button
|
||||
*/
|
||||
public JsonResult createMenu(int agentid, List<Button> buttons) throws WeixinException {
|
||||
public JsonResult createMenu(int agentid, List<Button> buttons)
|
||||
throws WeixinException {
|
||||
return menuApi.createMenu(agentid, buttons);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询菜单(管理员须拥有应用的管理权限 并且应用必须设置在回调模式。)
|
||||
*
|
||||
*
|
||||
* @param agentid
|
||||
* 应用ID
|
||||
* @return 菜单集合
|
||||
@ -313,7 +318,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 删除菜单(管理员须拥有应用的管理权限 并且应用必须设置在回调模式)
|
||||
*
|
||||
*
|
||||
* @param agentid
|
||||
* 应用ID
|
||||
* @throws WeixinException
|
||||
@ -330,7 +335,7 @@ public class WeixinProxy {
|
||||
/**
|
||||
* 上传图文消息内的图片:用于上传图片到企业号服务端,接口返回图片url,请注意,该url仅可用于图文消息的发送,
|
||||
* 且每个企业每天最多只能上传100张图片。
|
||||
*
|
||||
*
|
||||
* @param is
|
||||
* 图片数据
|
||||
* @param fileName
|
||||
@ -342,7 +347,8 @@ public class WeixinProxy {
|
||||
* @see com.foxinmy.weixin4j.qy.api.MediaApi
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public String uploadImage(InputStream is, String fileName) throws WeixinException {
|
||||
public String uploadImage(InputStream is, String fileName)
|
||||
throws WeixinException {
|
||||
return mediaApi.uploadImage(is, fileName);
|
||||
}
|
||||
|
||||
@ -352,7 +358,7 @@ public class WeixinProxy {
|
||||
* 正常情况下返回{"type":"TYPE","media_id":"MEDIA_ID","created_at":123456789},
|
||||
* 否则抛出异常.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param agentid
|
||||
* 企业应用ID(<font color="red">大于0时视为上传永久媒体文件</font>)
|
||||
* @param is
|
||||
@ -370,13 +376,14 @@ public class WeixinProxy {
|
||||
* 上传永久素材文件说明</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public MediaUploadResult uploadMedia(int agentid, InputStream is, String fileName) throws WeixinException {
|
||||
public MediaUploadResult uploadMedia(int agentid, InputStream is,
|
||||
String fileName) throws WeixinException {
|
||||
return mediaApi.uploadMedia(agentid, is, fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载媒体文件
|
||||
*
|
||||
*
|
||||
* @param agentid
|
||||
* 企业应用Id(<font color="red">大于0时视为获取永久媒体文件</font>)
|
||||
* @param mediaId
|
||||
@ -392,7 +399,8 @@ public class WeixinProxy {
|
||||
* 获取永久媒体说明</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public MediaDownloadResult downloadMedia(int agentid, String mediaId) throws WeixinException {
|
||||
public MediaDownloadResult downloadMedia(int agentid, String mediaId)
|
||||
throws WeixinException {
|
||||
return mediaApi.downloadMedia(agentid, mediaId);
|
||||
}
|
||||
|
||||
@ -402,7 +410,7 @@ public class WeixinProxy {
|
||||
* 、新增的永久素材也可以在公众平台官网素材管理模块中看到,永久素材的数量是有上限的,请谨慎新增。图文消息素材和图片素材的上限为5000,
|
||||
* 其他类型为1000
|
||||
* </P>
|
||||
*
|
||||
*
|
||||
* @param agentid
|
||||
* 企业应用的id
|
||||
* @param articles
|
||||
@ -415,13 +423,14 @@ public class WeixinProxy {
|
||||
* 上传永久媒体素材</a>
|
||||
* @see com.foxinmy.weixin4j.tuple.MpArticle
|
||||
*/
|
||||
public String uploadMaterialArticle(int agentid, List<MpArticle> articles) throws WeixinException {
|
||||
public String uploadMaterialArticle(int agentid, List<MpArticle> articles)
|
||||
throws WeixinException {
|
||||
return mediaApi.uploadMaterialArticle(agentid, articles);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除永久媒体素材
|
||||
*
|
||||
*
|
||||
* @param agentid
|
||||
* 企业应用ID
|
||||
* @param mediaId
|
||||
@ -433,13 +442,14 @@ public class WeixinProxy {
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E5%88%A0%E9%99%A4%E6%B0%B8%E4%B9%85%E7%B4%A0%E6%9D%90">
|
||||
* 删除永久媒体素材</a>
|
||||
*/
|
||||
public JsonResult deleteMaterialMedia(int agentid, String mediaId) throws WeixinException {
|
||||
public JsonResult deleteMaterialMedia(int agentid, String mediaId)
|
||||
throws WeixinException {
|
||||
return mediaApi.deleteMaterialMedia(agentid, mediaId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载永久图文素材
|
||||
*
|
||||
*
|
||||
* @param agentid
|
||||
* 企业应用ID
|
||||
* @param mediaId
|
||||
@ -450,13 +460,14 @@ public class WeixinProxy {
|
||||
* @see com.foxinmy.weixin4j.qy.api.MediaApi
|
||||
* @see com.foxinmy.weixin4j.tuple.MpArticle
|
||||
*/
|
||||
public List<MpArticle> downloadArticle(int agentid, String mediaId) throws WeixinException {
|
||||
public List<MpArticle> downloadArticle(int agentid, String mediaId)
|
||||
throws WeixinException {
|
||||
return mediaApi.downloadArticle(agentid, mediaId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改永久图文素材
|
||||
*
|
||||
*
|
||||
* @param agentid
|
||||
* 企业应用的id
|
||||
* @param mediaId
|
||||
@ -471,13 +482,14 @@ public class WeixinProxy {
|
||||
* 修改永久媒体素材</a>
|
||||
* @see com.foxinmy.weixin4j.tuple.MpArticle
|
||||
*/
|
||||
public String updateMaterialArticle(int agentid, String mediaId, List<MpArticle> articles) throws WeixinException {
|
||||
public String updateMaterialArticle(int agentid, String mediaId,
|
||||
List<MpArticle> articles) throws WeixinException {
|
||||
return mediaApi.updateMaterialArticle(agentid, mediaId, articles);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取永久媒体素材的总数
|
||||
*
|
||||
*
|
||||
* @param agentid
|
||||
* 企业应用id
|
||||
* @return 总数对象
|
||||
@ -494,7 +506,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 获取媒体素材记录列表
|
||||
*
|
||||
*
|
||||
* @param agentid
|
||||
* 企业应用ID
|
||||
* @param mediaType
|
||||
@ -513,13 +525,14 @@ public class WeixinProxy {
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E8%8E%B7%E5%8F%96%E7%B4%A0%E6%9D%90%E5%88%97%E8%A1%A8">
|
||||
* 获取素材列表</a>
|
||||
*/
|
||||
public MediaRecord listMaterialMedia(int agentid, MediaType mediaType, Pageable pageable) throws WeixinException {
|
||||
public MediaRecord listMaterialMedia(int agentid, MediaType mediaType,
|
||||
Pageable pageable) throws WeixinException {
|
||||
return mediaApi.listMaterialMedia(agentid, mediaType, pageable);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全部的媒体素材
|
||||
*
|
||||
*
|
||||
* @param agentid
|
||||
* 企业应用id
|
||||
* @param mediaType
|
||||
@ -529,13 +542,14 @@ public class WeixinProxy {
|
||||
* @see {@link #listMaterialMedia(int,MediaType, Pageable)}
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public List<MediaItem> listAllMaterialMedia(int agentid, MediaType mediaType) throws WeixinException {
|
||||
public List<MediaItem> listAllMaterialMedia(int agentid, MediaType mediaType)
|
||||
throws WeixinException {
|
||||
return mediaApi.listAllMaterialMedia(agentid, mediaType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建部门(根部门的parentid为1)
|
||||
*
|
||||
*
|
||||
* @param party
|
||||
* 部门对象
|
||||
* @see com.foxinmy.weixin4j.qy.model.Party
|
||||
@ -552,7 +566,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 更新部门(如果非必须的字段未指定 则不更新该字段之前的设置值)
|
||||
*
|
||||
*
|
||||
* @param party
|
||||
* 部门对象
|
||||
* @see com.foxinmy.weixin4j.qy.model.Party
|
||||
@ -569,7 +583,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 查询部门列表(以部门的order字段从小到大排列)
|
||||
*
|
||||
*
|
||||
* @param partyId
|
||||
* 部门ID。获取指定部门ID下的子部门 传入0表示获取全部子部门
|
||||
* @see com.foxinmy.weixin4j.qy.model.Party
|
||||
@ -586,7 +600,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 删除部门(不能删除根部门;不能删除含有子部门、成员的部门)
|
||||
*
|
||||
*
|
||||
* @param partyId
|
||||
* 部门ID
|
||||
* @see <a href=
|
||||
@ -602,7 +616,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 批量上传部门
|
||||
*
|
||||
*
|
||||
* @param parties
|
||||
* 部门列表
|
||||
* @see com.foxinmy.weixin4j.qy.api.MediaApi
|
||||
@ -614,13 +628,14 @@ public class WeixinProxy {
|
||||
* @return 上传后的mediaId
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public String batchUploadParties(List<Party> parties) throws WeixinException {
|
||||
public String batchUploadParties(List<Party> parties)
|
||||
throws WeixinException {
|
||||
return mediaApi.batchUploadParties(parties);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建成员
|
||||
*
|
||||
*
|
||||
* @param user
|
||||
* 成员对象
|
||||
* @see com.foxinmy.weixin4j.qy.model.User
|
||||
@ -637,7 +652,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 创建成员
|
||||
*
|
||||
*
|
||||
* @param user
|
||||
* 成员对象
|
||||
* @param avatar
|
||||
@ -650,13 +665,14 @@ public class WeixinProxy {
|
||||
* @return 处理结果
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public JsonResult createUser(User user, InputStream avatar) throws WeixinException {
|
||||
public JsonResult createUser(User user, InputStream avatar)
|
||||
throws WeixinException {
|
||||
return userApi.createUser(user, avatar);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户(如果非必须的字段未指定 则不更新该字段之前的设置值)
|
||||
*
|
||||
*
|
||||
* @param user
|
||||
* 成员对象
|
||||
* @see com.foxinmy.weixin4j.qy.model.User
|
||||
@ -673,7 +689,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 更新用户(如果非必须的字段未指定 则不更新该字段之前的设置值)
|
||||
*
|
||||
*
|
||||
* @param user
|
||||
* 成员对象
|
||||
* @param avatar
|
||||
@ -686,13 +702,14 @@ public class WeixinProxy {
|
||||
* @return 处理结果
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public JsonResult updateUser(User user, InputStream avatar) throws WeixinException {
|
||||
public JsonResult updateUser(User user, InputStream avatar)
|
||||
throws WeixinException {
|
||||
return userApi.updateUser(user, avatar);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取成员信息
|
||||
*
|
||||
*
|
||||
* @param userid
|
||||
* 成员唯一ID
|
||||
* @see com.foxinmy.weixin4j.qy.model.User
|
||||
@ -709,7 +726,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* code获取userid(管理员须拥有agent的使用权限;agentid必须和跳转链接时所在的企业应用ID相同。)
|
||||
*
|
||||
*
|
||||
* @param code
|
||||
* 通过员工授权获取到的code,每次员工授权带上的code将不一样,code只能使用一次,5分钟未被使用自动过期
|
||||
* @see com.foxinmy.weixin4j.qy.model.User
|
||||
@ -731,7 +748,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 根据code获取成员ID信息
|
||||
*
|
||||
*
|
||||
* @param code
|
||||
* 通过员工授权获取到的code,每次员工授权带上的code将不一样,code只能使用一次,5分钟未被使用自动过期
|
||||
* @return 两个元素的数组 <font color="red">第一个元素为userId或者openId
|
||||
@ -748,7 +765,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 获取部门成员
|
||||
*
|
||||
*
|
||||
* @param partyId
|
||||
* 部门ID 必须
|
||||
* @param fetchChild
|
||||
@ -765,14 +782,14 @@ public class WeixinProxy {
|
||||
* @return 成员列表
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public List<User> listUser(int partyId, boolean fetchChild, UserStatus userStatus, boolean findDetail)
|
||||
throws WeixinException {
|
||||
public List<User> listUser(int partyId, boolean fetchChild,
|
||||
UserStatus userStatus, boolean findDetail) throws WeixinException {
|
||||
return userApi.listUser(partyId, fetchChild, userStatus, findDetail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门下所有状态成员(不进行递归)
|
||||
*
|
||||
*
|
||||
* @param partyId
|
||||
* 部门ID
|
||||
* @see {@link #listUser(int, boolean, UserStatus, boolean)}
|
||||
@ -786,7 +803,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 删除成员
|
||||
*
|
||||
*
|
||||
* @param userid
|
||||
* 成员ID
|
||||
* @see <a href=
|
||||
@ -802,7 +819,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 批量删除成员
|
||||
*
|
||||
*
|
||||
* @param userIds
|
||||
* 成员列表
|
||||
* @see <a href=
|
||||
@ -812,13 +829,14 @@ public class WeixinProxy {
|
||||
* @return 处理结果
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public JsonResult batchDeleteUser(List<String> userIds) throws WeixinException {
|
||||
public JsonResult batchDeleteUser(List<String> userIds)
|
||||
throws WeixinException {
|
||||
return userApi.batchDeleteUser(userIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 邀请成员关注(管理员须拥有该成员的查看权限)
|
||||
*
|
||||
*
|
||||
* @param userId
|
||||
* 成员ID
|
||||
* @param tips
|
||||
@ -830,17 +848,17 @@ public class WeixinProxy {
|
||||
* 邀请成员关注说明</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public InviteType inviteUser(String userId, String tips) throws WeixinException {
|
||||
public InviteType inviteUser(String userId, String tips)
|
||||
throws WeixinException {
|
||||
return userApi.inviteUser(userId, tips);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建标签(创建的标签属于管理组;默认为未加锁状态)
|
||||
*
|
||||
*
|
||||
* @param tag
|
||||
* 标签对象;</br>
|
||||
* 标签名称,长度为1~64个字节,标签名不可与其他标签重名;</br>
|
||||
* 标签id,整型, 指定此参数时新增的标签会生成对应的标签id,不指定时则以目前最大的id自增。
|
||||
* 标签对象;</br> 标签名称,长度为1~64个字节,标签名不可与其他标签重名;</br> 标签id,整型,
|
||||
* 指定此参数时新增的标签会生成对应的标签id,不指定时则以目前最大的id自增。
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%A0%87%E7%AD%BE#.E5.88.9B.E5.BB.BA.E6.A0.87.E7.AD.BE">
|
||||
* 创建标签说明</a>
|
||||
@ -854,7 +872,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 更新标签(管理组必须是指定标签的创建者)
|
||||
*
|
||||
*
|
||||
* @param tag
|
||||
* 标签信息
|
||||
* @see <a href=
|
||||
@ -871,7 +889,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 删除标签(管理组必须是指定标签的创建者 并且标签的成员列表为空)
|
||||
*
|
||||
*
|
||||
* @param tagId
|
||||
* 标签ID
|
||||
* @return 处理结果
|
||||
@ -887,7 +905,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 获取标签列表
|
||||
*
|
||||
*
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%A0%87%E7%AD%BE#.E8.8E.B7.E5.8F.96.E6.A0.87.E7.AD.BE.E5.88.97.E8.A1.A8">
|
||||
* 获取标签列表说明</a>
|
||||
@ -902,7 +920,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 获取标签成员(管理组须拥有“获取标签成员”的接口权限,标签须对管理组可见;返回列表仅包含管理组管辖范围的成员)
|
||||
*
|
||||
*
|
||||
* @param tagId
|
||||
* 标签ID
|
||||
* @see com.foxinmy.weixin4j.qy.model.User
|
||||
@ -910,8 +928,8 @@ public class WeixinProxy {
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%A0%87%E7%AD%BE#.E8.8E.B7.E5.8F.96.E6.A0.87.E7.AD.BE.E6.88.90.E5.91.98">
|
||||
* 获取标签成员说明</a>
|
||||
* @see com.foxinmy.weixin4j.qy.api.TagApi
|
||||
* @return 成员列表<font color="red">Contacts#getUsers</font>和部门列表
|
||||
* <font color="red">Contacts#getPartyIds</font>
|
||||
* @return 成员列表<font color="red">Contacts#getUsers</font>和部门列表 <font
|
||||
* color="red">Contacts#getPartyIds</font>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public Contacts getTagUsers(int tagId) throws WeixinException {
|
||||
@ -920,7 +938,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 新增标签成员(标签对管理组可见且未加锁,成员属于管理组管辖范围)
|
||||
*
|
||||
*
|
||||
* @param tagId
|
||||
* 标签ID
|
||||
* @param userIds
|
||||
@ -935,13 +953,14 @@ public class WeixinProxy {
|
||||
* @return 非法的userIds和partyIds
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public IdParameter addTagUsers(int tagId, List<String> userIds, List<Integer> partyIds) throws WeixinException {
|
||||
public IdParameter addTagUsers(int tagId, List<String> userIds,
|
||||
List<Integer> partyIds) throws WeixinException {
|
||||
return tagApi.addTagUsers(tagId, userIds, partyIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除标签成员(标签对管理组可见且未加锁,成员属于管理组管辖范围)
|
||||
*
|
||||
*
|
||||
* @param tagId
|
||||
* 标签ID
|
||||
* @param userIds
|
||||
@ -956,13 +975,14 @@ public class WeixinProxy {
|
||||
* @return 非法的userIds和partyIds
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public IdParameter deleteTagUsers(int tagId, List<String> userIds, List<Integer> partyIds) throws WeixinException {
|
||||
public IdParameter deleteTagUsers(int tagId, List<String> userIds,
|
||||
List<Integer> partyIds) throws WeixinException {
|
||||
return tagApi.deleteTagUsers(tagId, userIds, partyIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取微信服务器IP地址
|
||||
*
|
||||
*
|
||||
* @return IP地址
|
||||
* @see com.foxinmy.weixin4j.qy.api.HelperApi
|
||||
* @see <a href=
|
||||
@ -976,7 +996,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 获取企业号某个应用的基本信息,包括头像、昵称、帐号类型、认证类型、可见范围等信息
|
||||
*
|
||||
*
|
||||
* @param agentid
|
||||
* 授权方应用id
|
||||
* @return 应用信息
|
||||
@ -993,7 +1013,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 设置企业应用的选项设置信息,如:地理位置上报等
|
||||
*
|
||||
*
|
||||
* @param agentSet
|
||||
* 设置参数
|
||||
* @see com.foxinmy.weixin4j.qy.model.AgentSetter
|
||||
@ -1010,7 +1030,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 获取应用概况列表
|
||||
*
|
||||
*
|
||||
* @see com.foxinmy.weixin4j.qy.model.AgentOverview
|
||||
* @see com.foxinmy.weixin4j.qy.api.AgentApi
|
||||
* @see <a href=
|
||||
@ -1025,7 +1045,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 批量邀请成员关注
|
||||
*
|
||||
*
|
||||
* @param parameter
|
||||
* 成员ID,标签ID,部门ID
|
||||
* @param callback
|
||||
@ -1041,7 +1061,8 @@ public class WeixinProxy {
|
||||
* 邀请成员关注</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public String batchInviteUser(IdParameter parameter, Callback callback, String tips) throws WeixinException {
|
||||
public String batchInviteUser(IdParameter parameter, Callback callback,
|
||||
String tips) throws WeixinException {
|
||||
return batchApi.inviteUser(parameter, callback, tips);
|
||||
}
|
||||
|
||||
@ -1049,11 +1070,10 @@ public class WeixinProxy {
|
||||
* 批量更新成员,本接口以userid为主键,增量更新企业号通讯录成员。
|
||||
* <p>
|
||||
* 1.模板中的部门需填写部门ID,多个部门用分号分隔,部门ID必须为数字</br>
|
||||
* 2.文件中存在、通讯录中也存在的成员,更新成员在文件中指定的字段值 </br>
|
||||
* 3.文件中存在、通讯录中不存在的成员,执行添加操作</br>
|
||||
* 2.文件中存在、通讯录中也存在的成员,更新成员在文件中指定的字段值 </br> 3.文件中存在、通讯录中不存在的成员,执行添加操作</br>
|
||||
* 4.通讯录中存在、文件中不存在的成员,保持不变</br>
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param mediaId
|
||||
* 带user信息的cvs文件上传后的media_id
|
||||
* @param callback
|
||||
@ -1066,20 +1086,20 @@ public class WeixinProxy {
|
||||
* 批量更新成员</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public String batchSyncUser(String mediaId, Callback callback) throws WeixinException {
|
||||
public String batchSyncUser(String mediaId, Callback callback)
|
||||
throws WeixinException {
|
||||
return batchApi.syncUser(mediaId, callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量覆盖成员,本接口以userid为主键,全量覆盖企业号通讯录成员,任务完成后企业号通讯录成员与提交的文件完全保持一致。
|
||||
* <p>
|
||||
* 1.模板中的部门需填写部门ID,多个部门用分号分隔,部门ID必须为数字</br>
|
||||
* 2.文件中存在、通讯录中也存在的成员,完全以文件为准</br>
|
||||
* 1.模板中的部门需填写部门ID,多个部门用分号分隔,部门ID必须为数字</br> 2.文件中存在、通讯录中也存在的成员,完全以文件为准</br>
|
||||
* 3.文件中存在、通讯录中不存在的成员,执行添加操作</br>
|
||||
* 4.通讯录中存在、文件中不存在的成员,执行删除操作。出于安全考虑,如果需要删除的成员多于50人,
|
||||
* 且多于现有人数的20%以上,系统将中止导入并返回相应的错误码
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param mediaId
|
||||
* 带userid信息的cvs文件上传后的media_id
|
||||
* @param callback
|
||||
@ -1092,13 +1112,14 @@ public class WeixinProxy {
|
||||
* 批量覆盖成员</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public String batchReplaceUser(String mediaId, Callback callback) throws WeixinException {
|
||||
public String batchReplaceUser(String mediaId, Callback callback)
|
||||
throws WeixinException {
|
||||
return batchApi.replaceUser(mediaId, callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量上传成员
|
||||
*
|
||||
*
|
||||
* @param users
|
||||
* 成员列表
|
||||
* @see com.foxinmy.weixin4j.qy.api.MediaApi
|
||||
@ -1118,12 +1139,11 @@ public class WeixinProxy {
|
||||
/**
|
||||
* 批量覆盖部门,本接口以partyid为键,全量覆盖企业号通讯录组织架构,任务完成后企业号通讯录组织架构与提交的文件完全保持一致。
|
||||
* <p>
|
||||
* 1.文件中存在、通讯录中也存在的部门,执行修改操作</br>
|
||||
* 2.文件中存在、通讯录中不存在的部门,执行添加操作</br>
|
||||
* 1.文件中存在、通讯录中也存在的部门,执行修改操作</br> 2.文件中存在、通讯录中不存在的部门,执行添加操作</br>
|
||||
* 3.文件中不存在、通讯录中存在的部门,当部门为空时,执行删除操作</br>
|
||||
* 4.CSV文件中,部门名称、部门ID、父部门ID为必填字段,部门ID必须为数字;排序为可选字段,置空或填0不修改排序
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param mediaId
|
||||
* 带partyid信息的cvs文件上传后的media_id
|
||||
* @param callback
|
||||
@ -1136,13 +1156,14 @@ public class WeixinProxy {
|
||||
* 批量覆盖部门</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public String batchReplaceParty(String mediaId, Callback callback) throws WeixinException {
|
||||
public String batchReplaceParty(String mediaId, Callback callback)
|
||||
throws WeixinException {
|
||||
return batchApi.replaceParty(mediaId, callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取异步任务执行的结果
|
||||
*
|
||||
*
|
||||
* @param jobId
|
||||
* 任务ID
|
||||
* @return 效果信息
|
||||
@ -1160,7 +1181,7 @@ public class WeixinProxy {
|
||||
/**
|
||||
* userid转换成openid:该接口使用场景为微信支付、微信红包和企业转账,企业号用户在使用微信支付的功能时,
|
||||
* 需要自行将企业号的userid转成openid。 在使用微信红包功能时,需要将应用id和userid转成appid和openid才能使用。
|
||||
*
|
||||
*
|
||||
* @param userid
|
||||
* 企业号内的成员id 必填
|
||||
* @param agentid
|
||||
@ -1172,14 +1193,15 @@ public class WeixinProxy {
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=Userid%E4%B8%8Eopenid%E4%BA%92%E6%8D%A2%E6%8E%A5%E5%8F%A3">
|
||||
* userid转换成openid</a>
|
||||
*/
|
||||
public String[] userid2openid(String userid, int agentid) throws WeixinException {
|
||||
public String[] userid2openid(String userid, int agentid)
|
||||
throws WeixinException {
|
||||
return userApi.userid2openid(userid, agentid);
|
||||
}
|
||||
|
||||
/**
|
||||
* openid转换成userid:该接口主要应用于使用微信支付、微信红包和企业转账之后的结果查询,
|
||||
* 开发者需要知道某个结果事件的openid对应企业号内成员的信息时,可以通过调用该接口进行转换查询。
|
||||
*
|
||||
*
|
||||
* @param openid
|
||||
* 在使用微信支付、微信红包和企业转账之后,返回结果的openid
|
||||
* @return 该openid在企业号中对应的成员userid
|
||||
@ -1195,7 +1217,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 创建会话 <font color="red">如果会话id为空,程序会自动生成一个唯一ID</font>
|
||||
*
|
||||
*
|
||||
* @param chatInfo
|
||||
* 会话信息
|
||||
* @return 会话ID
|
||||
@ -1212,7 +1234,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 获取会话
|
||||
*
|
||||
*
|
||||
* @param chatId
|
||||
* 会话ID
|
||||
* @return 会话信息
|
||||
@ -1229,7 +1251,7 @@ public class WeixinProxy {
|
||||
|
||||
/**
|
||||
* 更新会话
|
||||
*
|
||||
*
|
||||
* @param chatInfo
|
||||
* 会话信息 至少保持会话ID不能为空
|
||||
* @param operator
|
||||
@ -1246,14 +1268,15 @@ public class WeixinProxy {
|
||||
* 修改会话信息</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public JsonResult updateChat(ChatInfo chatInfo, String operator, List<String> addUsers, List<String> deleteUsers)
|
||||
public JsonResult updateChat(ChatInfo chatInfo, String operator,
|
||||
List<String> addUsers, List<String> deleteUsers)
|
||||
throws WeixinException {
|
||||
return chatApi.updateChat(chatInfo, operator, addUsers, deleteUsers);
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出会话
|
||||
*
|
||||
*
|
||||
* @param chatId
|
||||
* 会话ID
|
||||
* @param operator
|
||||
@ -1265,13 +1288,14 @@ public class WeixinProxy {
|
||||
* 退出会话</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public JsonResult quitChat(String chatId, String operator) throws WeixinException {
|
||||
public JsonResult quitChat(String chatId, String operator)
|
||||
throws WeixinException {
|
||||
return chatApi.quitChat(chatId, operator);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除会话未读状态
|
||||
*
|
||||
*
|
||||
* @param targetId
|
||||
* 会话值,为userid|chatid,分别表示:成员id|会话id
|
||||
* @param owner
|
||||
@ -1285,14 +1309,15 @@ public class WeixinProxy {
|
||||
* 清除会话未读状态</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public JsonResult clearChatNotify(String targetId, String owner, ChatType chatType) throws WeixinException {
|
||||
public JsonResult clearChatNotify(String targetId, String owner,
|
||||
ChatType chatType) throws WeixinException {
|
||||
return chatApi.clearChatNotify(targetId, owner, chatType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置成员接收到的消息是否提醒。主要场景是用于对接企业im的在线状态,如成员处于在线状态时,可以设置该成员的消息免打扰。当成员离线时,关闭免打扰状态
|
||||
* ,对微信端进行提醒。
|
||||
*
|
||||
*
|
||||
* @param chatMutes
|
||||
* 提醒参数
|
||||
* @see com.foxinmy.weixin4j.qy.api.ChatApi
|
||||
@ -1303,13 +1328,14 @@ public class WeixinProxy {
|
||||
* @return 列表中不存在的成员,剩余合法成员会继续执行。
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public List<String> setChatMute(List<ChatMute> chatMutes) throws WeixinException {
|
||||
public List<String> setChatMute(List<ChatMute> chatMutes)
|
||||
throws WeixinException {
|
||||
return chatApi.setChatMute(chatMutes);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送会话消息
|
||||
*
|
||||
*
|
||||
* @param message
|
||||
* 消息对象
|
||||
* @return 处理结果
|
||||
@ -1320,7 +1346,8 @@ public class WeixinProxy {
|
||||
* 发送消息</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public JsonResult sendChatMessage(ChatMessage message) throws WeixinException {
|
||||
public JsonResult sendChatMessage(ChatMessage message)
|
||||
throws WeixinException {
|
||||
return chatApi.sendChatMessage(message);
|
||||
}
|
||||
|
||||
|
||||
@ -59,26 +59,26 @@ public class WeixinSuiteProxy {
|
||||
*/
|
||||
public WeixinSuiteProxy(Weixin4jSuiteSettings suiteSettings) {
|
||||
this.suiteSettings = suiteSettings;
|
||||
if (suiteSettings.getWeixinAccount().getSuiteAccounts() != null) {
|
||||
if (suiteSettings.getAccount().getSuiteAccounts() != null) {
|
||||
this.suiteMap = new HashMap<String, SuiteApi>();
|
||||
for (WeixinAccount suite : suiteSettings.getWeixinAccount()
|
||||
for (WeixinAccount suite : suiteSettings.getAccount()
|
||||
.getSuiteAccounts()) {
|
||||
this.suiteMap.put(suite.getId(), new SuiteApi(
|
||||
new SuiteTicketHolder(suite.getId(), suite.getSecret(),
|
||||
suiteSettings.getTokenStorager0())));
|
||||
this.suiteMap.put(
|
||||
null,
|
||||
suiteMap.get(suiteSettings.getWeixinAccount()
|
||||
suiteMap.get(suiteSettings.getAccount()
|
||||
.getSuiteAccounts().get(0).getId()));
|
||||
}
|
||||
}
|
||||
if (StringUtil.isNotBlank(suiteSettings.getWeixinAccount().getId())
|
||||
&& StringUtil.isNotBlank(suiteSettings.getWeixinAccount()
|
||||
if (StringUtil.isNotBlank(suiteSettings.getAccount().getId())
|
||||
&& StringUtil.isNotBlank(suiteSettings.getAccount()
|
||||
.getProviderSecret())) {
|
||||
this.providerApi = new ProviderApi(new TokenHolder(
|
||||
new WeixinProviderTokenCreator(suiteSettings
|
||||
.getWeixinAccount().getId(), suiteSettings
|
||||
.getWeixinAccount().getProviderSecret()),
|
||||
.getAccount().getId(), suiteSettings
|
||||
.getAccount().getProviderSecret()),
|
||||
suiteSettings.getTokenStorager0()),
|
||||
suiteSettings.getTokenStorager0());
|
||||
}
|
||||
@ -90,7 +90,7 @@ public class WeixinSuiteProxy {
|
||||
* @return
|
||||
*/
|
||||
public WeixinQyAccount getWeixinAccount() {
|
||||
return this.suiteSettings.getWeixinAccount();
|
||||
return this.suiteSettings.getAccount();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -3,40 +3,22 @@ package com.foxinmy.weixin4j.qy.suite;
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.foxinmy.weixin4j.http.HttpParams;
|
||||
import com.foxinmy.weixin4j.model.WeixinAccount;
|
||||
import com.foxinmy.weixin4j.qy.model.WeixinQyAccount;
|
||||
import com.foxinmy.weixin4j.token.FileTokenStorager;
|
||||
import com.foxinmy.weixin4j.token.TokenStorager;
|
||||
import com.foxinmy.weixin4j.setting.SystemSettings;
|
||||
import com.foxinmy.weixin4j.util.StringUtil;
|
||||
import com.foxinmy.weixin4j.util.Weixin4jConfigUtil;
|
||||
|
||||
/**
|
||||
* 微信第三方套件配置相关
|
||||
*
|
||||
*
|
||||
* @className Weixin4jSuiteSettings
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2016年1月28日
|
||||
* @since JDK 1.6
|
||||
* @see
|
||||
*/
|
||||
public class Weixin4jSuiteSettings {
|
||||
/**
|
||||
* 微信企业号信息
|
||||
*/
|
||||
private final WeixinQyAccount weixinAccount;
|
||||
/**
|
||||
* Http参数
|
||||
*/
|
||||
private HttpParams httpParams;
|
||||
/**
|
||||
* token存储方式 默认为FileTokenStorager
|
||||
*/
|
||||
private TokenStorager tokenStorager;
|
||||
/**
|
||||
* 系统临时目录
|
||||
*/
|
||||
private String tmpdir;
|
||||
public class Weixin4jSuiteSettings extends SystemSettings<WeixinQyAccount> {
|
||||
|
||||
/**
|
||||
* 默认使用weixin4j.properties配置的信息
|
||||
@ -47,7 +29,7 @@ public class Weixin4jSuiteSettings {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param providerCorpId
|
||||
* 服务商的企业号ID <font color="red">使用服务商API时必填项</font>
|
||||
* @param providerSecret
|
||||
@ -57,68 +39,30 @@ public class Weixin4jSuiteSettings {
|
||||
*/
|
||||
public Weixin4jSuiteSettings(String providerCorpId, String providerSecret,
|
||||
WeixinAccount... suites) {
|
||||
this.weixinAccount = new WeixinQyAccount(providerCorpId, null,
|
||||
Arrays.asList(suites), providerSecret, null);
|
||||
this(new WeixinQyAccount(providerCorpId, null, Arrays.asList(suites),
|
||||
providerSecret, null));
|
||||
}
|
||||
|
||||
private Weixin4jSuiteSettings(WeixinQyAccount weixinAccount) {
|
||||
this.weixinAccount = weixinAccount;
|
||||
}
|
||||
|
||||
public WeixinQyAccount getWeixinAccount() {
|
||||
return weixinAccount;
|
||||
}
|
||||
|
||||
public HttpParams getHttpParams() {
|
||||
return httpParams;
|
||||
}
|
||||
|
||||
public HttpParams getHttpParams0() {
|
||||
if (httpParams == null) {
|
||||
return new HttpParams();
|
||||
}
|
||||
return httpParams;
|
||||
}
|
||||
|
||||
public String getTmpdir() {
|
||||
return tmpdir;
|
||||
/**
|
||||
* 账号信息
|
||||
*
|
||||
* @param account
|
||||
*/
|
||||
private Weixin4jSuiteSettings(WeixinQyAccount account) {
|
||||
super(account);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTmpdir0() {
|
||||
if (StringUtil.isBlank(tmpdir)) {
|
||||
if (StringUtil.isBlank(getTmpdir())) {
|
||||
return Weixin4jConfigUtil.getClassPathValue("weixin4j.tmpdir",
|
||||
System.getProperty("java.io.tmpdir"));
|
||||
}
|
||||
return tmpdir;
|
||||
}
|
||||
|
||||
public TokenStorager getTokenStorager() {
|
||||
return tokenStorager;
|
||||
}
|
||||
|
||||
public TokenStorager getTokenStorager0() {
|
||||
if (tokenStorager == null) {
|
||||
return new FileTokenStorager(getTmpdir0());
|
||||
}
|
||||
return tokenStorager;
|
||||
}
|
||||
|
||||
public void setHttpParams(HttpParams httpParams) {
|
||||
this.httpParams = httpParams;
|
||||
}
|
||||
|
||||
public void setTmpdir(String tmpdir) {
|
||||
this.tmpdir = tmpdir;
|
||||
}
|
||||
|
||||
public void setTokenStorager(TokenStorager tokenStorager) {
|
||||
this.tokenStorager = tokenStorager;
|
||||
return getTmpdir();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Weixin4jSuiteSettings [weixinAccount=" + weixinAccount
|
||||
+ ", httpParams=" + httpParams + ",tokenStorager="
|
||||
+ tokenStorager + ", tmpdir=" + tmpdir + "]";
|
||||
return "Weixin4jSuiteSettings [" + super.toString() + "]";
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,12 +6,12 @@ import org.junit.Test;
|
||||
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.qy.token.WeixinTokenCreator;
|
||||
import com.foxinmy.weixin4j.setting.Weixin4jSettings;
|
||||
import com.foxinmy.weixin4j.token.TokenHolder;
|
||||
import com.foxinmy.weixin4j.util.Weixin4jSettings;
|
||||
|
||||
/**
|
||||
* token测试
|
||||
*
|
||||
*
|
||||
* @className TokenTest
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2014年4月10日
|
||||
@ -26,7 +26,7 @@ public class TokenTest {
|
||||
public void setUp() {
|
||||
this.settings = new Weixin4jSettings();
|
||||
tokenHolder = new TokenHolder(new WeixinTokenCreator(settings
|
||||
.getWeixinAccount().getId(), settings.getWeixinAccount()
|
||||
.getAccount().getId(), settings.getAccount()
|
||||
.getSecret()), settings.getTokenStorager0());
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user