package com.qxgmat.help; import com.nuliji.tools.third.OauthData; import com.nuliji.tools.third.wechat.MessageListener; import com.nuliji.tools.third.wechat.WechatClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @Service public class WechatHelp { private WechatClient wechatPc; @Autowired private void getWechatPc(@Value("${third.wechat.pc.appId}") String appId, @Value("${third.wechat.pc.appSecret}") String appSecret) { this.wechatPc = new WechatClient(appId, appSecret); } private WechatClient wechat; @Autowired private void getWechat(@Value("${third.wechat.native.appId}") String appId, @Value("${third.wechat.native.appSecret}") String appSecret) { this.wechat = new WechatClient(appId, appSecret); } public OauthData oauthPc(String code) { return wechatPc.webAuthorize(code); } public OauthData oauthNative(String code){ return wechat.webAuthorize(code); } public OauthData refreshNative(String refreshToken) { return wechat.refreshWebAccessToken(refreshToken); } public String redirectPc(String redirectUrl, String state){ return wechatPc.getOAuthUrl(redirectUrl, state); } public String redirectNative(String redirectUrl, String state){ return wechat.getOAuthUrl(redirectUrl, state); } public String receiveMessage(String body){ wechat.ReceiveMessage(body, new MessageListener() { @Override public void OnScan(String openId, int sceneId) { } @Override public void OnSubscribe(String openId) { } }); return ""; } }