Bläddra i källkod

adjust Account Login

master
liuxinxin 1 år sedan
förälder
incheckning
16ca073fb5
2 ändrade filer med 23 tillägg och 50 borttagningar
  1. +23
    -8
      pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserAuthLoginManage.java
  2. +0
    -42
      pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/credential/AccountIdLoginUserDetailService.java

+ 23
- 8
pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserAuthLoginManage.java Visa fil

@@ -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;
}
}

+ 0
- 42
pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/credential/AccountIdLoginUserDetailService.java Visa fil

@@ -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;
}
}

Laddar…
Avbryt
Spara