Merge remote-tracking branch 'origin/master'

master
river 4 years ago
commit 1f08ddbf5e
  1. 30
      dq-financial-api/src/main/java/com/daqing/financial/hrauth/UserLoginControllerApi.java
  2. 5
      dq-financial-hrms-auth/pom.xml
  3. 11
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/UserLoginController.java
  4. 1
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/UserLoginService.java
  5. 37
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserLoginServiceImpl.java
  6. 4
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/controller/DeptController.java
  7. 164
      dq-framework-common/dq-framework-common.iml
  8. 17
      dq-framework-common/pom.xml
  9. 9
      dq-framework-common/src/main/java/com/daqing/framework/util/BasePage.java
  10. 15
      dq-framework-common/src/main/java/com/daqing/framework/util/RandomUtil.java
  11. 80
      dq-framework-common/src/main/java/com/daqing/framework/util/SendSMS.java
  12. 4
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/request/UserLoginRequest.java
  13. 3
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/response/HrmsCode.java
  14. 23
      dq-govern-gateway/pom.xml
  15. 3
      dq-govern-gateway/src/main/java/com/daqing/financial/gateway/config/ApiGlobalFilter.java
  16. 142
      dq-govern-gateway/src/main/java/com/daqing/financial/gateway/util/JwtUtil.java
  17. 2
      dq-govern-gateway/src/main/resources/jwt.properties

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

@ -89,6 +89,11 @@
<artifactId>mybatis-plus-boot-starter</artifactId> <artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.0.5</version> <version>3.0.5</version>
</dependency>--> </dependency>-->
<dependency>
<groupId>com.daqing.financial</groupId>
<artifactId>dq-financial-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies> </dependencies>
<dependencyManagement> <dependencyManagement>

@ -1,5 +1,6 @@
package com.daqing.financial.hrauth.controller; package com.daqing.financial.hrauth.controller;
import com.daqing.financial.hrauth.UserLoginControllerApi;
import com.daqing.financial.hrauth.service.UserLoginService; import com.daqing.financial.hrauth.service.UserLoginService;
import com.daqing.framework.domain.hrms.request.LoginRequest; import com.daqing.framework.domain.hrms.request.LoginRequest;
import com.daqing.framework.domain.hrms.request.UserLoginRequest; import com.daqing.framework.domain.hrms.request.UserLoginRequest;
@ -19,7 +20,7 @@ import javax.validation.Valid;
@RestController @RestController
@RequestMapping("/hrms/auth/userlogin") @RequestMapping("/hrms/auth/userlogin")
@Api(tags = {"登录"}) @Api(tags = {"登录"})
public class UserLoginController { public class UserLoginController implements UserLoginControllerApi {
@Autowired @Autowired
private UserLoginService userLoginService; private UserLoginService userLoginService;
@ -36,7 +37,15 @@ public class UserLoginController {
return "Hello"; return "Hello";
} }
@PostMapping("/verifyMobile")
@ApiOperation(value = "验证手机号及验证码")
public ResponseResult verifyMobile(@RequestBody @Valid UserLoginRequest user){
UserLoginRequest result = userLoginService.verifyMobile(user);
return ResponseResult.SUCCESS(result);
}
@PostMapping("/getBackPwd") @PostMapping("/getBackPwd")
@ApiOperation(value = "重置密码")
public ResponseResult getBackPwd(@RequestBody @Valid UserLoginRequest user){ public ResponseResult getBackPwd(@RequestBody @Valid UserLoginRequest user){
boolean result = userLoginService.getBackPwd(user); boolean result = userLoginService.getBackPwd(user);
return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL(); return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL();

@ -12,6 +12,7 @@ import com.daqing.framework.model.response.ResponseResult;
*/ */
public interface UserLoginService extends IService<UserEntity> { public interface UserLoginService extends IService<UserEntity> {
Boolean getBackPwd(UserLoginRequest user); Boolean getBackPwd(UserLoginRequest user);
UserLoginRequest verifyMobile(UserLoginRequest user);
//登录 //登录
ResponseResult login(LoginRequest loginRequest); ResponseResult login(LoginRequest loginRequest);

@ -43,10 +43,10 @@ public class UserLoginServiceImpl extends ServiceImpl<UserLoginDao, UserEntity>
}*/ }*/
/** /**
* 忘记密 * 验证手机号及验证
*/ */
@Override @Override
public Boolean getBackPwd(UserLoginRequest user){ public UserLoginRequest verifyMobile(UserLoginRequest user){
//判断重置密码参数是否为空 //判断重置密码参数是否为空
if(StringUtils.isEmpty(user.getPhoneAccount())){ if(StringUtils.isEmpty(user.getPhoneAccount())){
ExceptionCast.cast(HrmsCode.PHNOE_ACCOUNT_NOT_EMPTY); ExceptionCast.cast(HrmsCode.PHNOE_ACCOUNT_NOT_EMPTY);
@ -54,9 +54,7 @@ public class UserLoginServiceImpl extends ServiceImpl<UserLoginDao, UserEntity>
if(StringUtils.isEmpty(user.getVerifyCode())){ if(StringUtils.isEmpty(user.getVerifyCode())){
ExceptionCast.cast(HrmsCode.VERIFY_CODE_ILLEGAL); ExceptionCast.cast(HrmsCode.VERIFY_CODE_ILLEGAL);
} }
if(StringUtils.isEmpty(user.getNewPwd())){
ExceptionCast.cast(HrmsCode.NEW_PASSWORD_NOT_EMPTY);
}
//校验手机账号是否存在 //校验手机账号是否存在
/* int count = this.count(new QueryWrapper<UserEntity>() /* int count = this.count(new QueryWrapper<UserEntity>()
.eq("phone_account", user.getPhoneAccount()));*/ .eq("phone_account", user.getPhoneAccount()));*/
@ -65,13 +63,38 @@ public class UserLoginServiceImpl extends ServiceImpl<UserLoginDao, UserEntity>
if (count == 0) { if (count == 0) {
ExceptionCast.cast(HrmsCode.PHNOE_ACCOUNT_NOT_EXIST); ExceptionCast.cast(HrmsCode.PHNOE_ACCOUNT_NOT_EXIST);
} }
//根据手机号查询相关信息
UserEntity userEntity = baseMapper.selectByPhoneAccount(user.getPhoneAccount());
//判断验证码是否匹配 //判断验证码是否匹配
String verify = "123456"; String verify = "123456";
if(!verify.equals(user.getVerifyCode())){ if(!verify.equals(user.getVerifyCode())){
ExceptionCast.cast(HrmsCode.VERIFY_CODE_ILLEGAL); ExceptionCast.cast(HrmsCode.VERIFY_CODE_ILLEGAL);
} }
return user;
}
/**
* 重置密码
*/
@Override
public Boolean getBackPwd(UserLoginRequest user){
//判断重置密码参数是否为空
if(StringUtils.isEmpty(user.getNewPwd())){
ExceptionCast.cast(HrmsCode.NEW_PASSWORD_NOT_EMPTY);
}
if(StringUtils.isEmpty(user.getConfirmPwd())){
ExceptionCast.cast(HrmsCode.CONFIRM_PWD_NOT_EMPTY);
}
if(!user.getConfirmPwd().equals(user.getNewPwd())){
ExceptionCast.cast(HrmsCode.TWICE_PWD_DIFFERENT);
}
//根据手机号查询相关信息
UserEntity userEntity = baseMapper.selectByPhoneAccount(user.getPhoneAccount());
//新密码不能与账号相同
if(user.getNewPwd().equals(userEntity.getAccount())){
ExceptionCast.cast(HrmsCode.NEW_PASSWORD_DIFFERENT);
}
String newMD5 = Md5Util.md5(user.getNewPwd()+userEntity.getId()); String newMD5 = Md5Util.md5(user.getNewPwd()+userEntity.getId());
//根据手机号码修改密码 //根据手机号码修改密码

@ -6,6 +6,8 @@ import com.daqing.framework.domain.hrms.DepartmentVO;
import com.daqing.framework.domain.hrms.DeptEntity; import com.daqing.framework.domain.hrms.DeptEntity;
import com.daqing.framework.domain.hrms.request.DeptAddRequest; import com.daqing.framework.domain.hrms.request.DeptAddRequest;
import com.daqing.framework.model.response.ResponseResult; import com.daqing.framework.model.response.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -21,6 +23,7 @@ import java.util.List;
*/ */
@RestController @RestController
@RequestMapping("hrms/dept") @RequestMapping("hrms/dept")
@Api(tags = {"测试swagger"})
public class DeptController implements DeptControllerApi { public class DeptController implements DeptControllerApi {
@Autowired @Autowired
@ -34,6 +37,7 @@ public class DeptController implements DeptControllerApi {
*/ */
@Override @Override
@PostMapping("/save") @PostMapping("/save")
@ApiOperation(value = "111")
//@RequiresPermissions("hrms:dept:save") //@RequiresPermissions("hrms:dept:save")
public ResponseResult save(@RequestBody DeptAddRequest deptAddRequest) { public ResponseResult save(@RequestBody DeptAddRequest deptAddRequest) {
boolean result = deptService.saveDept(deptAddRequest); boolean result = deptService.saveDept(deptAddRequest);

@ -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>

@ -115,23 +115,40 @@
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency> </dependency>
<!--jwt-->
<dependency> <dependency>
<groupId>com.auth0</groupId> <groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId> <artifactId>java-jwt</artifactId>
<version>3.3.0</version> <version>3.3.0</version>
</dependency> </dependency>
<!--fastJson-->
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId> <artifactId>fastjson</artifactId>
<version>1.2.70</version> <version>1.2.70</version>
</dependency> </dependency>
<!--redis-->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId> <artifactId>spring-boot-starter-data-redis</artifactId>
<version> 2.1.8.RELEASE</version> <version> 2.1.8.RELEASE</version>
</dependency> </dependency>
<!--短信-->
<dependency>
<groupId>com.github.suxingli</groupId>
<artifactId>aliyuncs</artifactId>
<version>1.0.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.aliyun/aliyun-java-sdk-dysmsapi -->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
<version>1.1.0</version>
</dependency>
</dependencies> </dependencies>
<dependencyManagement> <dependencyManagement>

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

@ -30,4 +30,8 @@ public class UserLoginRequest implements Serializable {
*/ */
@Pattern(regexp = "^(?=.*[0-9].*)(?=.*[A-Z].*)(?=.*[a-z].*).{6,20}$",message = "密码格式不正确!") @Pattern(regexp = "^(?=.*[0-9].*)(?=.*[A-Z].*)(?=.*[a-z].*).{6,20}$",message = "密码格式不正确!")
private String newPwd; private String newPwd;
/**
* 确认密码
*/
private String confirmPwd;
} }

@ -27,6 +27,9 @@ public enum HrmsCode implements ResultCode {
NEW_PASSWORD_ILLEGAL(false,33004,"新密码格式不正确!"), NEW_PASSWORD_ILLEGAL(false,33004,"新密码格式不正确!"),
VERIFY_CODE_ILLEGAL(false,33005,"验证码不匹配!"), VERIFY_CODE_ILLEGAL(false,33005,"验证码不匹配!"),
PHNOE_ACCOUNT_NOT_EXIST(false,33006,"手机号码不存在!"), PHNOE_ACCOUNT_NOT_EXIST(false,33006,"手机号码不存在!"),
CONFIRM_PWD_NOT_EMPTY(false,33007,"确认密码不能为空!"),
TWICE_PWD_DIFFERENT(false,33008,"两次输入密码不一致!"),
NEW_PASSWORD_DIFFERENT(false,33008,"输入的新密码不能与账号相同!"),
EMP_POSITION_EXSIT(false, 22006, "该职位下已关联员工!"); EMP_POSITION_EXSIT(false, 22006, "该职位下已关联员工!");

@ -20,11 +20,6 @@
</properties> </properties>
<dependencies> <dependencies>
<!--<dependency>
<groupId>com.daqing.framework</groupId>
<artifactId>dq-framework-common</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>-->
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
@ -53,27 +48,11 @@
<version>1.18.12</version> <version>1.18.12</version>
</dependency> </dependency>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.3.0</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId> <artifactId>spring-boot-starter-data-redis</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies> </dependencies>
<dependencyManagement> <dependencyManagement>

@ -1,7 +1,6 @@
package com.daqing.financial.gateway.config; package com.daqing.financial.gateway.config;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.daqing.financial.gateway.util.JwtUtil;
import com.daqing.financial.gateway.util.RedisUtil; import com.daqing.financial.gateway.util.RedisUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
@ -86,7 +85,7 @@ public class ApiGlobalFilter implements GlobalFilter, Ordered {
*/ */
private Long verifyJWT(String token){ private Long verifyJWT(String token){
String id = RedisUtil.get("dq:token:"+token); String id = RedisUtil.get("dq:token:"+token);
return JwtUtil.verifyToken(token); return Long.parseLong(id);
} }
@Override @Override

@ -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…
Cancel
Save