mirror of
https://gitee.com/youlaitech/youlai-mall.git
synced 2025-01-04 01:52:21 +08:00
feat:微信小程序用户登录逻辑
This commit is contained in:
parent
e66a8445e8
commit
cd73d8bb9b
@ -1,10 +1,6 @@
|
|||||||
package com.youlai.mall.oms.api;
|
package com.youlai.mall.oms.api;
|
||||||
|
|
||||||
import com.youlai.common.result.Result;
|
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author haoxr
|
* @author haoxr
|
||||||
|
@ -53,7 +53,6 @@ public class OAuthController {
|
|||||||
@ApiIgnore Principal principal,
|
@ApiIgnore Principal principal,
|
||||||
@ApiIgnore @RequestParam Map<String, String> parameters
|
@ApiIgnore @RequestParam Map<String, String> parameters
|
||||||
) throws HttpRequestMethodNotSupportedException {
|
) throws HttpRequestMethodNotSupportedException {
|
||||||
JwtTokenPair jwtTokenPair = new JwtTokenPair();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取登录认证的客户端ID
|
* 获取登录认证的客户端ID
|
||||||
@ -64,18 +63,14 @@ public class OAuthController {
|
|||||||
*/
|
*/
|
||||||
String clientId = JwtUtils.getAuthClientId();
|
String clientId = JwtUtils.getAuthClientId();
|
||||||
OAuthClientEnum client = OAuthClientEnum.getByClientId(clientId);
|
OAuthClientEnum client = OAuthClientEnum.getByClientId(clientId);
|
||||||
|
|
||||||
switch (client) {
|
switch (client) {
|
||||||
case WEAPP: // 微信小程序
|
case WEAPP: // 微信小程序
|
||||||
jwtTokenPair = weAppService.login(parameters);
|
return Result.success(weAppService.login(parameters));
|
||||||
break;
|
|
||||||
case TEST: // knife4j接口测试文档使用 client_id/client_secret : client/123456
|
case TEST: // knife4j接口测试文档使用 client_id/client_secret : client/123456
|
||||||
return tokenEndpoint.postAccessToken(principal, parameters).getBody();
|
return tokenEndpoint.postAccessToken(principal, parameters).getBody();
|
||||||
default:
|
default:
|
||||||
// oAuth2AccessToken = tokenEndpoint.postAccessToken(principal, parameters).getBody();
|
return Result.success(tokenEndpoint.postAccessToken(principal, parameters).getBody());
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return Result.success(jwtTokenPair);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "注销", notes = "logout")
|
@ApiOperation(value = "注销", notes = "logout")
|
||||||
|
@ -53,6 +53,7 @@ public class WeAppService {
|
|||||||
public JwtTokenPair login(Map<String, String> parameters) {
|
public JwtTokenPair login(Map<String, String> parameters) {
|
||||||
|
|
||||||
String code = parameters.get("code");
|
String code = parameters.get("code");
|
||||||
|
String userInfo = parameters.get("userInfo");
|
||||||
|
|
||||||
if (StrUtil.isBlank(code)) {
|
if (StrUtil.isBlank(code)) {
|
||||||
throw new BizException("code不能为空");
|
throw new BizException("code不能为空");
|
||||||
|
Loading…
Reference in New Issue
Block a user