Skip to content

Commit

Permalink
update springboot and springcloud version and add generator plateform
Browse files Browse the repository at this point in the history
  • Loading branch information
jzfai committed Jun 26, 2022
1 parent ea98432 commit 36f1a9f
Show file tree
Hide file tree
Showing 191 changed files with 9,202 additions and 6,827 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
.history
.idea
target
node_modules
.DS_Store
dist
dist-ssr
*.local
target
*.iml
yarn*
pnpm*
coverage
33 changes: 15 additions & 18 deletions README-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,11 @@
本架构为springCloud微服务架构,提供基本的jwt权限认证,token更新,以及各微服务之间调用,以及提供企业级的使用例子

```text
spring-boot:2.1.4.RELEASE
spring-cloud:Greenwich.SR1
spring-cloud-starter-gateway:2.1.1.RELEASE
nacos:2.1.3.RELEASE
mybatis-plus:3.3.2
rabbitmq:3.7-management
redis:3.2.9
spring-boot:2.4.13
spring-cloud:2020.0.5
mybatis-plus: 3.3.2
mysql:5.7
seata:1.4.2
canal:1.2.1
knife4j:2.0.9
```

> 以上部分版本后续会升级
Expand Down Expand Up @@ -49,7 +44,7 @@ to look doc ----

#### 开发接口和nacos地址

[swager文档地址](http://8.135.1.141/micro-service-doc/swagger-ui.html)
[swager文档地址](https://github.jzfai.top/micro-service-doc/doc.html)

[nacos地址](http://8.135.1.141:8848/nacos/)

Expand All @@ -67,26 +62,27 @@ github 地址: https://github.com/jzfai/micro-service-plus.git

#### 目前实现的微服务(后续还会新增新的微服务)

##### ty - gateway - one
##### gateway

网关微服务。使用的是spring - cloud - starter - gateway,相对于zull网关来说性能更好。主要实现了,权限控制和拦截,jwt token解析和校验,
swagger文件整合,使用令牌技术请求限流等。可启动多个实例

##### ty - auth

##### auth-pom

权限服务。jwt token生成,解析,校验等,默认配置3天有效期,少于一天自动续约

##### ty - example
##### basic-func:

提供一些例子。包括,rabbitmq延时队列,goFastDFS文件上传,canal, seata分部式事务,短信发送,邮件发送等。

##### integration - front

数据整合。vue3 - admin - plus 数据来源

##### easycode - temp
##### velocity-tmp-dir

easycode前后端模板
velocity 前后端模板

#### 如何运行

Expand All @@ -95,6 +91,7 @@ easycode前后端模板
```
git clone https://github.com/jzfai/micro-service-plus.git
//maven 下载依赖,即可运行
建议先运行下 maven insall 避免出现依赖不在情况
```

如何配合vue3-admin-plus ,前后端一起开发
Expand All @@ -107,9 +104,9 @@ pnpm i
pnpm run test

#micro-service-plus 至少需要运行
ty-auth
ty-gateway-one
ty-integration-front
basic-func
gateway
integration-front
以上三个服务
```

Expand Down
33 changes: 13 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,16 @@ this architecture is the springCloud microservice architecture, which provides b
token update, and calls between microservices, as well as enterprise-level usage examples.

```text
spring-boot:2.1.4.RELEASE
spring-cloud:Greenwich.SR1
spring-cloud-starter-gateway:2.1.1.RELEASE
nacos:2.1.3.RELEASE
spring-boot:2.4.13
spring-cloud:2020.0.5
mybatis-plus: 3.3.2
rabbitmq:3.7-management
redis: 3.2.9
mysql:5.7
seata:1.4.2
canal:1.2.1
knife4j:2.0.9
```

> some of the above versions will be upgraded in the future
## Doc and Example

[swager文档地址](http://8.135.1.141/micro-service-doc/swagger-ui.html)
## Example

![1642222390648](http://8.135.1.141/file/micro-service-assets/1642222390648.png)

Expand Down Expand Up @@ -54,10 +47,9 @@ to look doc ----

## Interface documentation and nacos address

[swager文档地址](http://8.135.1.141/micro-service-doc/swagger-ui.html)

[nacos地址](http://8.135.1.141:8848/nacos/)
[swager文档地址](https://github.jzfai.top/micro-service-doc/doc.html)

[nacos地址](https://github.jzfai.top/nacos/)
naocs: 用户名:jzfai; 密码:123456

## Online experience address
Expand All @@ -72,19 +64,19 @@ github 地址: https://github.com/jzfai/micro-service-plus.git

## Introduction to Microservices

##### ty-gateway-one
##### gateway:

gateway Microservices. The spring-cloud-starter-gateway is used, which has better performance than the zull gateway. It
mainly implements permission control and interception, jwt token parsing and verification, swagger file integration, and
request current limiting using token technology. Can start multiple

##### ty-auth:
##### auth-pom

permission service. jwt token generation, parsing, verification, etc., the default configuration is valid for 3 days,
and the contract is automatically renewed if it is less than one day (if you are interested here, you can view the
source code)

##### ty-example:
##### basic-func:

provide some examples. Including, rabbitmq delay queue, goFastDFS file upload, canal, seata partial transaction, SMS
sending, mail sending, etc.
Expand Down Expand Up @@ -112,11 +104,12 @@ pnpm i
pnpm run test

#micro-service-plus At least need to run
ty-auth
ty-gateway-one
ty-integration-front
basic-func
gateway
integration-front

The above three service
建议先运行下 maven insall 避免出现依赖不在情况
```

> Note: Select the environment in Maven Projects->Profies. Currently online is a package built in the prod environment, please do not select.
Expand Down
32 changes: 32 additions & 0 deletions auth-pom/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>micro-service-plus</artifactId>
<groupId>top.kuanghua</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>auth-pom</artifactId>

<dependencies>
<dependency>
<groupId>top.kuanghua</groupId>
<artifactId>common-pom</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.0</version>
</dependency>

<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-aggregation-spring-boot-starter</artifactId>
<version>2.0.9</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
package top.kuanghua.tyauth.controller;

import io.jsonwebtoken.Claims;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.kuanghua.khcomomon.entity.ResResult;
import top.kuanghua.tyauth.service.TokenService;

import java.util.Map;

/**
* @Title: TokenController
* @Description:
* @Auther: kuanghua
* @create 2021/1/31 16:31
*/

@RestController
@RequestMapping("token")
@Api(tags = "token相关")
@Slf4j
public class TokenController {

@Autowired
private TokenService tokenService;

/*
* 解析token
* */
@ApiOperation("获取token信息")
@PostMapping("parseToken")
public ResResult parseToken(@RequestParam("jwtToken") String jwtToken) {
Claims claims = this.tokenService.parseToken(jwtToken);
return new ResResult().success(claims);
}

/*
* 生成token
* */
@ApiOperation("生成token")
@PostMapping("generateToken")
//@RequestHeader("authorize_token") String authorize_token
public ResResult generateToken(@RequestBody Map tokenMap) {
String generateToken = this.tokenService.generateToken(tokenMap);
return new ResResult().success(generateToken);
}

/*
* 更新token
* */
@ApiOperation("更新token")
@PostMapping("updateToken")
public ResResult updateToken(@RequestBody Map map) {
String updateToken = this.tokenService.updateToken(map);
// System.out.println("生成信息的token"+updateToken);
// System.out.println("生成信息的token"+map.toString());
return new ResResult().success(updateToken);
}
}

package top.kuanghua.authpom.controller;

import io.jsonwebtoken.Claims;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.kuanghua.authpom.service.TokenService;
import top.kuanghua.commonpom.entity.ResResult;

import java.util.Map;

/**
* @Title: TokenController
* @Description:
* @Auther: kuanghua
* @create 2021/1/31 16:31
*/

@RestController
@RequestMapping("token")
@Api(tags = "token相关")
@Slf4j
public class TokenController {

@Autowired
private TokenService tokenService;

/*
* 解析token
* */
@ApiOperation("获取token信息")
@PostMapping("parseToken")
public ResResult parseToken(@RequestParam("jwtToken") String jwtToken) {
Claims claims = this.tokenService.parseToken(jwtToken);
return new ResResult().success(claims);
}

/*
* 生成token
* */
@ApiOperation("生成token")
@PostMapping("generateToken")
//@RequestHeader("authorize_token") String authorize_token
public ResResult generateToken(@RequestBody Map tokenMap) {
String generateToken = this.tokenService.generateToken(tokenMap);
return new ResResult().success(generateToken);
}

/*
* 更新token
* */
@ApiOperation("更新token")
@PostMapping("updateToken")
public ResResult updateToken(@RequestBody Map map) {
String updateToken = this.tokenService.updateToken(map);
// System.out.println("生成信息的token"+updateToken);
// System.out.println("生成信息的token"+map.toString());
return new ResResult().success(updateToken);
}
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package top.kuanghua.authpom.service;

import io.jsonwebtoken.Claims;
import org.springframework.stereotype.Service;
import top.kuanghua.authpom.utils.JwtUtilsSelf;

import java.util.Map;

/**
* @Title: TokenService
* @Description:
* @Auther: kuanghua
* @create 2021/1/31 16:19
*/
@Service
public class TokenService {

private static final String AUTHORIZE_TOKEN = "AUTHORIZE_TOKEN";

public String generateToken(Map map) {
try {
return JwtUtilsSelf.createJWT(map, null);
} catch (Exception e) {
throw new RuntimeException("token生成有误");
}
}

/*
* 更新token
* */
public String updateToken(Map map) {
try {
String updateToken = JwtUtilsSelf.createJWT(map, null);
return updateToken;
} catch (Exception e) {
throw new RuntimeException("token更新有误");
}
}
/*
* 解析token
* */
public Claims parseToken(String jwtToken) {
try {
Claims claims = JwtUtilsSelf.parseJWT(jwtToken);
return claims;
} catch (Exception e) {
throw new RuntimeException("token解析错误");
}
}
}
Loading

0 comments on commit 36f1a9f

Please sign in to comment.