stjdydayou 4 éve
szülő
commit
95562fb4a4

+ 24 - 6
src/main/java/com/zhiqiyun/open/router/apis/Oauth2Api.java

@@ -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);
 	}

+ 8 - 0
src/main/java/com/zhiqiyun/open/router/request/oauth2/Oauth2SendPhoneValidateCodeRequest.java

@@ -14,4 +14,12 @@ public class Oauth2SendPhoneValidateCodeRequest extends AbstractOapRequest {
 	@ServiceParamField(describe = "手机号码")
 	@NotBlank
 	private String phone;
+
+	@ServiceParamField(describe = "图形验证码唯一标志")
+	@NotBlank
+	private String captchaKey;
+
+	@ServiceParamField(describe = "图形验证码值")
+	@NotBlank
+	private String captchaCode;
 }

+ 2 - 0
src/test/java/com/zhiqiyun/TestSdk.java

@@ -69,6 +69,8 @@ public class TestSdk {
 	public void sendPhoneValidateCode() throws ClientException {
 		Map<String, Object> dataMap = new HashMap<>();
 		dataMap.put("phone", "18073113117");
+		dataMap.put("captchaCode", "u5yzs");
+		dataMap.put("captchaKey", "8f730efa1be59ac28b17b93a611a029d");
 		Response<Map<String, Object>> response = this.getClient().execute("oauth2.send.phone.validate.code", "1.0.0", dataMap);
 		System.out.println(JSON.toJSONString(response));
 	}