ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java
@@ -14,7 +14,6 @@ import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.framework.web.service.TokenService; import com.ruoyi.system.dto.SysUserUpdateStatusDTO; import com.ruoyi.system.query.SysUserQuery; import com.ruoyi.system.service.ISysDeptService; import com.ruoyi.system.service.ISysRoleService; @@ -280,22 +279,22 @@ /** * 状态修改 */ @ApiOperation(value = "状态修改") @Log(title = "用户信息-状态修改", businessType = BusinessType.UPDATE) @PutMapping("/system/user/changeStatus") public AjaxResult changeStatus(@RequestBody SysUserUpdateStatusDTO dto) { SysUser loginUser = tokenService.getLoginUser().getUser(); SysUser user = new SysUser(); user.setUserId(dto.getUserId()); user.setStatus(String.valueOf(dto.getStatus())); // user.setRemark(dto.getRemark()); user.setUpdateBy(getUsername()); user.setDisableRemark(dto.getRemark()); user.setOperatingTime(LocalDateTime.now()); user.setOperatingPerson(loginUser.getNickName()+"("+loginUser.getUserName()+")"); return AjaxResult.success(userService.updateUserStatus(user)); } // @ApiOperation(value = "状态修改") // @Log(title = "用户信息-状态修改", businessType = BusinessType.UPDATE) // @PutMapping("/system/user/changeStatus") // public AjaxResult changeStatus(@RequestBody SysUserUpdateStatusDTO dto) // { // SysUser loginUser = tokenService.getLoginUser().getUser(); // SysUser user = new SysUser(); // user.setUserId(dto.getUserId()); // user.setStatus(String.valueOf(dto.getStatus())); //// user.setRemark(dto.getRemark()); // user.setUpdateBy(getUsername()); // user.setDisableRemark(dto.getRemark()); // user.setOperatingTime(LocalDateTime.now()); // user.setOperatingPerson(loginUser.getNickName()+"("+loginUser.getUserName()+")"); // return AjaxResult.success(userService.updateUserStatus(user)); // } /** * 根据用户编号获取授权角色 ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/TaskUtil.java
@@ -1,22 +1,7 @@ package com.ruoyi.web.controller.task; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.system.model.TAppUser; import com.ruoyi.system.model.TAppUserPositioning; import com.ruoyi.system.service.TAppUserPositioningService; import com.ruoyi.system.service.TAppUserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import java.time.LocalDate; import java.util.ArrayList; import java.util.List; /** * @author xiaochen ruoyi-applet/src/main/java/com/ruoyi/web/controller/system/SysUserController.java
@@ -11,7 +11,6 @@ import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.framework.web.service.TokenService; import com.ruoyi.system.dto.SysUserUpdateStatusDTO; import com.ruoyi.system.query.SysUserQuery; import com.ruoyi.system.service.*; import com.ruoyi.system.vo.SysUserVO; @@ -338,21 +337,21 @@ return AjaxResult.success(userService.resetPwd(user)); } /** * 状态修改 */ @ApiOperation(value = "状态修改") @Log(title = "用户信息-状态修改", businessType = BusinessType.UPDATE) @PutMapping("/changeStatus") public AjaxResult changeStatus(@RequestBody SysUserUpdateStatusDTO dto) { SysUser user = new SysUser(); user.setUserId(dto.getUserId()); user.setStatus(String.valueOf(dto.getStatus())); user.setRemark(dto.getRemark()); user.setUpdateBy(getUsername()); return AjaxResult.success(userService.updateUserStatus(user)); } // /** // * 状态修改 // */ // @ApiOperation(value = "状态修改") // @Log(title = "用户信息-状态修改", businessType = BusinessType.UPDATE) // @PutMapping("/changeStatus") // public AjaxResult changeStatus(@RequestBody SysUserUpdateStatusDTO dto) // { // SysUser user = new SysUser(); // user.setUserId(dto.getUserId()); // user.setStatus(String.valueOf(dto.getStatus())); // user.setRemark(dto.getRemark()); // user.setUpdateBy(getUsername()); // return AjaxResult.success(userService.updateUserStatus(user)); // } /** * 根据用户编号获取授权角色 ruoyi-applet/src/main/java/com/ruoyi/web/controller/webSocket/WebSocketAuthHandler.java
@@ -1,224 +1,222 @@ package com.ruoyi.web.controller.webSocket; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.core.domain.model.LoginUserApplet; import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.system.model.TAppUser; import com.ruoyi.system.service.TAppUserService; import io.jsonwebtoken.Claims; import io.jsonwebtoken.Jwts; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import org.springframework.util.StringUtils; import java.util.Map; /** * WebSocket认证处理器 * 处理WebSocket连接的用户认证逻辑 */ @Component @Slf4j public class WebSocketAuthHandler { @Autowired private RedisCache redisCache; // 令牌秘钥 @Value("${token.secret}") private String secret; /** * 验证用户认证信息 * @param appUserId 用户ID * @param token 认证令牌(可选) * @return 认证结果 */ public AuthResult authenticateUser(String appUserId, String token) { try { if (appUserId == null || appUserId.trim().isEmpty()) { return AuthResult.failure("用户ID不能为空"); } return AuthResult.success(); } catch (Exception e) { log.error("用户认证失败,用户ID: {}, 错误: {}", appUserId, e.getMessage(), e); return AuthResult.failure("认证过程中发生错误: " + e.getMessage()); } } /** * 验证token * @param appUserId 用户ID * @param token 令牌 * @return 是否有效 */ private boolean validateToken(String appUserId, String token) { try { if (!StringUtils.hasText(token)) { log.debug("用户 {} 未提供token,跳过token验证", appUserId); return true; // 如果没有提供token,允许通过(可以根据业务需求调整) } // 移除Bearer前缀 if (token.startsWith(Constants.TOKEN_PREFIX)) { token = token.replace(Constants.TOKEN_PREFIX, ""); } // 解析JWT token Claims claims = parseToken(token); if (claims == null) { log.warn("用户 {} 的token解析失败", appUserId); return false; } // 从token中获取用户标识 String uuid = (String) claims.get(Constants.LOGIN_USER_APPLET_KEY); if (!StringUtils.hasText(uuid)) { log.warn("用户 {} 的token中未找到用户标识", appUserId); return false; } // 从Redis中获取用户登录信息 String userKey = getTokenKey(uuid); LoginUserApplet loginUser = redisCache.getCacheObject(userKey); if (loginUser == null) { log.warn("用户 {} 的登录信息已过期或不存在", appUserId); return false; } // 验证用户ID是否匹配 if (!appUserId.equals(loginUser.getUserId())) { log.warn("用户 {} 的token与提供的用户ID不匹配", appUserId); return false; } // 验证token是否过期 long currentTime = System.currentTimeMillis(); if (loginUser.getExpireTime() != null && loginUser.getExpireTime() < currentTime) { log.warn("用户 {} 的token已过期", appUserId); return false; } log.debug("用户 {} 的token验证成功", appUserId); return true; } catch (Exception e) { log.error("验证用户 {} 的token时发生错误: {}", appUserId, e.getMessage(), e); return false; } } /** * 解析JWT token * @param token JWT token * @return Claims对象 */ private Claims parseToken(String token) { try { return Jwts.parser() .setSigningKey(secret) .parseClaimsJws(token) .getBody(); } catch (Exception e) { log.error("解析token失败: {}", e.getMessage()); return null; } } /** * 获取token在Redis中的key * @param uuid 用户唯一标识 * @return Redis key */ private String getTokenKey(String uuid) { return com.ruoyi.common.constant.CacheConstants.LOGIN_TOKEN_KEY + uuid; } /** * 认证结果类 */ public static class AuthResult { private final boolean success; private final String message; private final TAppUser appUser; private AuthResult(boolean success, String message, TAppUser appUser) { this.success = success; this.message = message; this.appUser = appUser; } public static AuthResult success(TAppUser appUser) { return new AuthResult(true, "认证成功", appUser); } public static AuthResult failure(String message) { return new AuthResult(false, message, null); } public boolean isSuccess() { return success; } public String getMessage() { return message; } public TAppUser getAppUser() { return appUser; } } /** * 从认证消息中提取用户信息 * @param messageObj 消息对象 * @return 用户认证信息 */ public UserAuthInfo extractAuthInfo(Map<String, Object> messageObj) { String appUserId = (String) messageObj.get("appUserId"); String token = (String) messageObj.get("token"); String deviceId = (String) messageObj.get("deviceId"); String deviceType = (String) messageObj.get("deviceType"); return new UserAuthInfo(appUserId, token, deviceId, deviceType); } /** * 用户认证信息类 */ public static class UserAuthInfo { private final String appUserId; private final String token; private final String deviceId; private final String deviceType; public UserAuthInfo(String appUserId, String token, String deviceId, String deviceType) { this.appUserId = appUserId; this.token = token; this.deviceId = deviceId; this.deviceType = deviceType; } public String getAppUserId() { return appUserId; } public String getToken() { return token; } public String getDeviceId() { return deviceId; } public String getDeviceType() { return deviceType; } } } //package com.ruoyi.web.controller.webSocket; // //import com.ruoyi.common.constant.Constants; //import com.ruoyi.common.core.domain.model.LoginUserApplet; //import com.ruoyi.common.core.redis.RedisCache; //import io.jsonwebtoken.Claims; //import io.jsonwebtoken.Jwts; //import lombok.extern.slf4j.Slf4j; //import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.beans.factory.annotation.Value; //import org.springframework.stereotype.Component; //import org.springframework.util.StringUtils; // //import java.util.Map; // ///** // * WebSocket认证处理器 // * 处理WebSocket连接的用户认证逻辑 // */ //@Component //@Slf4j //public class WebSocketAuthHandler { // // // @Autowired // private RedisCache redisCache; // // // 令牌秘钥 // @Value("${token.secret}") // private String secret; // // /** // * 验证用户认证信息 // * @param appUserId 用户ID // * @param token 认证令牌(可选) // * @return 认证结果 // */ // public AuthResult authenticateUser(String appUserId, String token) { // try { // if (appUserId == null || appUserId.trim().isEmpty()) { // return AuthResult.failure("用户ID不能为空"); // } // // // return AuthResult.success(); // } catch (Exception e) { // log.error("用户认证失败,用户ID: {}, 错误: {}", appUserId, e.getMessage(), e); // return AuthResult.failure("认证过程中发生错误: " + e.getMessage()); // } // } // // /** // * 验证token // * @param appUserId 用户ID // * @param token 令牌 // * @return 是否有效 // */ // private boolean validateToken(String appUserId, String token) { // try { // if (!StringUtils.hasText(token)) { // log.debug("用户 {} 未提供token,跳过token验证", appUserId); // return true; // 如果没有提供token,允许通过(可以根据业务需求调整) // } // // // 移除Bearer前缀 // if (token.startsWith(Constants.TOKEN_PREFIX)) { // token = token.replace(Constants.TOKEN_PREFIX, ""); // } // // // 解析JWT token // Claims claims = parseToken(token); // if (claims == null) { // log.warn("用户 {} 的token解析失败", appUserId); // return false; // } // // // 从token中获取用户标识 // String uuid = (String) claims.get(Constants.LOGIN_USER_APPLET_KEY); // if (!StringUtils.hasText(uuid)) { // log.warn("用户 {} 的token中未找到用户标识", appUserId); // return false; // } // // // 从Redis中获取用户登录信息 // String userKey = getTokenKey(uuid); // LoginUserApplet loginUser = redisCache.getCacheObject(userKey); // // if (loginUser == null) { // log.warn("用户 {} 的登录信息已过期或不存在", appUserId); // return false; // } // // // 验证用户ID是否匹配 // if (!appUserId.equals(loginUser.getUserId())) { // log.warn("用户 {} 的token与提供的用户ID不匹配", appUserId); // return false; // } // // // 验证token是否过期 // long currentTime = System.currentTimeMillis(); // if (loginUser.getExpireTime() != null && loginUser.getExpireTime() < currentTime) { // log.warn("用户 {} 的token已过期", appUserId); // return false; // } // // log.debug("用户 {} 的token验证成功", appUserId); // return true; // // } catch (Exception e) { // log.error("验证用户 {} 的token时发生错误: {}", appUserId, e.getMessage(), e); // return false; // } // } // // /** // * 解析JWT token // * @param token JWT token // * @return Claims对象 // */ // private Claims parseToken(String token) { // try { // return Jwts.parser() // .setSigningKey(secret) // .parseClaimsJws(token) // .getBody(); // } catch (Exception e) { // log.error("解析token失败: {}", e.getMessage()); // return null; // } // } // // /** // * 获取token在Redis中的key // * @param uuid 用户唯一标识 // * @return Redis key // */ // private String getTokenKey(String uuid) { // return com.ruoyi.common.constant.CacheConstants.LOGIN_TOKEN_KEY + uuid; // } // // /** // * 认证结果类 // */ // public static class AuthResult { // private final boolean success; // private final String message; //// private final TAppUser appUser; // // private AuthResult(boolean success, String message) { // this.success = success; // this.message = message; //// this.appUser = appUser; // } // //// public static AuthResult success(TAppUser appUser) { //// return new AuthResult(true, "认证成功", appUser); //// } //// //// public static AuthResult failure(String message) { //// return new AuthResult(false, message, null); //// } //// //// public boolean isSuccess() { //// return success; //// } //// //// public String getMessage() { //// return message; //// } //// //// public TAppUser getAppUser() { //// return appUser; //// } // } // // /** // * 从认证消息中提取用户信息 // * @param messageObj 消息对象 // * @return 用户认证信息 // */ // public UserAuthInfo extractAuthInfo(Map<String, Object> messageObj) { // String appUserId = (String) messageObj.get("appUserId"); // String token = (String) messageObj.get("token"); // String deviceId = (String) messageObj.get("deviceId"); // String deviceType = (String) messageObj.get("deviceType"); // // return new UserAuthInfo(appUserId, token, deviceId, deviceType); // } // // /** // * 用户认证信息类 // */ // public static class UserAuthInfo { // private final String appUserId; // private final String token; // private final String deviceId; // private final String deviceType; // // public UserAuthInfo(String appUserId, String token, String deviceId, String deviceType) { // this.appUserId = appUserId; // this.token = token; // this.deviceId = deviceId; // this.deviceType = deviceType; // } // // public String getAppUserId() { // return appUserId; // } // // public String getToken() { // return token; // } // // public String getDeviceId() { // return deviceId; // } // // public String getDeviceType() { // return deviceType; // } // } //} ruoyi-applet/src/main/java/com/ruoyi/web/controller/webSocket/WebSocketController.java
@@ -3,7 +3,6 @@ import com.alibaba.fastjson.JSONObject; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.R; import com.ruoyi.system.model.TMissionReassign; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; @@ -38,7 +37,7 @@ * @return 操作结果 */ @PostMapping("/user/send/{appUserId}") @ApiOperation(value = "发送信息", response = TMissionReassign.class) @ApiOperation(value = "发送信息") public R<String> sendMessageToUser(@PathVariable String appUserId, @RequestBody Map<String, String> request) { try { String message = JSONObject.toJSONString(request); @@ -59,7 +58,7 @@ } @GetMapping("/user/send1/{appUserId}") @ApiOperation(value = "发送信息", response = TMissionReassign.class) @ApiOperation(value = "发送信息") public R<String> sendMessageToUser1(@PathVariable String appUserId) { try { String message = "{\"type\":\"mission_push\",\"content\":\"{\\\"missionId\\\":\\\"1983875114637811713\\\"}\",\"timestamp\":\"2025-10-27T09:22:45.681\"}"; ruoyi-applet/src/main/java/com/ruoyi/web/controller/webSocket/WebSocketTextFrameHandler.java
@@ -27,8 +27,8 @@ @Autowired private WebSocketUserConnectionManager userConnectionManager; @Autowired private WebSocketAuthHandler authHandler; // @Autowired // private WebSocketAuthHandler authHandler; @Override protected void channelRead0(ChannelHandlerContext ctx, TextWebSocketFrame msg) throws Exception { @@ -63,39 +63,39 @@ private void handleUserAuth(ChannelHandlerContext ctx, JSONObject messageObj) { try { // 提取认证信息 WebSocketAuthHandler.UserAuthInfo authInfo = authHandler.extractAuthInfo(messageObj); String appUserId = authInfo.getAppUserId(); String token = authInfo.getToken(); // WebSocketAuthHandler.UserAuthInfo authInfo = authHandler.extractAuthInfo(messageObj); // String appUserId = authInfo.getAppUserId(); // String token = authInfo.getToken(); if (!StringUtils.hasText(appUserId)) { sendAuthFailureResponse(ctx, "用户ID不能为空"); return; } // if (!StringUtils.hasText(appUserId)) { // sendAuthFailureResponse(ctx, "用户ID不能为空"); // return; // } // 进行用户认证 WebSocketAuthHandler.AuthResult authResult = authHandler.authenticateUser(appUserId, token); if (authResult.isSuccess()) { // 认证成功,将连接与用户关联 userConnectionManager.addUserConnection(appUserId, ctx.channel()); // 发送认证成功响应 JSONObject response = new JSONObject(); response.put("type", "auth_success"); response.put("appUserId", appUserId); response.put("nickName", authResult.getAppUser().getNickName()); response.put("message", "认证成功"); response.put("timestamp", LocalDateTime.now().toString()); ctx.channel().writeAndFlush(new TextWebSocketFrame(response.toJSONString())); log.info("用户 {} ({}) 认证成功,ChannelId: {}", appUserId, authResult.getAppUser().getNickName(), ctx.channel().id().asLongText()); } else { // 认证失败 sendAuthFailureResponse(ctx, authResult.getMessage()); log.warn("用户 {} 认证失败: {}, ChannelId: {}", appUserId, authResult.getMessage(), ctx.channel().id().asLongText()); } // WebSocketAuthHandler.AuthResult authResult = authHandler.authenticateUser(appUserId, token); // // if (authResult.isSuccess()) { // // 认证成功,将连接与用户关联 // userConnectionManager.addUserConnection(appUserId, ctx.channel()); // // // 发送认证成功响应 // JSONObject response = new JSONObject(); // response.put("type", "auth_success"); // response.put("appUserId", appUserId); // response.put("nickName", authResult.getAppUser().getNickName()); // response.put("message", "认证成功"); // response.put("timestamp", LocalDateTime.now().toString()); // // ctx.channel().writeAndFlush(new TextWebSocketFrame(response.toJSONString())); // log.info("用户 {} ({}) 认证成功,ChannelId: {}", // appUserId, authResult.getAppUser().getNickName(), ctx.channel().id().asLongText()); // } else { // // 认证失败 // sendAuthFailureResponse(ctx, authResult.getMessage()); // log.warn("用户 {} 认证失败: {}, ChannelId: {}", // appUserId, authResult.getMessage(), ctx.channel().id().asLongText()); // } } catch (Exception e) { log.error("处理用户认证时发生错误", e); sendAuthFailureResponse(ctx, "认证过程中发生错误: " + e.getMessage()); ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java
@@ -18,10 +18,8 @@ import com.ruoyi.framework.manager.AsyncManager; import com.ruoyi.framework.manager.factory.AsyncFactory; import com.ruoyi.framework.security.context.AuthenticationContextHolder; import com.ruoyi.system.model.TAppUser; import com.ruoyi.system.service.ISysConfigService; import com.ruoyi.system.service.ISysUserService; import com.ruoyi.system.service.TAppUserService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.authentication.AuthenticationManager; @@ -57,8 +55,6 @@ private ISysConfigService configService; @Autowired private SysPermissionService permissionService; @Autowired private TAppUserService appUserService; /** * 登录验证 @@ -138,17 +134,17 @@ // 用户验证 Authentication authentication = null; // 用户验证 TAppUser appUser = appUserService.getOne(Wrappers.<TAppUser>lambdaQuery().eq(TAppUser::getAccount,account)); if (StringUtils.isNull(appUser)){ log.info("登录用户:{} 不存在.", account); throw new ServiceException(MessageUtils.message("user.not.exists")); } else if (appUser.getDisabled()) { log.info("登录用户:{} 已被删除.", account); throw new ServiceException(MessageUtils.message("user.password.delete")); } else if (2 == appUser.getStatus()) { log.info("登录用户:{} 已被停用.", account); throw new ServiceException(MessageUtils.message("user.blocked")); } // TAppUser appUser = appUserService.getOne(Wrappers.<TAppUser>lambdaQuery().eq(TAppUser::getAccount,account)); // if (StringUtils.isNull(appUser)){ // log.info("登录用户:{} 不存在.", account); // throw new ServiceException(MessageUtils.message("user.not.exists")); // } else if (appUser.getDisabled()) { // log.info("登录用户:{} 已被删除.", account); // throw new ServiceException(MessageUtils.message("user.password.delete")); // } else if (2 == appUser.getStatus()) { // log.info("登录用户:{} 已被停用.", account); // throw new ServiceException(MessageUtils.message("user.blocked")); // } try { String userName = account + "_2"; @@ -310,8 +306,8 @@ */ public void recordAppLoginInfo(String userId) { TAppUser appUser = new TAppUser(); appUser.setId(userId); // TAppUser appUser = new TAppUser(); // appUser.setId(userId); // sysUser.setLoginIp(IpUtils.getIpAddr()); // sysUser.setLoginDate(DateUtils.getNowDate()); // userService.updateUserProfile(sysUser); ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysPasswordService.java
@@ -11,7 +11,6 @@ import com.ruoyi.framework.manager.AsyncManager; import com.ruoyi.framework.manager.factory.AsyncFactory; import com.ruoyi.framework.security.context.AuthenticationContextHolder; import com.ruoyi.system.model.TAppUser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.security.core.Authentication; @@ -80,48 +79,48 @@ clearLoginRecordCache(username); } } public void validateApp(TAppUser user) { Authentication usernamePasswordAuthenticationToken = AuthenticationContextHolder.getContext(); String username = usernamePasswordAuthenticationToken.getName(); String password = usernamePasswordAuthenticationToken.getCredentials().toString(); Integer retryCount = redisCache.getCacheObject(getCacheKey(username)); if (retryCount == null) { retryCount = 0; } if (retryCount >= Integer.valueOf(maxRetryCount).intValue()) { AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.retry.limit.exceed", maxRetryCount, lockTime))); throw new UserPasswordRetryLimitExceedException(maxRetryCount, lockTime); } if (!matchesApp(user, password)) { retryCount = retryCount + 1; AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.retry.limit.count", retryCount))); redisCache.setCacheObject(getCacheKey(username), retryCount, lockTime, TimeUnit.MINUTES); throw new UserPasswordNotMatchException(); } else { clearLoginRecordCache(username); } } // public void validateApp(TAppUser user) // { // Authentication usernamePasswordAuthenticationToken = AuthenticationContextHolder.getContext(); // String username = usernamePasswordAuthenticationToken.getName(); // String password = usernamePasswordAuthenticationToken.getCredentials().toString(); // // Integer retryCount = redisCache.getCacheObject(getCacheKey(username)); // // if (retryCount == null) // { // retryCount = 0; // } // // if (retryCount >= Integer.valueOf(maxRetryCount).intValue()) // { // AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, // MessageUtils.message("user.password.retry.limit.exceed", maxRetryCount, lockTime))); // throw new UserPasswordRetryLimitExceedException(maxRetryCount, lockTime); // } // // if (!matchesApp(user, password)) // { // retryCount = retryCount + 1; // AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, // MessageUtils.message("user.password.retry.limit.count", retryCount))); // redisCache.setCacheObject(getCacheKey(username), retryCount, lockTime, TimeUnit.MINUTES); // throw new UserPasswordNotMatchException(); // } // else // { // clearLoginRecordCache(username); // } // } public boolean matches(SysUser user, String rawPassword) { return SecurityUtils.matchesPassword(rawPassword, user.getPassword()); } public boolean matchesApp(TAppUser user, String rawPassword) { return SecurityUtils.matchesPassword(rawPassword, user.getPassword()); } // public boolean matchesApp(TAppUser user, String rawPassword) // { // return SecurityUtils.matchesPassword(rawPassword, user.getPassword()); // } public void clearLoginRecordCache(String loginName) { ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java
@@ -1,6 +1,5 @@ package com.ruoyi.framework.web.service; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.entity.TAppUserResp; import com.ruoyi.common.core.domain.model.LoginUser; @@ -9,12 +8,9 @@ import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.MessageUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.system.model.TAppUser; import com.ruoyi.system.service.ISysUserService; import com.ruoyi.system.service.TAppUserService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetailsService; @@ -33,8 +29,6 @@ @Autowired private ISysUserService userService; @Autowired private TAppUserService appUserService; @Autowired private SysPasswordService passwordService; @@ -70,26 +64,26 @@ return createLoginUser(user); }else { TAppUser user = appUserService.getOne(Wrappers.<TAppUser>lambdaQuery().eq(TAppUser::getAccount,username)); if (StringUtils.isNull(user)) { log.info("登录用户:{} 不存在.", username); throw new ServiceException(MessageUtils.message("user.not.exists")); } else if (user.getDisabled()) { log.info("登录用户:{} 已被删除.", username); throw new ServiceException(MessageUtils.message("user.password.delete")); } else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) { log.info("登录用户:{} 已被停用.", username); throw new ServiceException(MessageUtils.message("user.blocked")); } passwordService.validateApp(user); // TAppUser user = appUserService.getOne(Wrappers.<TAppUser>lambdaQuery().eq(TAppUser::getAccount,username)); // if (StringUtils.isNull(user)) // { // log.info("登录用户:{} 不存在.", username); // throw new ServiceException(MessageUtils.message("user.not.exists")); // } // else if (user.getDisabled()) // { // log.info("登录用户:{} 已被删除.", username); // throw new ServiceException(MessageUtils.message("user.password.delete")); // } // else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) // { // log.info("登录用户:{} 已被停用.", username); // throw new ServiceException(MessageUtils.message("user.blocked")); // } // passwordService.validateApp(user); // TAppUserResp appUserResp = new TAppUserResp(); BeanUtils.copyProperties(user,appUserResp); // BeanUtils.copyProperties(user,appUserResp); return createLoginUserApp(appUserResp); } ruoyi-system/src/main/java/com/ruoyi/system/dto/SysRoleDTO.java
New file @@ -0,0 +1,28 @@ package com.ruoyi.system.dto; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; import java.util.List; @Data @ApiModel(value = "角色新增编辑DTO") public class SysRoleDTO implements Serializable { @ApiModelProperty(value = "角色id") private Long roleId; @ApiModelProperty(value = "角色名称") private String roleName; @ApiModelProperty(value = "类型") private Integer postType; @ApiModelProperty(value = "备注") private String remark; @ApiModelProperty(value = "权限id集合") private List<Long> menuIds; } ruoyi-system/src/main/java/com/ruoyi/system/vo/IndexDataDetailVo.java
File was deleted ruoyi-system/src/main/java/com/ruoyi/system/vo/IndexDataRankVo.java
File was deleted ruoyi-system/src/main/java/com/ruoyi/system/vo/IndexDataVo.java
File was deleted ruoyi-system/src/main/java/com/ruoyi/system/vo/IndexLookDataUserVo.java
File was deleted ruoyi-system/src/main/java/com/ruoyi/system/vo/IndexLookDataVo.java
File was deleted ruoyi-system/src/main/java/com/ruoyi/system/vo/MissionTotalVo.java
File was deleted ruoyi-system/src/main/java/com/ruoyi/system/vo/PositioningDetailVO.java
File was deleted ruoyi-system/src/main/java/com/ruoyi/system/vo/TAppUserDetailVO.java
File was deleted ruoyi-system/src/main/java/com/ruoyi/system/vo/TAppUserPageVo.java
File was deleted ruoyi-system/src/main/java/com/ruoyi/system/vo/TMissionAssignRuleVO.java
File was deleted ruoyi-system/src/main/java/com/ruoyi/system/vo/TMissionReassignVO.java
File was deleted ruoyi-system/src/main/java/com/ruoyi/system/vo/TMissionVO.java
File was deleted ruoyi-system/src/main/java/com/ruoyi/system/vo/TotalHistoryVo.java
File was deleted