diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/websocket/context/KitWsServer.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/websocket/context/KitWsServer.java index 2bb1be4e..19d07f30 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/websocket/context/KitWsServer.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/websocket/context/KitWsServer.java @@ -61,12 +61,12 @@ public class KitWsServer { * @param message 客户端发送过来的消息 */ @OnMessage - public void onMessage(String message, Session session) { + public void onMessage(String message, Session session) throws IOException { KitWsMessage wsMessage = JSON.parseObject(message, KitWsMessage.class); String bizCode = wsMessage.getBizCode(); Object data = wsMessage.getData(); - log.info("收到来 sid={} 的信息: message={}, bizCode={}, data={}", sid, message, bizCode, - JSON.toJSONString(data)); + log.info("收到来 sid={} 的信息: message={}, bizCode={}, data={}", sid, message, bizCode, JSON.toJSONString(data)); + session.getBasicRemote().sendText(message); } /** diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemCacheKey.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/constant/SystemCacheKey.java similarity index 89% rename from cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemCacheKey.java rename to cutejava/cutejava-module-system/src/main/java/cn/odboy/system/constant/SystemCacheKey.java index 3a2a51f7..fb51017b 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemCacheKey.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/constant/SystemCacheKey.java @@ -1,31 +1,35 @@ -/* - * Copyright 2021-2026 Odboy - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package cn.odboy.system.dal.redis; - -/** - * 关于缓存的Key集合 - */ -public interface SystemCacheKey { - - /** - * 在线用户 - */ - String ONLINE_USER = "user::token:"; - /** - * 登录验证码 - */ - String CAPTCHA_LOGIN = "captcha::login:"; -} +/* + * Copyright 2021-2026 Odboy + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package cn.odboy.system.constant; + +/** + * 关于缓存的Key集合 + */ +public interface SystemCacheKey { + + /** + * 在线用户 + */ + String ONLINE_USER = "user::token:"; + /** + * 登录验证码 + */ + String CAPTCHA_LOGIN = "captcha::login:"; + /** + * 用户信息 + */ + String USER_INFO = "user::info:"; +} diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemRedisKey.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemRedisKey.java deleted file mode 100644 index 1ffeb347..00000000 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemRedisKey.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2021-2026 Odboy - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package cn.odboy.system.dal.redis; - -/** - * 关于缓存的Key集合 - */ -public interface SystemRedisKey { - - /** - * 用户 - */ - String USER_ID = "user::id:"; - /** - * 数据 - */ - String DATA_USER = "data::user:"; - /** - * 菜单 - */ - String MENU_ID = "menu::id:"; - String MENU_USER = "menu::user:"; - /** - * 角色授权 - */ - String ROLE_AUTH = "role::auth:"; - String ROLE_USER = "role::user:"; - /** - * 角色信息 - */ - String ROLE_ID = "role::id:"; - /** - * 部门 - */ - String DEPT_ID = "dept::id:"; - /** - * 岗位 - */ - String JOB_ID = "job::id:"; - /** - * 数据字典 - */ - String DICT_NAME = "dict::name:"; - /** - * 在线用户 - */ - String ONLINE_USER = "online::token:"; - /** - * 登录验证码 - */ - String CAPTCHA_LOGIN = "captcha::login:"; - /** - * 用户信息 - */ - String USER_INFO = "user::info:"; -} diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemUserInfoDAO.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemUserInfoDAO.java index b52f0f77..f5ec2465 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemUserInfoDAO.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemUserInfoDAO.java @@ -18,6 +18,7 @@ package cn.odboy.system.dal.redis; import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.StrUtil; import cn.odboy.framework.redis.KitRedisHelper; +import cn.odboy.system.constant.SystemCacheKey; import cn.odboy.system.dal.model.response.SystemUserJwtVo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Async; @@ -42,7 +43,7 @@ public class SystemUserInfoDAO { if (StrUtil.isNotEmpty(userName)) { // 添加数据, 避免数据同时过期(2小时左右) long time = 7200 + RandomUtil.randomInt(900, 1800); - redisHelper.set(SystemRedisKey.USER_INFO + userName, user, time); + redisHelper.set(SystemCacheKey.USER_INFO + userName, user, time); } } @@ -55,7 +56,7 @@ public class SystemUserInfoDAO { public void deleteUserLoginInfoByUserName(String userName) { if (StrUtil.isNotEmpty(userName)) { // 清除数据 - redisHelper.del(SystemRedisKey.USER_INFO + userName); + redisHelper.del(SystemCacheKey.USER_INFO + userName); } } @@ -68,7 +69,7 @@ public class SystemUserInfoDAO { public SystemUserJwtVo getUserLoginInfoByUserName(String username) { if (StrUtil.isNotEmpty(username)) { // 获取数据 - return redisHelper.get(SystemRedisKey.USER_INFO + username, SystemUserJwtVo.class); + return redisHelper.get(SystemCacheKey.USER_INFO + username, SystemUserJwtVo.class); } return null; } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemUserOnlineInfoDAO.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemUserOnlineInfoDAO.java index 4d2bfbc2..2ea3d160 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemUserOnlineInfoDAO.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemUserOnlineInfoDAO.java @@ -19,6 +19,7 @@ import cn.hutool.core.util.StrUtil; import cn.odboy.base.KitPageResult; import cn.odboy.framework.properties.AppProperties; import cn.odboy.framework.redis.KitRedisHelper; +import cn.odboy.system.constant.SystemCacheKey; import cn.odboy.system.dal.model.export.SystemUserOnlineExportRowVo; import cn.odboy.system.dal.model.response.SystemUserJwtVo; import cn.odboy.system.dal.model.response.SystemUserOnlineVo; @@ -122,7 +123,7 @@ public class SystemUserOnlineInfoDAO { * @param username / */ public void kickOutByUsername(String username) { - String loginKey = SystemRedisKey.ONLINE_USER + username + "*"; + String loginKey = SystemCacheKey.ONLINE_USER + username + "*"; redisHelper.scanDel(loginKey); } @@ -133,15 +134,13 @@ public class SystemUserOnlineInfoDAO { * @param pageable / * @return / */ - public KitPageResult searchOnlineUser(SystemUserOnlineVo onlineVo, - IPage pageable) { + public KitPageResult searchOnlineUser(SystemUserOnlineVo onlineVo, IPage pageable) { String username = null; if (onlineVo != null) { username = onlineVo.getUserName(); } - List onlineUserList = queryUserOnlineModelListByUsername(username); - List paging = - KitPageUtil.softPaging(pageable.getCurrent(), pageable.getSize(), onlineUserList); + List onlineUserList = this.queryUserOnlineModelListByUsername(username); + List paging = KitPageUtil.softPaging(pageable.getCurrent(), pageable.getSize(), onlineUserList); return KitPageUtil.toPage(paging, onlineUserList.size()); } @@ -152,7 +151,7 @@ public class SystemUserOnlineInfoDAO { * @return / */ public List queryUserOnlineModelListByUsername(String username) { - String loginKey = SystemRedisKey.ONLINE_USER + (StrUtil.isBlank(username) ? "" : "*" + username); + String loginKey = SystemCacheKey.ONLINE_USER + (StrUtil.isBlank(username) ? "" : "*" + username); List keys = redisHelper.scan(loginKey + "*"); Collections.reverse(keys); List onlineUserList = new ArrayList<>(); diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/core/handler/TokenProvider.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/core/handler/TokenProvider.java index 732eadbc..dc83894b 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/core/handler/TokenProvider.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/core/handler/TokenProvider.java @@ -22,7 +22,7 @@ import cn.odboy.constant.SystemConst; import cn.odboy.framework.properties.AppProperties; import cn.odboy.framework.redis.KitRedisHelper; import cn.odboy.system.dal.model.response.SystemUserJwtVo; -import cn.odboy.system.dal.redis.SystemCacheKey; +import cn.odboy.system.constant.SystemCacheKey; import io.jsonwebtoken.Claims; import io.jsonwebtoken.JwtParser; import io.jsonwebtoken.Jwts; diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemCaptchaService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemCaptchaService.java index 91d2ac7e..ffd8443a 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemCaptchaService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemCaptchaService.java @@ -23,7 +23,7 @@ import cn.odboy.framework.exception.BadRequestException; import cn.odboy.framework.properties.AppProperties; import cn.odboy.framework.redis.KitRedisHelper; import cn.odboy.system.dal.model.response.SystemCaptchaVo; -import cn.odboy.system.dal.redis.SystemCacheKey; +import cn.odboy.system.constant.SystemCacheKey; import com.wf.captcha.base.Captcha; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service;