Skip to content

Commit 9e9cd02

Browse files
author
Xiong Neng
committed
更新到jwt
1 parent df91463 commit 9e9cd02

File tree

26 files changed

+93
-2444
lines changed

26 files changed

+93
-2444
lines changed

springboot-cache/src/main/resources/application.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ spring:
1010
profiles:
1111
active: dev
1212
datasource:
13-
url: jdbc:mysql://123.207.66.156:3306/test?useSSL=false&autoReconnect=true&tinyInt1isBit=false&useUnicode=true&characterEncoding=utf8
13+
url: jdbc:mysql://127.0.0.1:3306/test?useSSL=false&autoReconnect=true&tinyInt1isBit=false&useUnicode=true&characterEncoding=utf8
1414
username: root
15-
password: _EnZhi123
15+
password: 123456
1616

1717
################### mybatis-plus配置 ###################
1818
mybatis-plus:

springboot-echarts/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<parent>
1616
<groupId>org.springframework.boot</groupId>
1717
<artifactId>spring-boot-starter-parent</artifactId>
18-
<version>1.5.10.RELEASE</version>
18+
<version>2.0.4.RELEASE</version>
1919
<relativePath/>
2020
</parent>
2121

springboot-hibernate/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<parent>
1616
<groupId>org.springframework.boot</groupId>
1717
<artifactId>spring-boot-starter-parent</artifactId>
18-
<version>1.5.10.RELEASE</version>
18+
<version>2.0.4.RELEASE</version>
1919
<relativePath/>
2020
</parent>
2121

springboot-jwt/README.md

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,81 @@
99

1010
## 测试
1111

12-
启动应用后,先访问登录接口,使用参数用户名=admin/密码=12345678,拿到token后再访问其他接口。
12+
启动应用后
13+
14+
1. 先访问登录接口/login
15+
16+
*URL*
17+
18+
```
19+
POST http://localhost:9095/login
20+
```
21+
22+
*Header参数*
23+
24+
```
25+
Content-Type: application/json
26+
```
27+
28+
*Body参数*
29+
30+
``` json
31+
{
32+
"username": "admin",
33+
"password": "12345678",
34+
"appid": "111",
35+
"imei": "imei"
36+
}
37+
```
38+
39+
返回值:
40+
41+
``` json
42+
{
43+
"success": true,
44+
"msg": "Login success",
45+
"data": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhcHBpZCI6IjExMSIsImltZWkiOiJpbWVpIiwiZXhwIjoxNTM2NDg3NTM1LCJ1c2VybmFtZSI6ImFkbWluIn0.uat7rvVLwC7bcM-jRs329RWdHIFC6P-YN7YdJrdRUHE"
46+
}
47+
```
48+
49+
2. 使用token再去访问接口
50+
51+
上面的"data"对应的一长串字符串就是返回的token值
52+
53+
*URL*
54+
55+
```
56+
GET http://localhost:9095/api/v1/join?imei=imei
57+
```
58+
59+
*Header参数*
60+
61+
```
62+
Content-Type: application/json
63+
Authorization: 'Bearer ' + token
64+
```
65+
66+
*Body参数*
67+
68+
``` json
69+
{
70+
"username": "admin",
71+
"password": "12345678",
72+
"appid": "111",
73+
"imei": "imei"
74+
}
75+
```
76+
77+
返回值:
78+
79+
``` json
80+
{
81+
"success": true,
82+
"msg": "Login success",
83+
"data": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhcHBpZCI6IjExMSIsImltZWkiOiJpbWVpIiwiZXhwIjoxNTM2NDg3NTM1LCJ1c2VybmFtZSI6ImFkbWluIn0.uat7rvVLwC7bcM-jRs329RWdHIFC6P-YN7YdJrdRUHE"
84+
}
85+
```
86+
1387

1488
## 许可证
1589

springboot-jwt/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<parent>
1616
<groupId>org.springframework.boot</groupId>
1717
<artifactId>spring-boot-starter-parent</artifactId>
18-
<version>1.5.10.RELEASE</version>
18+
<version>2.0.4.RELEASE</version>
1919
<relativePath/>
2020
</parent>
2121

springboot-jwt/src/main/java/com/xncoding/jwt/api/ExceptionController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@ public class ExceptionController {
2020
@ResponseStatus(HttpStatus.UNAUTHORIZED)
2121
@ExceptionHandler(ShiroException.class)
2222
public BaseResponse handle401(ShiroException e) {
23-
return new BaseResponse(false, "shiro的异常", null);
23+
return new BaseResponse<>(false, "shiro的异常", null);
2424
}
2525

2626
// 捕捉UnauthorizedException
2727
@ResponseStatus(HttpStatus.UNAUTHORIZED)
2828
@ExceptionHandler(UnauthorizedException.class)
2929
public BaseResponse handle401() {
30-
return new BaseResponse(false, "UnauthorizedException", null);
30+
return new BaseResponse<>(false, "UnauthorizedException", null);
3131
}
3232

3333
// 捕捉其他所有异常
3434
@ExceptionHandler(Exception.class)
3535
@ResponseStatus(HttpStatus.BAD_REQUEST)
3636
public BaseResponse globalException(HttpServletRequest request, Throwable ex) {
37-
return new BaseResponse(false, "其他异常", null);
37+
return new BaseResponse<>(false, "其他异常", null);
3838
}
3939

4040
private HttpStatus getStatus(HttpServletRequest request) {

springboot-jwt/src/main/java/com/xncoding/jwt/api/NotifyController.java

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)