You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
1.1 KiB
30 lines
1.1 KiB
package com.example.demo.serviceImpl;
|
|
|
|
|
|
import com.example.demo.domain.entity.Admin;
|
|
import com.example.demo.mapper.AdminMapper;
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.security.core.userdetails.UserDetails;
|
|
import org.springframework.security.core.userdetails.UserDetailsService;
|
|
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.util.ObjectUtils;
|
|
@Transactional
|
|
@Service
|
|
@RequiredArgsConstructor
|
|
|
|
public class UserDetailServiceImpl implements UserDetailsService {
|
|
@Autowired
|
|
private AdminMapper adminMapper;
|
|
|
|
@Override
|
|
public UserDetails loadUserByUsername(String account) throws UsernameNotFoundException {
|
|
Admin admin=adminMapper.selectByName(account);
|
|
if(ObjectUtils.isEmpty(admin)){
|
|
throw new UsernameNotFoundException("用户名不存在");
|
|
}
|
|
return admin;
|
|
}
|
|
}
|