From 87ea5dfd559ab23fb67f7b196f325a24b1564255 Mon Sep 17 00:00:00 2001 From: chen-xin-zhi <3588068430@qq.com> Date: Tue, 6 May 2025 13:25:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dsessionbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../heritage/controller/clothes/ClothesController.java | 2 +- .../cultural/heritage/service/user/impl/UserServiceImpl.java | 5 ++++- src/main/resources/application-dev.yml | 2 +- src/main/resources/application-prod.yml | 2 +- src/main/resources/application-test.yml | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/cultural/heritage/controller/clothes/ClothesController.java b/src/main/java/com/cultural/heritage/controller/clothes/ClothesController.java index c36c769..e840961 100644 --- a/src/main/java/com/cultural/heritage/controller/clothes/ClothesController.java +++ b/src/main/java/com/cultural/heritage/controller/clothes/ClothesController.java @@ -309,7 +309,7 @@ public class ClothesController { */ @GetMapping("/facelift") @Operation(summary = "小程序端用户调用换装api", description = "参数:服装id,权限:管理员(admin, boss),方法名:updateClothesShelvesStatus") - @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + @AuthCheck(mustRole = UserConstant.DEFAULT_ROLE) public BaseResponse invokeChangeClothesApi(@RequestParam String modelURL, @RequestParam String clothesURL) { if (StringUtils.isBlank(modelURL) || StringUtils.isBlank(clothesURL)) { throw new BusinessException(ErrorCode.PARAMS_ERROR, "参数不能为空"); diff --git a/src/main/java/com/cultural/heritage/service/user/impl/UserServiceImpl.java b/src/main/java/com/cultural/heritage/service/user/impl/UserServiceImpl.java index 20805d9..81d2f33 100644 --- a/src/main/java/com/cultural/heritage/service/user/impl/UserServiceImpl.java +++ b/src/main/java/com/cultural/heritage/service/user/impl/UserServiceImpl.java @@ -65,6 +65,7 @@ public class UserServiceImpl extends ServiceImpl implements Us HttpSession session = request.getSession(); System.out.println(session); session.setAttribute(USER_LOGIN_STATE, user); + session.setMaxInactiveInterval(10); return this.getUserVO(user); } @@ -192,7 +193,9 @@ public class UserServiceImpl extends ServiceImpl implements Us this.save(user); // 记住用户的登录态 } - request.getSession().setAttribute(USER_LOGIN_STATE, user); + HttpSession session = request.getSession(); + session.setAttribute(USER_LOGIN_STATE, user); + session.setMaxInactiveInterval(10); return this.getUserVO(user); } } diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index fa52f6e..30a3e7c 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -47,7 +47,7 @@ server: session: cookie: max-age: 2592000 - timeout: 2592000 +# timeout: 2592000 mybatis-plus: mapper-locations: classpath:mapper/*.xml diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index ece4e14..7044587 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -52,7 +52,7 @@ server: session: cookie: max-age: 2592000 - timeout: 2592000 +# timeout: 2592000 mybatis-plus: mapper-locations: classpath:mapper/*.xml diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml index 3f8aa97..70d091e 100644 --- a/src/main/resources/application-test.yml +++ b/src/main/resources/application-test.yml @@ -55,7 +55,7 @@ server: session: cookie: max-age: 2592000 - timeout: 720h +# timeout: 720h mybatis-plus: mapper-locations: classpath:mapper/*.xml