mirror of
https://gitee.com/youlaitech/youlai-mall.git
synced 2024-12-23 05:00:25 +08:00
feat(smscode): 阿里云短信抽取成公共API提供给需要发送短信的微服务
Closes #I51WXT
This commit is contained in:
parent
ebfeb4a306
commit
08d90f2d40
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<youlai.version>2.0.0</youlai.version>
|
<youlai.version>2.0.0</youlai.version>
|
||||||
|
<!-- K8S属性配置(可忽略) -->
|
||||||
<service.port>8000</service.port>
|
<service.port>8000</service.port>
|
||||||
<service.nodeport>32005</service.nodeport>
|
<service.nodeport>32005</service.nodeport>
|
||||||
</properties>
|
</properties>
|
||||||
|
@ -11,9 +11,8 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
|
|||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableDiscoveryClient
|
@EnableDiscoveryClient
|
||||||
public class AuthApplication {
|
public class AuthApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
SpringApplication.run(AuthApplication.class, args);
|
SpringApplication.run(AuthApplication.class, args);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.youlai.auth.config;
|
package com.youlai.auth.config;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
@ -32,29 +33,29 @@ public class SwaggerConfiguration {
|
|||||||
@Bean
|
@Bean
|
||||||
public Docket restApi() {
|
public Docket restApi() {
|
||||||
//schema
|
//schema
|
||||||
List<GrantType> grantTypes=new ArrayList<>();
|
List<GrantType> grantTypes = new ArrayList<>();
|
||||||
//密码模式
|
//密码模式
|
||||||
ResourceOwnerPasswordCredentialsGrant resourceOwnerPasswordCredentialsGrant=new ResourceOwnerPasswordCredentialsGrant(passwordTokenUrl);
|
ResourceOwnerPasswordCredentialsGrant resourceOwnerPasswordCredentialsGrant = new ResourceOwnerPasswordCredentialsGrant(passwordTokenUrl);
|
||||||
grantTypes.add(resourceOwnerPasswordCredentialsGrant);
|
grantTypes.add(resourceOwnerPasswordCredentialsGrant);
|
||||||
OAuth oAuth=new OAuthBuilder().name("oauth2")
|
OAuth oAuth = new OAuthBuilder().name("oauth2")
|
||||||
.grantTypes(grantTypes).build();
|
.grantTypes(grantTypes).build();
|
||||||
//context
|
//context
|
||||||
//scope方位
|
//scope方位
|
||||||
List<AuthorizationScope> scopes=new ArrayList<>();
|
List<AuthorizationScope> scopes = new ArrayList<>();
|
||||||
scopes.add(new AuthorizationScope("read","read resources"));
|
scopes.add(new AuthorizationScope("read", "read resources"));
|
||||||
scopes.add(new AuthorizationScope("write","write resources"));
|
scopes.add(new AuthorizationScope("write", "write resources"));
|
||||||
scopes.add(new AuthorizationScope("reads","read all resources"));
|
scopes.add(new AuthorizationScope("reads", "read all resources"));
|
||||||
scopes.add(new AuthorizationScope("writes","write all resources"));
|
scopes.add(new AuthorizationScope("writes", "write all resources"));
|
||||||
|
|
||||||
SecurityReference securityReference=new SecurityReference("oauth2",scopes.toArray(new AuthorizationScope[]{}));
|
SecurityReference securityReference = new SecurityReference("oauth2", scopes.toArray(new AuthorizationScope[]{}));
|
||||||
SecurityContext securityContext=new SecurityContext(Lists.newArrayList(securityReference),PathSelectors.ant("/**"));
|
SecurityContext securityContext = new SecurityContext(Lists.newArrayList(securityReference), PathSelectors.ant("/**"));
|
||||||
//schemas
|
//schemas
|
||||||
List<SecurityScheme> securitySchemes=Lists.newArrayList(oAuth);
|
List<SecurityScheme> securitySchemes = Lists.newArrayList(oAuth);
|
||||||
//securyContext
|
//securyContext
|
||||||
List<SecurityContext> securityContexts=Lists.newArrayList(securityContext);
|
List<SecurityContext> securityContexts = Lists.newArrayList(securityContext);
|
||||||
return new Docket(DocumentationType.SWAGGER_2)
|
return new Docket(DocumentationType.SWAGGER_2)
|
||||||
.select()
|
.select()
|
||||||
.apis(RequestHandlerSelectors.basePackage("com.youlai.auth.controller"))
|
.apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
|
||||||
.paths(PathSelectors.any())
|
.paths(PathSelectors.any())
|
||||||
.build()
|
.build()
|
||||||
.securityContexts(securityContexts)
|
.securityContexts(securityContexts)
|
||||||
@ -69,7 +70,7 @@ public class SwaggerConfiguration {
|
|||||||
.contact(new Contact("有来技术团队", "https://gitee.com/youlaiorg", "youlaitech@163.com"))
|
.contact(new Contact("有来技术团队", "https://gitee.com/youlaiorg", "youlaitech@163.com"))
|
||||||
.license("Open Source")
|
.license("Open Source")
|
||||||
.licenseUrl("https://www.apache.org/licenses/LICENSE-2.0")
|
.licenseUrl("https://www.apache.org/licenses/LICENSE-2.0")
|
||||||
.version("1.0.0")
|
.version("2.0.0")
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.youlai</groupId>
|
<groupId>com.youlai</groupId>
|
||||||
<artifactId>common-web</artifactId>
|
<artifactId>common-web</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -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.result.Result;
|
||||||
import com.youlai.common.sms.service.AliyunSmsService;
|
import com.youlai.common.sms.service.AliyunSmsService;
|
||||||
@ -21,7 +21,7 @@ public class SmsCodeController {
|
|||||||
@ApiOperation(value = "发送短信验证码")
|
@ApiOperation(value = "发送短信验证码")
|
||||||
@ApiImplicitParam(name = "phoneNumber", example = "17621590365", value = "手机号", required = true)
|
@ApiImplicitParam(name = "phoneNumber", example = "17621590365", value = "手机号", required = true)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public Result sendSmsCode(String phoneNumber) {
|
public Result sendSmsCode(String phoneNumber) {
|
||||||
boolean result = aliyunSmsService.sendSmsCode(phoneNumber);
|
boolean result = aliyunSmsService.sendSmsCode(phoneNumber);
|
||||||
return Result.judge(result);
|
return Result.judge(result);
|
||||||
}
|
}
|
@ -1,3 +1,4 @@
|
|||||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||||
com.youlai.common.sms.config.AliyunSmsProperties,\
|
com.youlai.common.sms.config.AliyunSmsProperties,\
|
||||||
com.youlai.common.sms.service.AliyunSmsService
|
com.youlai.common.sms.service.AliyunSmsService, \
|
||||||
|
com.youlai.common.sms.controller.SmsCodeController
|
||||||
|
Loading…
Reference in New Issue
Block a user