use of org.example.security.auth.entity.UserInfo in project spring-boot-learning-demo by rookie-ricardo.
the class CustomUserDetailsService method loadUserByUsername.
@Override
public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
log.debug("开始登陆验证,用户名为: {}", s);
// 根据用户名验证用户
QueryWrapper<UserInfo> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(UserInfo::getUsername, s);
UserInfo userInfo = userService.getOne(queryWrapper);
if (userInfo == null) {
throw new UsernameNotFoundException("用户名不存在,登陆失败。");
}
// 构建UserDetail对象
UserDetail userDetail = new UserDetail();
userDetail.setUserInfo(userInfo);
List<RoleInfo> roleInfoList = roleInfoService.listRoleByUserId(userInfo.getId());
userDetail.setRoleInfoList(roleInfoList);
return userDetail;
}
use of org.example.security.auth.entity.UserInfo in project spring-boot-learning-demo by rookie-ricardo.
the class UserServiceTest method insertData.
@Test
public void insertData() {
UserInfo userInfo = new UserInfo();
userInfo.setUsername("test");
userInfo.setPassword(passwordEncoder.encode("123456"));
userInfo.setActiveStatus(1);
userInfo.setCreateTime(LocalDateTime.now());
boolean save = userService.save(userInfo);
if (save) {
System.out.println("插入成功");
}
}
Aggregations