diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/security/service/UserDetailsServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/security/service/UserDetailsServiceImpl.java index 75d1ce21..6d5d51ad 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/security/service/UserDetailsServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/security/service/UserDetailsServiceImpl.java @@ -19,10 +19,11 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import me.zhengjie.exception.BadRequestException; import me.zhengjie.modules.security.service.dto.JwtUserDto; +import me.zhengjie.modules.system.domain.User; import me.zhengjie.modules.system.service.DataService; import me.zhengjie.modules.system.service.RoleService; import me.zhengjie.modules.system.service.UserService; -import me.zhengjie.modules.system.service.dto.UserLoginDto; +import me.zhengjie.modules.system.service.dto.UserDto; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.stereotype.Service; @@ -43,7 +44,7 @@ public class UserDetailsServiceImpl implements UserDetailsService { public JwtUserDto loadUserByUsername(String username) { JwtUserDto jwtUserDto = userCacheManager.getUserCache(username); if(jwtUserDto == null){ - UserLoginDto user = userService.getLoginData(username); + UserDto user = userService.getLoginData(username); if (user == null) { throw new BadRequestException("用户不存在"); } else { diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/security/service/dto/JwtUserDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/security/service/dto/JwtUserDto.java index 984c5191..ebb1a1de 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/security/service/dto/JwtUserDto.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/security/service/dto/JwtUserDto.java @@ -20,7 +20,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; -import me.zhengjie.modules.system.service.dto.UserLoginDto; +import me.zhengjie.modules.system.service.dto.UserDto; import org.springframework.security.core.userdetails.UserDetails; import java.util.List; import java.util.Set; @@ -35,7 +35,7 @@ import java.util.stream.Collectors; public class JwtUserDto implements UserDetails { @ApiModelProperty(value = "用户") - private final UserLoginDto user; + private final UserDto user; @ApiModelProperty(value = "数据权限") private final List dataScopes; @@ -51,12 +51,6 @@ public class JwtUserDto implements UserDetails { return authorities.stream().map(AuthorityDto::getAuthority).collect(Collectors.toSet()); } - @Override - @JSONField(serialize = false) - public String getPassword() { - return user.getPassword(); - } - @Override @JSONField(serialize = false) public String getUsername() { diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/UserService.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/UserService.java index 7ab5d41d..4e414c5a 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/UserService.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/UserService.java @@ -18,7 +18,6 @@ package me.zhengjie.modules.system.service; import me.zhengjie.utils.PageResult; import me.zhengjie.modules.system.domain.User; import me.zhengjie.modules.system.service.dto.UserDto; -import me.zhengjie.modules.system.service.dto.UserLoginDto; import me.zhengjie.modules.system.service.dto.UserQueryCriteria; import org.springframework.data.domain.Pageable; import org.springframework.web.multipart.MultipartFile; @@ -72,7 +71,7 @@ public interface UserService { * @param userName / * @return / */ - UserLoginDto getLoginData(String userName); + UserDto getLoginData(String userName); /** * 修改密码 diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/UserDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/UserDto.java index e27695aa..23f7398d 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/UserDto.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/UserDto.java @@ -68,8 +68,8 @@ public class UserDto extends BaseDTO implements Serializable { @ApiModelProperty(value = "头像路径") private String avatarPath; - @ApiModelProperty(value = "密码") @JSONField(serialize = false) + @ApiModelProperty(value = "密码") private String password; @ApiModelProperty(value = "是否启用") diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/UserLoginDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/UserLoginDto.java deleted file mode 100644 index b4f36210..00000000 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/UserLoginDto.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2019-2025 Zheng Jie - * - * 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 me.zhengjie.modules.system.service.dto; - -import com.alibaba.fastjson.annotation.JSONField; -import io.swagger.annotations.ApiModelProperty; - -/** - * @author Zheng Jie - * @description 用户缓存时使用 - * @date 2022-05-26 - **/ -public class UserLoginDto extends UserDto { - - @ApiModelProperty(value = "密码") - @JSONField(serialize = false) - private String password; - - @ApiModelProperty(value = "是否为管理员") - private Boolean isAdmin; -} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java index d4a3d4a7..9904d431 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java @@ -27,7 +27,6 @@ import me.zhengjie.exception.EntityNotFoundException; import me.zhengjie.modules.system.repository.UserRepository; import me.zhengjie.modules.system.service.UserService; import me.zhengjie.modules.system.service.dto.*; -import me.zhengjie.modules.system.service.mapstruct.UserLoginMapper; import me.zhengjie.modules.system.service.mapstruct.UserMapper; import me.zhengjie.utils.*; import org.springframework.data.domain.Page; @@ -57,7 +56,6 @@ public class UserServiceImpl implements UserService { private final RedisUtils redisUtils; private final UserCacheManager userCacheManager; private final OnlineUserService onlineUserService; - private final UserLoginMapper userLoginMapper; @Override public PageResult queryAll(UserQueryCriteria criteria, Pageable pageable) { @@ -182,12 +180,12 @@ public class UserServiceImpl implements UserService { } @Override - public UserLoginDto getLoginData(String userName) { + public UserDto getLoginData(String userName) { User user = userRepository.findByUsername(userName); if (user == null) { return null; } else { - return userLoginMapper.toDto(user); + return userMapper.toDto(user); } } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapstruct/UserLoginMapper.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapstruct/UserLoginMapper.java deleted file mode 100644 index 19b77282..00000000 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapstruct/UserLoginMapper.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2019-2025 Zheng Jie - * - * 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 me.zhengjie.modules.system.service.mapstruct; - -import me.zhengjie.base.BaseMapper; -import me.zhengjie.modules.system.domain.User; -import me.zhengjie.modules.system.service.dto.UserLoginDto; -import org.mapstruct.Mapper; -import org.mapstruct.ReportingPolicy; - -/** - * @author Zheng Jie - * @date 2018-11-23 - */ -@Mapper(componentModel = "spring",uses = {RoleMapper.class, DeptMapper.class, JobMapper.class},unmappedTargetPolicy = ReportingPolicy.IGNORE) -public interface UserLoginMapper extends BaseMapper { -}