commit
1f08ddbf5e
17 changed files with 446 additions and 104 deletions
@ -0,0 +1,30 @@ |
|||||||
|
package com.daqing.financial.hrauth; |
||||||
|
|
||||||
|
import com.daqing.framework.domain.hrms.request.LoginRequest; |
||||||
|
import com.daqing.framework.domain.hrms.request.UserLoginRequest; |
||||||
|
import com.daqing.framework.model.response.ResponseResult; |
||||||
|
import io.swagger.annotations.Api; |
||||||
|
import io.swagger.annotations.ApiOperation; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author: gongsj. |
||||||
|
* @Description: 登录controllerApi定义 |
||||||
|
* @Date:Created in 2020/09/07 11:33. |
||||||
|
* @Modified By: |
||||||
|
*/ |
||||||
|
@Api(value = "登录相关操作", tags = "提供登录相关操作") |
||||||
|
public interface UserLoginControllerApi { |
||||||
|
|
||||||
|
/** |
||||||
|
* 验证手机号及验证码 |
||||||
|
*/ |
||||||
|
@ApiOperation(value = "验证手机号及验证码", notes = "验证手机号及验证码") |
||||||
|
ResponseResult verifyMobile(UserLoginRequest user); |
||||||
|
|
||||||
|
@ApiOperation(value = "重置密码") |
||||||
|
ResponseResult getBackPwd(UserLoginRequest user); |
||||||
|
|
||||||
|
@ApiOperation(value = "登录") |
||||||
|
ResponseResult login(LoginRequest loginRequest); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,164 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<module version="4"> |
||||||
|
<component name="ExternalSystem" externalSystem="Maven" /> |
||||||
|
<component name="FacetManager"> |
||||||
|
<facet type="Spring" name="Spring"> |
||||||
|
<configuration /> |
||||||
|
</facet> |
||||||
|
<facet type="web" name="Web"> |
||||||
|
<configuration> |
||||||
|
<webroots /> |
||||||
|
</configuration> |
||||||
|
</facet> |
||||||
|
</component> |
||||||
|
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7"> |
||||||
|
<output url="file://$MODULE_DIR$/target/classes" /> |
||||||
|
<output-test url="file://$MODULE_DIR$/target/test-classes" /> |
||||||
|
<content url="file://$MODULE_DIR$"> |
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> |
||||||
|
<excludeFolder url="file://$MODULE_DIR$/target" /> |
||||||
|
</content> |
||||||
|
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" /> |
||||||
|
<orderEntry type="sourceFolder" forTests="false" /> |
||||||
|
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:8.0.17" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:3.6.1" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-boot-starter:3.0.7.1" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus:3.0.7.1" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:2.1.0.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.1.0.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:2.1.0.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:3.2.0" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework:spring-jdbc:5.1.2.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-generator:3.0.7.1" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-extension:3.0.7.1" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-core:3.0.7.1" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-annotation:3.0.7.1" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.github.jsqlparser:jsqlparser:1.3" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.mybatis:mybatis-spring:1.3.2" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.mybatis:mybatis:3.4.6" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.18.12" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger2:2.7.0" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: io.swagger:swagger-annotations:1.5.13" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: io.swagger:swagger-models:1.5.13" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.8.5" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: io.springfox:springfox-spi:2.7.0" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: io.springfox:springfox-core:2.7.0" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: net.bytebuddy:byte-buddy:1.6.14" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: io.springfox:springfox-schema:2.7.0" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-common:2.7.0" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: io.springfox:springfox-spring-web:2.7.0" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.reflections:reflections:0.9.11" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.javassist:javassist:3.21.0-GA" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.3.3" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.24" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework:spring-context:4.0.9.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework:spring-aop:4.0.9.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: aopalliance:aopalliance:1.0" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-metadata:1.2.0.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.mapstruct:mapstruct:1.1.0.Final" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-ui:2.7.0" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:2.1.8.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.1.8.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:2.1.8.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.2.3" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.2.3" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-to-slf4j:2.11.2" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.11.2" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.28" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: javax.annotation:javax.annotation-api:1.3.2" level="project" /> |
||||||
|
<orderEntry type="library" scope="RUNTIME" name="Maven: org.yaml:snakeyaml:1.23" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:2.1.8.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.9.9" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.9" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.9.9" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:2.1.8.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:9.0.24" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:9.0.24" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:9.0.24" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.hibernate.validator:hibernate-validator:6.0.17.Final" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: javax.validation:validation-api:2.0.1.Final" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.3.2.Final" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.1.9.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.1.9.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.servlet:servlet-api:2.5" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework:spring-web:5.2.8.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework:spring-beans:5.2.8.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework:spring-core:5.2.8.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.2.8.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.google.guava:guava:24.0-jre" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:1.3.9" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.checkerframework:checker-compat-qual:2.0.0" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.google.errorprone:error_prone_annotations:2.1.3" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.google.j2objc:j2objc-annotations:1.1" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.codehaus.mojo:animal-sniffer-annotations:1.14" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-discovery:2.1.0.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.alibaba.cloud:spring-cloud-alibaba-nacos-discovery:2.1.0.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.alibaba.nacos:nacos-client:1.1.1" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.alibaba.nacos:nacos-common:1.1.1" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: commons-io:commons-io:2.2" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.4" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.alibaba.nacos:nacos-api:1.1.1" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: io.prometheus:simpleclient:0.5.0" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-commons:2.1.2.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-crypto:5.1.5.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-context:2.1.2.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter-netflix-ribbon:2.1.2.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter:2.1.2.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-rsa:1.0.7.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.bouncycastle:bcpkix-jdk15on:1.60" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.bouncycastle:bcprov-jdk15on:1.60" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-netflix-ribbon:2.1.2.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-netflix-archaius:2.1.2.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter-netflix-archaius:2.1.2.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.netflix.archaius:archaius-core:0.7.6" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: commons-configuration:commons-configuration:1.8" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.netflix.ribbon:ribbon:2.3.0" level="project" /> |
||||||
|
<orderEntry type="library" scope="RUNTIME" name="Maven: com.netflix.ribbon:ribbon-transport:2.3.0" level="project" /> |
||||||
|
<orderEntry type="library" scope="RUNTIME" name="Maven: io.reactivex:rxnetty-contexts:0.4.9" level="project" /> |
||||||
|
<orderEntry type="library" scope="RUNTIME" name="Maven: io.reactivex:rxnetty-servo:0.4.9" level="project" /> |
||||||
|
<orderEntry type="library" scope="RUNTIME" name="Maven: com.netflix.hystrix:hystrix-core:1.4.3" level="project" /> |
||||||
|
<orderEntry type="library" scope="RUNTIME" name="Maven: javax.inject:javax.inject:1" level="project" /> |
||||||
|
<orderEntry type="library" scope="RUNTIME" name="Maven: io.reactivex:rxnetty:0.4.9" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.netflix.ribbon:ribbon-core:2.3.0" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.netflix.ribbon:ribbon-httpclient:2.3.0" level="project" /> |
||||||
|
<orderEntry type="library" scope="RUNTIME" name="Maven: commons-collections:commons-collections:3.2.2" level="project" /> |
||||||
|
<orderEntry type="library" scope="RUNTIME" name="Maven: org.apache.httpcomponents:httpclient:4.2.1" level="project" /> |
||||||
|
<orderEntry type="library" scope="RUNTIME" name="Maven: org.apache.httpcomponents:httpcore:4.2.1" level="project" /> |
||||||
|
<orderEntry type="library" scope="RUNTIME" name="Maven: commons-logging:commons-logging:1.1.1" level="project" /> |
||||||
|
<orderEntry type="library" scope="RUNTIME" name="Maven: com.sun.jersey:jersey-client:1.19.1" level="project" /> |
||||||
|
<orderEntry type="library" scope="RUNTIME" name="Maven: com.sun.jersey:jersey-core:1.19.1" level="project" /> |
||||||
|
<orderEntry type="library" scope="RUNTIME" name="Maven: javax.ws.rs:jsr311-api:1.1.1" level="project" /> |
||||||
|
<orderEntry type="library" scope="RUNTIME" name="Maven: com.sun.jersey.contribs:jersey-apache-client4:1.19.1" level="project" /> |
||||||
|
<orderEntry type="library" scope="RUNTIME" name="Maven: com.netflix.servo:servo-core:0.10.1" level="project" /> |
||||||
|
<orderEntry type="library" scope="RUNTIME" name="Maven: com.netflix.servo:servo-internal:0.10.1" level="project" /> |
||||||
|
<orderEntry type="library" scope="RUNTIME" name="Maven: com.netflix.netflix-commons:netflix-commons-util:0.1.1" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.netflix.ribbon:ribbon-loadbalancer:2.3.0" level="project" /> |
||||||
|
<orderEntry type="library" scope="RUNTIME" name="Maven: com.netflix.netflix-commons:netflix-statistics:0.1.1" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: io.reactivex:rxjava:1.2.0" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-config:2.1.0.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.alibaba.cloud:spring-cloud-alibaba-nacos-config:2.1.0.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.auth0:java-jwt:3.3.0" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.2" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.2" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.11" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.70" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-data-redis:2.1.8.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-redis:2.1.10.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-keyvalue:2.1.10.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-commons:2.1.10.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework:spring-tx:5.1.9.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework:spring-oxm:5.1.9.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.springframework:spring-context-support:5.1.9.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: io.lettuce:lettuce-core:5.1.8.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: io.netty:netty-common:4.1.38.Final" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: io.netty:netty-handler:4.1.38.Final" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: io.netty:netty-buffer:4.1.38.Final" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: io.netty:netty-codec:4.1.38.Final" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: io.netty:netty-transport:4.1.38.Final" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: io.netty:netty-resolver:4.1.38.Final" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: io.projectreactor:reactor-core:3.2.11.RELEASE" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.reactivestreams:reactive-streams:1.0.2" level="project" /> |
||||||
|
</component> |
||||||
|
</module> |
@ -0,0 +1,9 @@ |
|||||||
|
package com.daqing.framework.util; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
//分页工具类
|
||||||
|
@Data |
||||||
|
public class BasePage { |
||||||
|
private int page = 0; |
||||||
|
private int size = 10; |
||||||
|
} |
@ -0,0 +1,15 @@ |
|||||||
|
package com.daqing.framework.util; |
||||||
|
|
||||||
|
import java.util.Random; |
||||||
|
|
||||||
|
public class RandomUtil { |
||||||
|
public static String getRandomNum(int num) { |
||||||
|
String str = "0123456789"; |
||||||
|
StringBuilder sb = new StringBuilder(4); |
||||||
|
for (int i = 0; i < num; i++) { |
||||||
|
char ch = str.charAt(new Random().nextInt(str.length())); |
||||||
|
sb.append(ch); |
||||||
|
} |
||||||
|
return sb.toString(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,80 @@ |
|||||||
|
package com.daqing.framework.util; |
||||||
|
|
||||||
|
import com.aliyuncs.DefaultAcsClient; |
||||||
|
import com.aliyuncs.IAcsClient; |
||||||
|
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest; |
||||||
|
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse; |
||||||
|
import com.aliyuncs.http.MethodType; |
||||||
|
import com.aliyuncs.profile.DefaultProfile; |
||||||
|
import com.aliyuncs.profile.IClientProfile; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
|
||||||
|
@Slf4j |
||||||
|
public class SendSMS { |
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args){ |
||||||
|
String mobile="13888888888";//需要接受短信验证码的手机号
|
||||||
|
String sendTemplate="SMS_134188888";//短信模板ID,需要去阿里云平台申请,审核通过后方能使用,通常是以"SMS_"开头字符串
|
||||||
|
String code = (int)((Math.random() * 9 + 1) * 100000)+ "";//要发送给用户的短信验证码,行业通常使用六位纯数字
|
||||||
|
|
||||||
|
String result= sendCode(mobile,sendTemplate,code); |
||||||
|
if(result!=null&&"OK".equals(result.toUpperCase())){ |
||||||
|
System.out.println("短信发送成功"); |
||||||
|
}else{ |
||||||
|
System.out.println("短信发送失败"); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
/** |
||||||
|
* 通过阿里云平台发送短信,如果发送成功,返回"OK" ;否则返回的是错误信息 |
||||||
|
* @param mobile 要接收该短信的用户手机号 |
||||||
|
* @param sendTemplate 短信模板id,此处将其封装为变量,是为了由该方法的调用者决定自己来发送哪种类型的短信验证码,比如注册,重置密码类的 |
||||||
|
* @param code 您将发送到用户手机的短信验证码 |
||||||
|
*/ |
||||||
|
public static String sendCode(String mobile,String sendTemplate,String code){ |
||||||
|
//请求失败这里会抛ClientException异常
|
||||||
|
String result=""; |
||||||
|
try { |
||||||
|
//设置超时时间-可自行调整
|
||||||
|
System.setProperty("sun.net.client.defaultConnectTimeout", "10000"); |
||||||
|
System.setProperty("sun.net.client.defaultReadTimeout", "10000"); |
||||||
|
//初始化ascClient需要的几个参数
|
||||||
|
final String product = "Dysmsapi";//短信API产品名称(短信产品名固定,无需修改)
|
||||||
|
final String domain = "dysmsapi.aliyuncs.com";//短信API产品域名(接口地址固定,无需修改)
|
||||||
|
//替换成你的AK
|
||||||
|
final String accessKeyId = "LTAI3IJDEVkXgY0E";//你的accessKeyId,参考本文档步骤2
|
||||||
|
final String accessKeySecret = "kmnOeksdTEauInvea9Hf6dqssDdvho";//你的accessKeySecret,参考本文档步骤2
|
||||||
|
//初始化ascClient,暂时不支持多region(请勿修改)
|
||||||
|
IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, |
||||||
|
accessKeySecret); |
||||||
|
DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", product, domain); |
||||||
|
IAcsClient acsClient = new DefaultAcsClient(profile); |
||||||
|
//组装请求对象
|
||||||
|
SendSmsRequest request = new SendSmsRequest(); |
||||||
|
//使用post提交
|
||||||
|
request.setMethod(MethodType.POST); |
||||||
|
//必填:待发送手机号。支持以逗号分隔的形式进行批量调用,批量上限为1000个手机号码,批量调用相对于单条调用及时性稍有延迟,验证码类型的短信推荐使用单条调用的方式;发送国际/港澳台消息时,接收号码格式为00+国际区号+号码,如“0085200000000”
|
||||||
|
request.setPhoneNumbers(mobile); |
||||||
|
//必填:短信签名-可在短信控制台中找到
|
||||||
|
request.setSignName("");//注意要与你在短信控制台中的签名一致
|
||||||
|
//必填:短信模板-可在短信控制台中找到
|
||||||
|
request.setTemplateCode(sendTemplate); |
||||||
|
//可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为
|
||||||
|
//友情提示:如果JSON中需要带换行符,请参照标准的JSON协议对换行符的要求,比如短信内容中包含\r\n的情况在JSON中需要表示成\\r\\n,否则会导致JSON在服务端解析失败
|
||||||
|
// request.setTemplateParam("{\"name\":\"Tom\", \"code\":\"123\"}");
|
||||||
|
request.setTemplateParam("{\"code\":\""+code+"\"}"); |
||||||
|
//可选-上行短信扩展码(扩展码字段控制在7位或以下,无特殊需求用户请忽略此字段)
|
||||||
|
//request.setSmsUpExtendCode("90997");
|
||||||
|
//可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者
|
||||||
|
// request.setOutId("yourOutId");
|
||||||
|
|
||||||
|
SendSmsResponse response = acsClient.getAcsResponse(request); |
||||||
|
result=response.getCode(); |
||||||
|
} catch (Exception e) { |
||||||
|
result=e.getMessage(); |
||||||
|
} |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -1,71 +1,71 @@ |
|||||||
package com.daqing.financial.gateway.util; |
//package com.daqing.financial.gateway.util;
|
||||||
|
//
|
||||||
|
//
|
||||||
import com.auth0.jwt.JWT; |
//import com.auth0.jwt.JWT;
|
||||||
import com.auth0.jwt.algorithms.Algorithm; |
//import com.auth0.jwt.algorithms.Algorithm;
|
||||||
import com.daqing.financial.gateway.SpringContextHolder; |
//import com.daqing.financial.gateway.SpringContextHolder;
|
||||||
|
//
|
||||||
import java.util.Date; |
//import java.util.Date;
|
||||||
import java.util.Set; |
//import java.util.Set;
|
||||||
|
//
|
||||||
/** |
///**
|
||||||
* @author zcw |
// * @author zcw
|
||||||
* @version 1.0 |
// * @version 1.0
|
||||||
* @date 2019/11/23 11:06 |
// * @date 2019/11/23 11:06
|
||||||
* @description jwt工具类 |
// * @description jwt工具类
|
||||||
*/ |
// */
|
||||||
public class JwtUtil { |
//public class JwtUtil {
|
||||||
|
//
|
||||||
private final static Algorithm algorithm = SpringContextHolder.getBean("algorithm", Algorithm.class); |
// private final static Algorithm algorithm = SpringContextHolder.getBean("algorithm", Algorithm.class);
|
||||||
|
//
|
||||||
//private final static OdcProperties properties = SpringContextHolder.getBean("odcProperties", OdcProperties.class);
|
// //private final static OdcProperties properties = SpringContextHolder.getBean("odcProperties", OdcProperties.class);
|
||||||
|
//
|
||||||
/** |
// /**
|
||||||
* 创建token |
// * 创建token
|
||||||
* |
// *
|
||||||
* @param userId; |
// * @param userId;
|
||||||
* @param timeout; 单位是秒 |
// * @param timeout; 单位是秒
|
||||||
*/ |
// */
|
||||||
public static String createJwtToken(Long userId, long timeout) { |
// public static String createJwtToken(Long userId, long timeout) {
|
||||||
return JWT.create() |
// return JWT.create()
|
||||||
.withClaim("member", userId) |
// .withClaim("member", userId)
|
||||||
.withExpiresAt(new Date(System.currentTimeMillis() + timeout * 1000)) |
// .withExpiresAt(new Date(System.currentTimeMillis() + timeout * 1000))
|
||||||
.sign(algorithm); |
// .sign(algorithm);
|
||||||
} |
// }
|
||||||
|
//
|
||||||
/** |
// /**
|
||||||
* token正确且有效,则返回userId |
// * token正确且有效,则返回userId
|
||||||
*/ |
// */
|
||||||
public static Long verifyToken(String token) { |
// public static Long verifyToken(String token) {
|
||||||
try { |
// try {
|
||||||
String noBearerToken = token.replaceFirst("Bearer ", ""); |
// String noBearerToken = token.replaceFirst("Bearer ", "");
|
||||||
Long userId = JWT.require(algorithm) |
// Long userId = JWT.require(algorithm)
|
||||||
.build() |
// .build()
|
||||||
.verify(noBearerToken) |
// .verify(noBearerToken)
|
||||||
.getClaim("member") |
// .getClaim("member")
|
||||||
.asLong(); |
// .asLong();
|
||||||
if (RedisUtil.get(getRedisKey(userId, noBearerToken)) != null) { |
// if (RedisUtil.get(getRedisKey(userId, noBearerToken)) != null) {
|
||||||
return userId; |
// return userId;
|
||||||
} |
// }
|
||||||
} catch (Exception e) { |
// } catch (Exception e) {
|
||||||
e.printStackTrace(); |
// e.printStackTrace();
|
||||||
return null; |
// return null;
|
||||||
} |
// }
|
||||||
return null; |
// return null;
|
||||||
} |
// }
|
||||||
|
//
|
||||||
public static String getRedisKey(Long userId, String token) { |
// public static String getRedisKey(Long userId, String token) {
|
||||||
return String.format("dq:token:%d:%s", userId, token); |
// return String.format("dq:token:%d:%s", userId, token);
|
||||||
} |
// }
|
||||||
|
//
|
||||||
public static void putTokenToRedis(Long userId, String token, long times) { |
// public static void putTokenToRedis(Long userId, String token, long times) {
|
||||||
RedisUtil.setEx(getRedisKey(userId, token), "nothing", times); |
// RedisUtil.setEx(getRedisKey(userId, token), "nothing", times);
|
||||||
} |
// }
|
||||||
|
//
|
||||||
public static void removeTokenByUserId(Long userId) { |
// public static void removeTokenByUserId(Long userId) {
|
||||||
Set<String> tokenSet = RedisUtil.keys(getRedisKey(userId, "*")); |
// Set<String> tokenSet = RedisUtil.keys(getRedisKey(userId, "*"));
|
||||||
for (String key : tokenSet) { |
// for (String key : tokenSet) {
|
||||||
RedisUtil.del(key); |
// RedisUtil.del(key);
|
||||||
} |
// }
|
||||||
} |
// }
|
||||||
} |
//}
|
||||||
|
@ -1 +1 @@ |
|||||||
jwt.ignoreUrlList=/apiHrmsAuth/hrms/auth/userlogin/getBackPwd,/apiHrmsAuth/hrms/auth/userlogin/login |
jwt.ignoreUrlList=/apiHrmsAuth/hrms/auth/userlogin/getBackPwd,/apiHrmsAuth/hrms/auth/userlogin/login,/apiHrmsAuth/hrms/auth/userlogin/verifyMobile |
Loading…
Reference in new issue