新增小程序带用户状态token
This commit is contained in:
parent
f496348f4d
commit
0f94ecdc88
@ -43,7 +43,7 @@ public class WechatFilter implements Filter {
|
||||
private WechatOfficialAccountProperties wechatOfficialAccountProperties;
|
||||
private AntPathMatcher antPathMatcher;
|
||||
|
||||
private static final String WECHAT_LOGIN_URL = String.format("/**%s/sign/login", ISystemConstant.WECHAT_PREFIX);
|
||||
private static final String WECHAT_LOGIN_URL = String.format("/**%s/sign/login**", ISystemConstant.WECHAT_PREFIX);
|
||||
/**
|
||||
* 微信类放行
|
||||
*/
|
||||
|
@ -37,11 +37,11 @@ public class WechatMiniAppFilter implements Filter {
|
||||
/**
|
||||
* 授权登录
|
||||
*/
|
||||
private static final String WECHAT_MINI_APP_AUTH_LOGIN_URL = String.format("/**%s/auth/login", ISystemConstant.WECHAT_MINI_APP_PREFIX);
|
||||
private static final String WECHAT_MINI_APP_AUTH_LOGIN_URL = String.format("/**%s/auth/login**", ISystemConstant.WECHAT_MINI_APP_PREFIX);
|
||||
/**
|
||||
* 认证登录
|
||||
*/
|
||||
private static final String WECHAT_MINI_APP_SIGN_LOGIN_URL = String.format("/**%s/sign/login", ISystemConstant.WECHAT_MINI_APP_PREFIX);
|
||||
private static final String WECHAT_MINI_APP_SIGN_LOGIN_URL = String.format("/**%s/sign/login**", ISystemConstant.WECHAT_MINI_APP_PREFIX);
|
||||
/**
|
||||
* 微信类放行
|
||||
*/
|
||||
|
@ -6,6 +6,7 @@ import com.cm.common.exception.WechatUserInfoException;
|
||||
import com.cm.common.exception.base.SystemException;
|
||||
import com.cm.common.result.SuccessResultData;
|
||||
import com.cm.common.utils.AesUtil;
|
||||
import com.cm.common.utils.http.RestRequestUtil;
|
||||
import com.cm.common.wechat.config.pojo.WechatMiniAppProperties;
|
||||
import com.cm.common.wechat.pojo.WechatMiniAppLoginVO;
|
||||
import com.cm.common.wechat.pojo.WechatMiniAppUserInfo;
|
||||
@ -20,6 +21,8 @@ import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.HttpClientErrorException;
|
||||
import org.springframework.web.client.RestClientException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -88,13 +91,20 @@ public class WechatMiniAppAuthServiceImpl implements IWechatMiniAppAuthService {
|
||||
Map<String, Object> params = new HashMap<>(1);
|
||||
params.put("signInfo", wechatSignInfo);
|
||||
HttpEntity<Map<String, Object>> requestBody = new HttpEntity<>(params);
|
||||
ResponseEntity<Map> result = restTemplate.postForEntity(wechatMiniAppProperties.getBindUserUrl(), requestBody, Map.class);
|
||||
LOG.debug("状态码:{}", result.getStatusCodeValue());
|
||||
if (HttpStatus.OK.value() != result.getStatusCodeValue()) {
|
||||
throw new SearchException("获取Token失败");
|
||||
try {
|
||||
ResponseEntity<Map> result = restTemplate.postForEntity(wechatMiniAppProperties.getBindUserUrl(), requestBody, Map.class);
|
||||
LOG.debug("状态码:{}", result.getStatusCodeValue());
|
||||
if (HttpStatus.OK.value() != result.getStatusCodeValue()) {
|
||||
throw new SearchException("获取Token失败");
|
||||
}
|
||||
Map body = result.getBody();
|
||||
return (String) body.get("data");
|
||||
} catch (HttpClientErrorException e) {
|
||||
if (e.getRawStatusCode() == HttpStatus.BAD_REQUEST.value()) {
|
||||
throw new SearchException(e.getResponseBodyAsString());
|
||||
}
|
||||
throw new SearchException("绑定用户 | 登录失败");
|
||||
}
|
||||
Map body = result.getBody();
|
||||
return (String) body.get("data");
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user