调整微信工具封装
This commit is contained in:
parent
0817050b1b
commit
11bf25156f
|
|
@ -1,5 +1,8 @@
|
||||||
package com.mdd.common.utils;
|
package com.mdd.common.utils;
|
||||||
|
|
||||||
|
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||||
|
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
|
||||||
|
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
|
||||||
import com.qcloud.cos.model.ciModel.auditing.Conf;
|
import com.qcloud.cos.model.ciModel.auditing.Conf;
|
||||||
import me.chanjar.weixin.mp.api.WxMpService;
|
import me.chanjar.weixin.mp.api.WxMpService;
|
||||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
||||||
|
|
@ -9,6 +12,24 @@ import java.util.Map;
|
||||||
|
|
||||||
public class WeChatUtil {
|
public class WeChatUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信小程序
|
||||||
|
*
|
||||||
|
* @author fzr
|
||||||
|
* @return WxMaService
|
||||||
|
*/
|
||||||
|
public static WxMaService mnp() {
|
||||||
|
Map<String, String> config = ConfigUtil.get("mp_channel");
|
||||||
|
|
||||||
|
WxMaService service = new WxMaServiceImpl();
|
||||||
|
WxMaDefaultConfigImpl wxConfig = new WxMaDefaultConfigImpl();
|
||||||
|
wxConfig.setAppid(config.getOrDefault("appId", ""));
|
||||||
|
wxConfig.setSecret(config.getOrDefault("appSecret", ""));
|
||||||
|
service.setWxMaConfig(wxConfig);
|
||||||
|
return service;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信公众号
|
* 微信公众号
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -90,14 +90,8 @@ public class LoginServiceImpl implements ILoginService {
|
||||||
String gender = params.getOrDefault("gender", "0");
|
String gender = params.getOrDefault("gender", "0");
|
||||||
Integer client = Integer.parseInt(params.getOrDefault("client", "1"));
|
Integer client = Integer.parseInt(params.getOrDefault("client", "1"));
|
||||||
|
|
||||||
Map<String, String> config = ConfigUtil.get("mp_channel");
|
|
||||||
WxMaService wxMaService = new WxMaServiceImpl();
|
|
||||||
WxMaDefaultConfigImpl wxConfig = new WxMaDefaultConfigImpl();
|
|
||||||
wxConfig.setAppid(config.getOrDefault("appId", ""));
|
|
||||||
wxConfig.setSecret(config.getOrDefault("appSecret", ""));
|
|
||||||
wxMaService.setWxMaConfig(wxConfig);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
WxMaService wxMaService = WeChatUtil.mnp();
|
||||||
WxMaJscode2SessionResult sessionResult = wxMaService.getUserService().getSessionInfo(code);
|
WxMaJscode2SessionResult sessionResult = wxMaService.getUserService().getSessionInfo(code);
|
||||||
String openId = sessionResult.getOpenid();
|
String openId = sessionResult.getOpenid();
|
||||||
String uniId = sessionResult.getUnionid();
|
String uniId = sessionResult.getUnionid();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue