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> <description>系统API统一定义</description>
<dependencies> <dependencies>
<dependency> <!-- <dependency>
<groupId>com.daqing.framework</groupId> <groupId>com.daqing.framework</groupId>
<artifactId>dq-framework-common</artifactId> <artifactId>dq-framework-common</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>-->
<dependency> <dependency>
<groupId>com.daqing.framework</groupId> <groupId>com.daqing.framework</groupId>
<artifactId>dq-framework-model</artifactId> <artifactId>dq-framework-model</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <!--<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>-->
<!--<dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
<version>2.1.8.RELEASE</version> <version>2.1.8.RELEASE</version>
</dependency> </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> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>

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

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

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

@ -20,21 +20,21 @@
</properties> </properties>
<dependencies> <dependencies>
<dependency> <!--<dependency>
<groupId>com.daqing.framework</groupId> <groupId>com.daqing.framework</groupId>
<artifactId>dq-framework-common</artifactId> <artifactId>dq-framework-common</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>-->
<dependency> <dependency>
<groupId>com.daqing.framework</groupId> <groupId>com.daqing.framework</groupId>
<artifactId>dq-framework-model</artifactId> <artifactId>dq-framework-model</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <!-- <dependency>
<groupId>com.daqing.framework</groupId> <groupId>com.daqing.framework</groupId>
<artifactId>dq-framework-utils</artifactId> <artifactId>dq-framework-utils</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
</dependency> </dependency>-->
<dependency> <dependency>
<groupId>com.daqing.financial</groupId> <groupId>com.daqing.financial</groupId>
<artifactId>dq-financial-api</artifactId> <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.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
@ -33,7 +33,7 @@ public class EmployeeController implements EmployeeControllerApi {
//@RequiresPermissions("hrms:employee:info") //@RequiresPermissions("hrms:employee:info")
public ResponseResult list(@RequestParam("page") Integer page, public ResponseResult list(@RequestParam("page") Integer page,
@RequestParam("size") Integer size, @RequestParam("size") Integer size,
EmployeeEntity employee) { @Valid EmployeeEntity employee) {
PageUtils data = employeeService.queryPage(page, size, employee); PageUtils data = employeeService.queryPage(page, size, employee);
return new ResponseResult<PageUtils>().SUCCESS(data); return new ResponseResult<PageUtils>().SUCCESS(data);
} }

@ -27,16 +27,53 @@
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-java</artifactId>
<version>8.0.17</version> <version>8.0.17</version>
</dependency> </dependency>
<!--mybatis-plus-->
<dependency> <dependency>
<groupId>com.baomidou</groupId> <groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId> <artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.3.1</version> <version>3.0.7.1</version>
</dependency> </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> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<version>1.18.12</version> <version>1.18.12</version>
</dependency> </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--> <!--<scope>provided</scope> 设置成目标环境已存在,打包的时候不会带上这个jar-->
<dependency> <dependency>
<groupId>javax.servlet</groupId> <groupId>javax.servlet</groupId>
@ -49,6 +86,7 @@
<artifactId>spring-web</artifactId> <artifactId>spring-web</artifactId>
<version>5.2.8.RELEASE</version> <version>5.2.8.RELEASE</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>
<artifactId>guava</artifactId> <artifactId>guava</artifactId>

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

@ -48,5 +48,23 @@
<version>9.0.37</version> <version>9.0.37</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </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> </dependencies>
</project> </project>

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

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

@ -20,11 +20,11 @@
</properties> </properties>
<dependencies> <dependencies>
<dependency> <!--<dependency>
<groupId>com.daqing.framework</groupId> <groupId>com.daqing.framework</groupId>
<artifactId>dq-framework-common</artifactId> <artifactId>dq-framework-common</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>-->
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
@ -41,6 +41,18 @@
<version>3.8.1</version> <version>3.8.1</version>
</dependency> </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> <dependency>
<groupId>com.auth0</groupId> <groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId> <artifactId>java-jwt</artifactId>

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

@ -4,6 +4,7 @@ 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 com.daqing.financial.gateway.exception.DqException;
import java.util.Date; import java.util.Date;
import java.util.Set; import java.util.Set;
@ -48,9 +49,9 @@ public class JwtUtil {
return userId; return userId;
} }
} catch (Exception e) { } 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) { public static String getRedisKey(Long userId, String token) {

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