增加公众号登录

This commit is contained in:
TinyAnts 2022-09-14 11:22:43 +08:00
parent 30e6033b02
commit 0817050b1b
3 changed files with 33 additions and 0 deletions

View File

@ -55,6 +55,9 @@ public class LoginController {
case "account":
map = iLoginService.accountLogin(params);
break;
case "office":
map = iLoginService.officeLogin();
break;
}
return AjaxResult.success(map);
}

View File

@ -44,6 +44,14 @@ public interface ILoginService {
*/
Map<String, Object> accountLogin(Map<String, String> params);
/**
* 公众号登录
*
* @author fzr
* @return Map<String, Object>
*/
Map<String, Object> officeLogin();
/**
* 忘记密码
*

View File

@ -17,7 +17,10 @@ import com.mdd.common.utils.*;
import com.mdd.front.config.FrontConfig;
import com.mdd.front.service.ILoginService;
import com.mdd.front.validate.RegParam;
import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -256,6 +259,25 @@ public class LoginServiceImpl implements ILoginService {
return response;
}
/**
* 公众号登录
*
* @author fzr
* @return Map<String, Object>
*/
@Override
public Map<String, Object> officeLogin() {
WxMpService wxMpService = WeChatUtil.official();
try {
WxOAuth2AccessToken wxOAuth2AccessToken = wxMpService.getOAuth2Service().getAccessToken("aaa");
WxMpUser wxMpUser = wxMpService.getUserService().userInfo(wxOAuth2AccessToken.getAccessToken());
System.out.println(wxMpUser);
} catch (WxErrorException e) {
System.out.println(e.getError());
}
return null;
}
/**
* 忘记密码
*