feat:微信小程序用户登录逻辑

This commit is contained in:
haoxr 2021-06-08 01:27:17 +08:00
parent e66a8445e8
commit cd73d8bb9b
3 changed files with 3 additions and 11 deletions

View File

@ -1,10 +1,6 @@
package com.youlai.mall.oms.api;
import com.youlai.common.result.Result;
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

View File

@ -53,7 +53,6 @@ public class OAuthController {
@ApiIgnore Principal principal,
@ApiIgnore @RequestParam Map<String, String> parameters
) throws HttpRequestMethodNotSupportedException {
JwtTokenPair jwtTokenPair = new JwtTokenPair();
/**
* 获取登录认证的客户端ID
@ -64,18 +63,14 @@ public class OAuthController {
*/
String clientId = JwtUtils.getAuthClientId();
OAuthClientEnum client = OAuthClientEnum.getByClientId(clientId);
switch (client) {
case WEAPP: // 微信小程序
jwtTokenPair = weAppService.login(parameters);
break;
return Result.success(weAppService.login(parameters));
case TEST: // knife4j接口测试文档使用 client_id/client_secret : client/123456
return tokenEndpoint.postAccessToken(principal, parameters).getBody();
default:
// oAuth2AccessToken = tokenEndpoint.postAccessToken(principal, parameters).getBody();
break;
return Result.success(tokenEndpoint.postAccessToken(principal, parameters).getBody());
}
return Result.success(jwtTokenPair);
}
@ApiOperation(value = "注销", notes = "logout")

View File

@ -53,6 +53,7 @@ public class WeAppService {
public JwtTokenPair login(Map<String, String> parameters) {
String code = parameters.get("code");
String userInfo = parameters.get("userInfo");
if (StrUtil.isBlank(code)) {
throw new BizException("code不能为空");