shijie 4 years ago
commit 58a26d8951
  1. 35
      .gitignore
  2. 23
      dq-financial-api/pom.xml
  3. 20
      dq-financial-crms-auth/pom.xml
  4. 8
      dq-financial-guarantee/pom.xml
  5. 4
      dq-financial-hrms-auth/pom.xml
  6. 8
      dq-financial-hrms/pom.xml
  7. 4
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/controller/EmployeeController.java
  8. 40
      dq-framework-common/pom.xml
  9. 2
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/EmployeeEntity.java
  10. 18
      dq-framework-utils/pom.xml
  11. 1
      dq-framework-utils/src/main/java/com/daqing/framework/utils/PageUtils.java
  12. 9
      dq-framework-utils/src/main/java/com/daqing/framework/utils/Query.java
  13. 16
      dq-govern-gateway/pom.xml
  14. 38
      dq-govern-gateway/src/main/java/com/daqing/financial/gateway/config/ApiGlobalFilter.java
  15. 7
      dq-govern-gateway/src/main/java/com/daqing/financial/gateway/exception/DqException.java
  16. 5
      dq-govern-gateway/src/main/java/com/daqing/financial/gateway/util/JwtUtil.java
  17. 2
      dq-govern-gateway/src/main/resources/application.yml
  18. 2
      dq-govern-gateway/src/main/resources/jwt.properties

35
.gitignore vendored

@ -0,0 +1,35 @@
target/
logs/
.mvn/
mvnw
mvnw.cmd
!**/src/main/**
!**/src/test/**
src/main/resources/docs/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
### VS Code ###
.vscode/

@ -15,31 +15,26 @@
<description>系统API统一定义</description>
<dependencies>
<dependency>
<!-- <dependency>
<groupId>com.daqing.framework</groupId>
<artifactId>dq-framework-common</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependency>-->
<dependency>
<groupId>com.daqing.framework</groupId>
<artifactId>dq-framework-model</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<!--<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>-->
<!--<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.1.8.RELEASE</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.7.0</version>
</dependency>
</dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>

@ -20,25 +20,33 @@
</properties>
<dependencies>
<dependency>
<!--<dependency>
<groupId>com.daqing.framework</groupId>
<artifactId>dq-framework-common</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependency>-->
<dependency>
<groupId>com.daqing.framework</groupId>
<artifactId>dq-framework-model</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<!-- <dependency>
<groupId>com.daqing.financial</groupId>
<artifactId>dq-govern-gateway</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>-->
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependency>-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<!--<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-security</artifactId>
</dependency>
@ -51,7 +59,7 @@
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.0</version>
</dependency>
</dependency>-->
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>

@ -20,20 +20,20 @@
</properties>
<dependencies>
<dependency>
<!-- <dependency>
<groupId>com.daqing.framework</groupId>
<artifactId>dq-framework-common</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependency>-->
<dependency>
<groupId>com.daqing.framework</groupId>
<artifactId>dq-framework-model</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependency>-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>

@ -20,11 +20,11 @@
</properties>
<dependencies>
<dependency>
<!-- <dependency>
<groupId>com.daqing.framework</groupId>
<artifactId>dq-framework-common</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependency>-->
<dependency>
<groupId>com.daqing.framework</groupId>
<artifactId>dq-framework-model</artifactId>

@ -20,21 +20,21 @@
</properties>
<dependencies>
<dependency>
<!--<dependency>
<groupId>com.daqing.framework</groupId>
<artifactId>dq-framework-common</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependency>-->
<dependency>
<groupId>com.daqing.framework</groupId>
<artifactId>dq-framework-model</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<!-- <dependency>
<groupId>com.daqing.framework</groupId>
<artifactId>dq-framework-utils</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependency>-->
<dependency>
<groupId>com.daqing.financial</groupId>
<artifactId>dq-financial-api</artifactId>

@ -10,9 +10,9 @@ import com.daqing.framework.utils.PageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
@ -33,7 +33,7 @@ public class EmployeeController implements EmployeeControllerApi {
//@RequiresPermissions("hrms:employee:info")
public ResponseResult list(@RequestParam("page") Integer page,
@RequestParam("size") Integer size,
EmployeeEntity employee) {
@Valid EmployeeEntity employee) {
PageUtils data = employeeService.queryPage(page, size, employee);
return new ResponseResult<PageUtils>().SUCCESS(data);
}

@ -27,16 +27,53 @@
<artifactId>mysql-connector-java</artifactId>
<version>8.0.17</version>
</dependency>
<!--mybatis-plus-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.3.1</version>
<version>3.0.7.1</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>3.0.7.1</version>
</dependency>
<!--<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.3.1</version>
</dependency>-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
</dependency>
<!--swagger-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.1.8.RELEASE</version>
<!--<exclusions>
&lt;!&ndash;排除jackson&ndash;&gt;
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</exclusion>
</exclusions>-->
</dependency>
<!--<scope>provided</scope> 设置成目标环境已存在,打包的时候不会带上这个jar-->
<dependency>
<groupId>javax.servlet</groupId>
@ -49,6 +86,7 @@
<artifactId>spring-web</artifactId>
<version>5.2.8.RELEASE</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>

@ -3,10 +3,10 @@ package com.daqing.framework.domain.hrms;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 记录员工的基本信息如姓名电话部门等

@ -48,5 +48,23 @@
<version>9.0.37</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.1.9.RELEASE</version>
<scope>compile</scope>
</dependency>
<!-- <dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-core</artifactId>
<version>3.0.7.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-extension</artifactId>
<version>3.0.7.1</version>
<scope>compile</scope>
</dependency>-->
</dependencies>
</project>

@ -8,6 +8,7 @@
package com.daqing.framework.utils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import java.io.Serializable;

@ -9,7 +9,6 @@
package com.daqing.framework.utils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.daqing.framework.model.Constant;
import com.daqing.framework.xss.SQLFilter;
@ -53,13 +52,13 @@ public class Query<T> {
//前端字段排序
if (StringUtils.isNotEmpty(orderField) && StringUtils.isNotEmpty(order)) {
/*if (StringUtils.isNotEmpty(orderField) && StringUtils.isNotEmpty(order)) {
if (Constant.ASC.equalsIgnoreCase(order)) {
return page.addOrder(OrderItem.asc(orderField));
} else {
return page.addOrder(OrderItem.desc(orderField));
}
}
}*/
//没有排序字段,则不排序
if (StringUtils.isBlank(defaultOrderField)) {
@ -67,11 +66,11 @@ public class Query<T> {
}
//默认排序
if (isAsc) {
/* if (isAsc) {
page.addOrder(OrderItem.asc(defaultOrderField));
} else {
page.addOrder(OrderItem.desc(defaultOrderField));
}
}*/
return page;
}

@ -20,11 +20,11 @@
</properties>
<dependencies>
<dependency>
<!--<dependency>
<groupId>com.daqing.framework</groupId>
<artifactId>dq-framework-common</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependency>-->
<dependency>
<groupId>org.springframework.cloud</groupId>
@ -41,6 +41,18 @@
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.70</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
</dependency>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>

@ -18,7 +18,6 @@ import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
import java.nio.charset.StandardCharsets;
import java.util.Enumeration;
import java.util.List;
@Component
@ -40,17 +39,16 @@ public class ApiGlobalFilter implements GlobalFilter, Ordered {
@Override
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
String requestUrl = exchange.getRequest().getPath().toString();
boolean status = CollectionUtils.contains((Enumeration<?>) ignoreUrl, requestUrl);
boolean status = CollectionUtils.contains(ignoreUrl.iterator(), requestUrl);
if (!status){
String token = exchange.getRequest().getHeaders().getFirst("token");
//type用于区分不同的端,在做校验token时需要
String type= exchange.getRequest().getHeaders().getFirst("type");
ServerHttpResponse response = exchange.getResponse();
//没有数据
if (StringUtils.isBlank(token) || StringUtils.isBlank(type)) {
if (StringUtils.isBlank(token)) {
JSONObject message = new JSONObject();
message.put("code", "");
message.put("message", "鉴权失败,无token或类型");
message.put("code", "401");
message.put("message", "请先登录");
byte[] bits = message.toString().getBytes(StandardCharsets.UTF_8);
DataBuffer buffer = response.bufferFactory().wrap(bits);
response.setStatusCode(HttpStatus.UNAUTHORIZED);
@ -58,13 +56,12 @@ public class ApiGlobalFilter implements GlobalFilter, Ordered {
return response.writeWith(Mono.just(buffer));
//有数据
}else {
String prefix = this.getPrefix(type);
//校验token
Long userId = verifyJWT(token ,prefix);
Long userId = verifyJWT(token);
if (userId == null){
JSONObject message = new JSONObject();
message.put("message", "token错误");
message.put("code", "");
message.put("message", "请重新登录");
message.put("code", "401");
byte[] bits = message.toString().getBytes(StandardCharsets.UTF_8);
DataBuffer buffer = response.bufferFactory().wrap(bits);
response.setStatusCode(HttpStatus.UNAUTHORIZED);
@ -85,27 +82,10 @@ public class ApiGlobalFilter implements GlobalFilter, Ordered {
* @param token
* @return userPhone
*/
private Long verifyJWT(String token, String prefix){
private Long verifyJWT(String token){
return JwtUtil.verifyToken(token);
}
/**
* 根据type获取前缀
* @param type
* @return
*/
private String getPrefix(String type){
String prefix = null;
if ("1".equals(type)){
prefix = "OPERATE";
}else if ("2".equals(type)){
prefix = "USER";
}else if ("3".equals(type)){
prefix = "WX";
}
return prefix;
}
@Override
public int getOrder() {
return -200;

@ -1,15 +1,16 @@
package com.daqing.financial.gateway.util;
package com.daqing.financial.gateway.exception;
import com.daqing.financial.gateway.util.ResultCodeEnum;
import lombok.Data;
@Data
public class OdcException extends RuntimeException {
public class DqException extends RuntimeException {
private int code;
private ResultCodeEnum resultCodeEnum;
public OdcException(ResultCodeEnum codeEnum) {
public DqException(ResultCodeEnum codeEnum) {
super(codeEnum.getRemark());
code = codeEnum.getCode();
}

@ -4,6 +4,7 @@ import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.daqing.financial.gateway.SpringContextHolder;
import com.daqing.financial.gateway.exception.DqException;
import java.util.Date;
import java.util.Set;
@ -48,9 +49,9 @@ public class JwtUtil {
return userId;
}
} catch (Exception e) {
throw new OdcException(ResultCodeEnum.UN_AUTHORIZATION);
throw new DqException(ResultCodeEnum.UN_AUTHORIZATION);
}
throw new OdcException(ResultCodeEnum.UN_AUTHORIZATION);
throw new DqException(ResultCodeEnum.UN_AUTHORIZATION);
}
public static String getRedisKey(Long userId, String token) {

@ -15,6 +15,6 @@ spring:
- id: hrms_route
uri: lb://dq-financial-hrms
predicates:
- Path=/api/hrms/**
- Path=/api/**
filters:
- RewritePath=/api/(?<segment>.*),/ $\{segment}

@ -1 +1 @@
jwt.ignoreUrlList=/route-api/login,/route-api/refresh
jwt.ignoreUrlList=/api/hrms/employee/list,/route-api/refresh
Loading…
Cancel
Save