From 08d90f2d40a887304904510634dbfd189c1104cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=9D=E5=85=88=E7=91=9E?= <1490493387@qq.com> Date: Sun, 10 Apr 2022 12:04:13 +0800 Subject: [PATCH] =?UTF-8?q?feat(smscode):=20=E9=98=BF=E9=87=8C=E4=BA=91?= =?UTF-8?q?=E7=9F=AD=E4=BF=A1=E6=8A=BD=E5=8F=96=E6=88=90=E5=85=AC=E5=85=B1?= =?UTF-8?q?API=E6=8F=90=E4=BE=9B=E7=BB=99=E9=9C=80=E8=A6=81=E5=8F=91?= =?UTF-8?q?=E9=80=81=E7=9F=AD=E4=BF=A1=E7=9A=84=E5=BE=AE=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #I51WXT --- youlai-auth/pom.xml | 1 + .../java/com/youlai/auth/AuthApplication.java | 3 +- .../auth/config/SwaggerConfiguration.java | 29 ++++++++++--------- youlai-common/common-sms/pom.xml | 1 + .../sms}/controller/SmsCodeController.java | 4 +-- .../main/resources/META-INF/spring.factories | 3 +- 6 files changed, 22 insertions(+), 19 deletions(-) rename {youlai-auth/src/main/java/com/youlai/auth => youlai-common/common-sms/src/main/java/com/youlai/common/sms}/controller/SmsCodeController.java (90%) diff --git a/youlai-auth/pom.xml b/youlai-auth/pom.xml index 96eaca4f4..3dfffe8e0 100644 --- a/youlai-auth/pom.xml +++ b/youlai-auth/pom.xml @@ -13,6 +13,7 @@ 2.0.0 + 8000 32005 diff --git a/youlai-auth/src/main/java/com/youlai/auth/AuthApplication.java b/youlai-auth/src/main/java/com/youlai/auth/AuthApplication.java index 0aa9a4fea..3e38d0bae 100644 --- a/youlai-auth/src/main/java/com/youlai/auth/AuthApplication.java +++ b/youlai-auth/src/main/java/com/youlai/auth/AuthApplication.java @@ -11,9 +11,8 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient public class AuthApplication { + public static void main(String[] args) { - SpringApplication.run(AuthApplication.class, args); - } } diff --git a/youlai-auth/src/main/java/com/youlai/auth/config/SwaggerConfiguration.java b/youlai-auth/src/main/java/com/youlai/auth/config/SwaggerConfiguration.java index 12545b891..162c77445 100644 --- a/youlai-auth/src/main/java/com/youlai/auth/config/SwaggerConfiguration.java +++ b/youlai-auth/src/main/java/com/youlai/auth/config/SwaggerConfiguration.java @@ -1,6 +1,7 @@ package com.youlai.auth.config; import com.google.common.collect.Lists; +import io.swagger.annotations.Api; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -32,29 +33,29 @@ public class SwaggerConfiguration { @Bean public Docket restApi() { //schema - List grantTypes=new ArrayList<>(); + List grantTypes = new ArrayList<>(); //密码模式 - ResourceOwnerPasswordCredentialsGrant resourceOwnerPasswordCredentialsGrant=new ResourceOwnerPasswordCredentialsGrant(passwordTokenUrl); + ResourceOwnerPasswordCredentialsGrant resourceOwnerPasswordCredentialsGrant = new ResourceOwnerPasswordCredentialsGrant(passwordTokenUrl); grantTypes.add(resourceOwnerPasswordCredentialsGrant); - OAuth oAuth=new OAuthBuilder().name("oauth2") + OAuth oAuth = new OAuthBuilder().name("oauth2") .grantTypes(grantTypes).build(); //context //scope方位 - List scopes=new ArrayList<>(); - scopes.add(new AuthorizationScope("read","read resources")); - scopes.add(new AuthorizationScope("write","write resources")); - scopes.add(new AuthorizationScope("reads","read all resources")); - scopes.add(new AuthorizationScope("writes","write all resources")); + List scopes = new ArrayList<>(); + scopes.add(new AuthorizationScope("read", "read resources")); + scopes.add(new AuthorizationScope("write", "write resources")); + scopes.add(new AuthorizationScope("reads", "read all resources")); + scopes.add(new AuthorizationScope("writes", "write all resources")); - SecurityReference securityReference=new SecurityReference("oauth2",scopes.toArray(new AuthorizationScope[]{})); - SecurityContext securityContext=new SecurityContext(Lists.newArrayList(securityReference),PathSelectors.ant("/**")); + SecurityReference securityReference = new SecurityReference("oauth2", scopes.toArray(new AuthorizationScope[]{})); + SecurityContext securityContext = new SecurityContext(Lists.newArrayList(securityReference), PathSelectors.ant("/**")); //schemas - List securitySchemes=Lists.newArrayList(oAuth); + List securitySchemes = Lists.newArrayList(oAuth); //securyContext - List securityContexts=Lists.newArrayList(securityContext); + List securityContexts = Lists.newArrayList(securityContext); return new Docket(DocumentationType.SWAGGER_2) .select() - .apis(RequestHandlerSelectors.basePackage("com.youlai.auth.controller")) + .apis(RequestHandlerSelectors.withClassAnnotation(Api.class)) .paths(PathSelectors.any()) .build() .securityContexts(securityContexts) @@ -69,7 +70,7 @@ public class SwaggerConfiguration { .contact(new Contact("有来技术团队", "https://gitee.com/youlaiorg", "youlaitech@163.com")) .license("Open Source") .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0") - .version("1.0.0") + .version("2.0.0") .build(); } diff --git a/youlai-common/common-sms/pom.xml b/youlai-common/common-sms/pom.xml index 6cce4c6c9..6b676b828 100644 --- a/youlai-common/common-sms/pom.xml +++ b/youlai-common/common-sms/pom.xml @@ -20,6 +20,7 @@ com.youlai common-web + true diff --git a/youlai-auth/src/main/java/com/youlai/auth/controller/SmsCodeController.java b/youlai-common/common-sms/src/main/java/com/youlai/common/sms/controller/SmsCodeController.java similarity index 90% rename from youlai-auth/src/main/java/com/youlai/auth/controller/SmsCodeController.java rename to youlai-common/common-sms/src/main/java/com/youlai/common/sms/controller/SmsCodeController.java index a1a823f4c..baf6f1aa4 100644 --- a/youlai-auth/src/main/java/com/youlai/auth/controller/SmsCodeController.java +++ b/youlai-common/common-sms/src/main/java/com/youlai/common/sms/controller/SmsCodeController.java @@ -1,4 +1,4 @@ -package com.youlai.auth.controller; +package com.youlai.common.sms.controller; import com.youlai.common.result.Result; import com.youlai.common.sms.service.AliyunSmsService; @@ -21,7 +21,7 @@ public class SmsCodeController { @ApiOperation(value = "发送短信验证码") @ApiImplicitParam(name = "phoneNumber", example = "17621590365", value = "手机号", required = true) @PostMapping - public Result sendSmsCode(String phoneNumber) { + public Result sendSmsCode(String phoneNumber) { boolean result = aliyunSmsService.sendSmsCode(phoneNumber); return Result.judge(result); } diff --git a/youlai-common/common-sms/src/main/resources/META-INF/spring.factories b/youlai-common/common-sms/src/main/resources/META-INF/spring.factories index e7f96fe79..68c3964f8 100644 --- a/youlai-common/common-sms/src/main/resources/META-INF/spring.factories +++ b/youlai-common/common-sms/src/main/resources/META-INF/spring.factories @@ -1,3 +1,4 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ com.youlai.common.sms.config.AliyunSmsProperties,\ - com.youlai.common.sms.service.AliyunSmsService + com.youlai.common.sms.service.AliyunSmsService, \ + com.youlai.common.sms.controller.SmsCodeController