chenyongxing пре 6 година
родитељ
комит
5371bc17e8

+ 11 - 16
business/base-service/src/main/java/com/yihu/jw/wechat/service/WechatInfoService.java

@ -19,22 +19,17 @@ public class WechatInfoService {
     * @param code
     * @return
     */
    public String getOpenidByCode(String code,String appId,String appSecret) {
        try {
            String token_url = "https://api.weixin.qq.com/sns/oauth2/access_token";
            String params = "appid=" + appId + "&secret=" +appSecret+ "&code=" + code + "&grant_type=authorization_code";
            String result = HttpUtil.sendGet(token_url, params);
            System.out.println("getOpenidByCode:"+result);
            JSONObject json = new JSONObject(result);
            if (json.has("openid")) {
                return json.get("openid").toString();
            } else {
                return null;
            }
        } catch (Exception e) {
            e.printStackTrace();
    public String getOpenidByCode(String code,String appId,String appSecret) throws Exception {
        String token_url = "https://api.weixin.qq.com/sns/oauth2/access_token";
        String params = "appid=" + appId + "&secret=" +appSecret+ "&code=" + code + "&grant_type=authorization_code";
        String result = HttpUtil.sendGet(token_url, params);
        System.out.println("getOpenidByCode:"+result);
        JSONObject json = new JSONObject(result);
        if (json.has("openid")) {
            return json.get("openid").toString();
        }else{
            throw new Exception(result);
        }
        return null;
    }
    /**
@ -43,7 +38,7 @@ public class WechatInfoService {
     * @param code
     * @return
     */
    public String getOpenidByCode(String code,String wxId) {
    public String getOpenidByCode(String code,String wxId) throws Exception {
        //通过wxId获取appId和appSecret
        WxWechatDO wxWechatDO = wechatDao.findById(wxId);
        return getOpenidByCode(code,wxWechatDO.getAppId(),wxWechatDO.getAppSecret());

+ 1 - 0
gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/BasicZuulFilter.java

@ -63,6 +63,7 @@ public class BasicZuulFilter extends ZuulFilter {
        //内部微服务有不需要认证的地址请在URL上追加/open/来进行过滤,如/api/v1.0/open/**,不要在此继续追加!!!
        if (url.contains("/auth/")//验证服务
                || url.contains("/wechat")//微信
                || url.contains("/wxBase")//微信
                || url.contains("/open/")) {//开发接口
            return true;
        }

+ 2 - 2
svr/svr-patient/src/main/resources/application.yml

@ -109,7 +109,7 @@ jw:
myFamily:
  qrCodeFailurTime: 7
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040  # base库中,wx_wechat 的id字段
  id: 97ed8a0a-4f07-4b85-ab02-b716c611a464  # base库中,wx_wechat 的id字段
# 短信验证码发送的客户端标识,居民端
sms:
  clientId: EwC0iRSrcP
@ -141,7 +141,7 @@ spring:
fastDFS:
  fastdfs_file_url: http://172.19.103.54:80/
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040  # base库中,wx_wechat 的id字段
  id: 97ed8a0a-4f07-4b85-ab02-b716c611a464  # base库中,wx_wechat 的id字段
# 短信验证码发送的客户端标识,居民端
sms:
  clientId: EwC0iRSrcP