Skip to content

Commit d314bc1

Browse files
committed
JWT
1 parent 5b6c844 commit d314bc1

5 files changed

Lines changed: 67 additions & 8 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,13 @@ npm run lint
248248
用户名:admin
249249
密码:1
250250
#### 截图
251+
251252
![登录](./inc/readme/登录.png)
252253
![增删改查](./inc/readme/增删改查列表.png)
253254
![用户管理](./inc/readme/用户管理.png)
254255
![角色管理](./inc/readme/角色管理.png)
255256
![系统菜单](./inc/readme/系统菜单.png)
257+
![Postman测试http接口](./inc/readme/Postman测试http接口.png)
256258

257259
#### 项目中需要说明的关键技术点
258260

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,36 @@
11
package com.inc.admin.controller.sys;
22

3+
import com.inc.admin.aspect.WebLogAspect;
4+
import org.slf4j.Logger;
5+
import org.slf4j.LoggerFactory;
6+
import org.springframework.web.bind.annotation.PostMapping;
7+
import org.springframework.web.bind.annotation.RequestMapping;
38
import org.springframework.web.bind.annotation.RestController;
49

5-
/**
6-
* @author xianxian
7-
* @version V1.0
8-
*/
10+
@RequestMapping("/curd")
911
@RestController
1012
public class BaseController {
13+
private static final Logger logger = LoggerFactory.getLogger(WebLogAspect.class);
14+
15+
/**
16+
* @methodName
17+
* <p>
18+
* Description:
19+
* 测试增删改查
20+
* </p>
21+
* @param: null
22+
* @return null
23+
* @throws
24+
* <p>Copyright: Copyright (c) 2017</p>
25+
* <p>Company: www.baidudu.com</p>
26+
* @Author xianxian
27+
* @Date 2023/11/7 5:34
28+
* @version 1.0
29+
*/
30+
@PostMapping("/login")
31+
String TestUrl(){
32+
logger.info("logger Hello World!");
33+
return "Hello World! Sucess!";
34+
}
35+
1136
}

inc/inc-admin/src/main/java/com/inc/admin/controller/sys/LoginController.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111
import com.inc.admin.utils.MD5Utils;
1212
import com.inc.admin.utils.R;
1313
import org.springframework.beans.factory.annotation.Autowired;
14-
import org.springframework.web.bind.annotation.PostMapping;
15-
import org.springframework.web.bind.annotation.RequestBody;
16-
import org.springframework.web.bind.annotation.RequestMapping;
17-
import org.springframework.web.bind.annotation.RestController;
14+
import org.springframework.web.bind.annotation.*;
1815

1916
import javax.servlet.http.HttpServletRequest;
2017
import javax.servlet.http.HttpServletResponse;
@@ -72,5 +69,9 @@ R logout(HttpServletRequest request, HttpServletResponse response) {
7269
return R.ok();
7370
}
7471

72+
@PostMapping("/testhttp")
73+
String testhttp(){
74+
return "sucess";
75+
}
7576

7677
}

inc/inc-admin/src/main/java/com/inc/admin/utils/JwtUtils.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@
1313
* @version V1.0
1414
*/
1515
public class JwtUtils {
16+
/**
17+
* @methodName generateToken
18+
* <p>
19+
* Description:
20+
* JWT加密
21+
* </p>
22+
* @param: userToken
23+
* @param: expire
24+
* @return String
25+
* @throws Exception
26+
* <p>Copyright: Copyright (c) 2017</p>
27+
* <p>Company: www.baidudu.com</p>
28+
* @author xianxian
29+
* @Date 2023/11/8 3:21
30+
* @version 1.0
31+
*/
1632
public static String generateToken(UserToken userToken, int expire) throws Exception {
1733
String token = Jwts.builder()
1834
.setSubject(userToken.getUsername())
@@ -26,6 +42,21 @@ public static String generateToken(UserToken userToken, int expire) throws Excep
2642
}
2743

2844

45+
/**
46+
* @methodName getInfoFromToken
47+
* <p>
48+
* Description:
49+
* JWT解密
50+
* </p>
51+
* @param: token
52+
* @return UserToken
53+
* @throws Exception
54+
* <p>Copyright: Copyright (c) 2017</p>
55+
* <p>Company: www.baidudu.com</p>
56+
* @author xianxian
57+
* @Date 2023/11/8 3:22
58+
* @version 1.0
59+
*/
2960
public static UserToken getInfoFromToken(String token) throws Exception {
3061
Claims claims = Jwts.parser()
3162
.setSigningKey(CommonConstants.JWT_PRIVATE_KEY).parseClaimsJws(token)
140 KB
Loading

0 commit comments

Comments
 (0)