审计记录

src/org/theyeasy/weixin/service/WxOpenService.java 4.2 KB
zxt@theyeasy.com committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
package org.theyeasy.weixin.service;


import org.apache.http.HttpHost; 
 
import org.theyeasy.weixin.model.WxOpenConfigStorage;
import org.theyeasy.weixin.model.WxOpenQueryAuthResult;

import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.util.http.RequestExecutor;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;



public interface WxOpenService {
	
	/**
	 * 获取授权公众号操作对象   系统初始化的时候调用
	 * @param appId  授权公众号appId
	 * @param authorizerRefreshToken  刷新token
	 * @return
	 * @throws WxErrorException
	 */
	public  WxMpService initWxMpService(String appId,String authorizerRefreshToken) throws WxErrorException;
	
	/**
	 *  获取授权公众号操作对象  操作公众号对象
	 * @param appId  授权公众号appId
	 * @throws WxErrorException
	 */
	public  WxMpService getWxMpService(String appId) throws WxErrorException;
	
	
	public void setWxOpenConfigStorage(WxOpenConfigStorage wxOpenConfigStorage) ;


	public WxOpenConfigStorage getWxOpenConfigStorage();
	
	
	
	
	/**
	 * 获取预授权码。预授权码用于公众号授权时的第三方平台方安全验证。
	 * @return 返回预授权码
	 * @throws WxErrorException
	 */
	String getPreAuthCode() throws WxErrorException;
	
	/**
	   * <pre>
	   * 获取PreAuthCode,本方法线程安全
	   * 且在多线程同时刷新时只刷新一次
	   *
	   * 程序员在非必要情况下尽量不要主动调用此方法
	   * </pre>
	   *
	   * @param forceRefresh 强制刷新
	   */
	public String getPreAuthCode(boolean forceRefresh) throws WxErrorException;
	
	/**
	 * 获取授权方的帐号基本信息
	 * @return
	 * @throws WxErrorException
	 */
	WxOpenQueryAuthResult getApiQueryAuth(String authorizationCode) throws WxErrorException;
	
	/**
	 * 获取授权方的帐号基本信息
	 * @return
	 * @throws WxErrorException
	 */
	String getApiGetAuthorizerInfo(String authorizationCode,int merchantid) throws WxErrorException;
	
	
	
	/**
	   * 获取access_token, 不强制刷新access_token
	   *
	   * @see #getAccessToken(boolean)
	   */
	  String getAccessToken() throws WxErrorException;

	  /**
	   * <pre>
	   * 获取access_token,本方法线程安全
	   * 且在多线程同时刷新时只刷新一次,避免超出2000次/日的调用次数上限
	   *
	   * 另:本service的所有方法都会在access_token过期是调用此方法
	   *
	   * 程序员在非必要情况下尽量不要主动调用此方法
	   *
	   * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140183&token=&lang=zh_CN
	   * </pre>
	   *
	   * @param forceRefresh 强制刷新
	   */
	  String getAccessToken(boolean forceRefresh) throws WxErrorException;
	  
	  /**
	   * 获取代理对象
	   */
	  HttpHost getHttpProxy();
	  
	  /**
	   * 获取预授权网址
	   * @return
	   */
	  String getOauth2buildAuthorizationUrl() throws WxErrorException;
	  /**
	   * 获取预授权网址
	   * redirectUri 回调地址
	   * @return
	   */
	  public String getOauth2buildAuthorizationUrl(String redirectUri) throws WxErrorException;
	  
	  
	
	  <T, E> T execute(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException;
	  
	  /**
	   * <pre>
	   * 设置当微信系统响应系统繁忙时,要等待多少 retrySleepMillis(ms) * 2^(重试次数 - 1) 再发起重试
	   * 默认:1000ms
	   * </pre>
	   */
	  void setRetrySleepMillis(int retrySleepMillis);
	  
	  /**
	   * <pre>
	   * 设置当微信系统响应系统繁忙时,最大重试次数
	   * 默认:5次
	   * </pre>
	   */
	  void setMaxRetryTimes(int maxRetryTimes);
	  
	  
	  /**
	   * 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的POST请求
	   */
	  String post(String url, String postData) throws WxErrorException;
	  
	  
	  /**
	   * 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的GET请求
	   */
	  String get(String url, String queryParam) throws WxErrorException;
	  
	  
	  
	  public WxMpXmlOutMessage route(WxMpXmlMessage message,String appId);
	  
	
}