|
|
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.dliyun.oap.framework.annotation.ServiceMethod;
|
|
|
import com.dliyun.oap.framework.annotation.ServiceMethodBean;
|
|
|
+import com.dliyun.oap.framework.request.AbstractOapRequest;
|
|
|
import com.dliyun.oap.framework.response.OapResponse;
|
|
|
import com.zhiqiyun.open.core.service.SystemConfigService;
|
|
|
import com.zhiqiyun.open.router.request.oauth2.*;
|
|
|
@@ -339,23 +340,40 @@ public class Oauth2Api {
|
|
|
return this.getResponse(builder);
|
|
|
}
|
|
|
|
|
|
+ @ServiceMethod(method = "oauth2.get.image.captcha", title = "获取发送手机验证码的图形验证码")
|
|
|
+ public OapResponse oauthGetImageCaptcha(AbstractOapRequest request) throws IOException {
|
|
|
+
|
|
|
+ String hostAddress = this.systemConfigService.getStringValue("OAUTH2_API_CONFIG", "hostAddress");
|
|
|
+ String clientSecret = this.systemConfigService.getStringValue("OAUTH2_API_CONFIG", "clientSecret");
|
|
|
+
|
|
|
+ Request.Builder builder = new Request.Builder();
|
|
|
+ builder.url(String.format("%s/blade-resource/sms/open/endpoint/send-captcha", hostAddress));
|
|
|
+ builder.header("Authorization", "Basic " + clientSecret);
|
|
|
+ builder.header("Content-Type", "application/x-www-form-urlencode");
|
|
|
+ builder.get();
|
|
|
+
|
|
|
+ return this.getResponse(builder);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@ServiceMethod(method = "oauth2.send.phone.validate.code", title = "发送短信验证码")
|
|
|
public OapResponse oauthSendPhoneValidateCode(Oauth2SendPhoneValidateCodeRequest request) throws IOException {
|
|
|
|
|
|
String hostAddress = this.systemConfigService.getStringValue("OAUTH2_API_CONFIG", "hostAddress");
|
|
|
String clientSecret = this.systemConfigService.getStringValue("OAUTH2_API_CONFIG", "clientSecret");
|
|
|
|
|
|
- Map<String, String> paramValues = new HashMap<>();
|
|
|
- paramValues.put("phone", request.getPhone());
|
|
|
+ HttpUrl.Builder urlBuilder = Objects.requireNonNull(HttpUrl.parse(String.format("%s/blade-resource/sms/open/endpoint/send-validate", hostAddress))).newBuilder();
|
|
|
+ urlBuilder.addQueryParameter("phone", request.getPhone());
|
|
|
+ urlBuilder.addQueryParameter("captchaKey", request.getCaptchaKey());
|
|
|
+ urlBuilder.addQueryParameter("captchaCode", request.getCaptchaCode());
|
|
|
|
|
|
- FormBody.Builder formBuilder = new FormBody.Builder();
|
|
|
- paramValues.forEach(formBuilder::add);
|
|
|
|
|
|
+ log.info(">>>>>{}", urlBuilder.build());
|
|
|
Request.Builder builder = new Request.Builder();
|
|
|
- builder.url(String.format("%s/blade-resource/sms/endpoint/send-validate", hostAddress));
|
|
|
+ builder.url(urlBuilder.build());
|
|
|
builder.header("Authorization", "Basic " + clientSecret);
|
|
|
builder.header("Content-Type", "application/x-www-form-urlencode");
|
|
|
- builder.post(formBuilder.build());
|
|
|
+ builder.get();
|
|
|
|
|
|
return this.getResponse(builder);
|
|
|
}
|