diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserAuthLoginManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserAuthLoginManage.java index fdda6c4..75e3a7c 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserAuthLoginManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserAuthLoginManage.java @@ -1,11 +1,15 @@ package com.ningdatech.pmapi.user.manage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.ningdatech.pmapi.user.entity.UserInfo; import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; import com.ningdatech.pmapi.user.service.IUserAuthService; import com.ningdatech.pmapi.user.service.IUserInfoService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; +import java.util.Objects; + /** * @author liuxinxin * @date 2023/1/3 上午10:57 @@ -41,12 +45,18 @@ public class UserAuthLoginManage { * @return */ public UserFullInfoDTO queryUserInfoInPhoneNoAuth(String phoneNo) { + UserInfo userInfo = iUserInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class) + .eq(UserInfo::getMobile, phoneNo)); + if (Objects.isNull(userInfo)) { + return null; + } + UserFullInfoDTO userFullInfoDTO = new UserFullInfoDTO(); userFullInfoDTO.setCompanyId(1L); - userFullInfoDTO.setUserId(1L); - userFullInfoDTO.setIdentifier("123456"); - userFullInfoDTO.setRealName("测试账号"); - userFullInfoDTO.setUsername("测试账号"); + userFullInfoDTO.setUserId(userInfo.getId()); + userFullInfoDTO.setIdentifier(userInfo.getRealName()); + userFullInfoDTO.setRealName(userInfo.getRealName()); + userFullInfoDTO.setUsername(userInfo.getRealName()); return userFullInfoDTO; } @@ -57,12 +67,17 @@ public class UserAuthLoginManage { * @return */ public UserFullInfoDTO queryUserInfoInAccountIdAuth(String accountId) { + UserInfo userInfo = iUserInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class) + .eq(UserInfo::getAccountId, accountId)); + if (Objects.isNull(userInfo)) { + return null; + } UserFullInfoDTO userFullInfoDTO = new UserFullInfoDTO(); userFullInfoDTO.setCompanyId(1L); - userFullInfoDTO.setUserId(1L); - userFullInfoDTO.setIdentifier("123456"); - userFullInfoDTO.setRealName("测试账号"); - userFullInfoDTO.setUsername("测试账号"); + userFullInfoDTO.setUserId(userInfo.getId()); + userFullInfoDTO.setIdentifier(userInfo.getRealName()); + userFullInfoDTO.setRealName(userInfo.getRealName()); + userFullInfoDTO.setUsername(userInfo.getRealName()); return userFullInfoDTO; } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/credential/AccountIdLoginUserDetailService.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/credential/AccountIdLoginUserDetailService.java deleted file mode 100644 index 6c7ba35..0000000 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/credential/AccountIdLoginUserDetailService.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.ningdatech.pmapi.user.security.auth.credential; - - -import com.ningdatech.pmapi.user.manage.UserAuthLoginManage; -import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; -import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; -import lombok.RequiredArgsConstructor; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.core.userdetails.UsernameNotFoundException; -import org.springframework.stereotype.Service; - -import java.util.Objects; - -/** - * @author LiuXinXin - * @date 2022/9/30 上午9:49 - */ - -@Service("accountIdLoginUserDetailService") -@RequiredArgsConstructor -public class AccountIdLoginUserDetailService implements UserDetailsService { - - private final UserAuthLoginManage userAuthLoginManage; - - @Override - public UserInfoDetails loadUserByUsername(String accountId) throws UsernameNotFoundException { - UserFullInfoDTO userFullInfoDTO = userAuthLoginManage.queryUserInfoInAccountIdAuth(accountId); - if (Objects.isNull(userFullInfoDTO)) { - throw new UsernameNotFoundException(String.format("%s user not exist", accountId)); - } - UserInfoDetails userInfoDetails = new UserInfoDetails(); - userInfoDetails.setUserId(userFullInfoDTO.getUserId()); - userInfoDetails.setUsername(userFullInfoDTO.getUsername()); - userInfoDetails.setRealName(userFullInfoDTO.getRealName()); - userInfoDetails.setRole(userFullInfoDTO.getRole()); - userInfoDetails.setRegionCode(userFullInfoDTO.getRegionCode()); - userInfoDetails.setCompanyId(userFullInfoDTO.getCompanyId()); - userInfoDetails.setIdentifier(userFullInfoDTO.getIdentifier()); - userInfoDetails.setPassword(userFullInfoDTO.getCredential()); - return userInfoDetails; - } -}