refactor(all): change sql to postgresql
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
package xin.merlin.myblog_server.config;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import xin.merlin.myblog_server.entity.Account;
|
||||
import xin.merlin.myblog_server.service.impl.AccountServiceImpl;
|
||||
|
||||
import xin.merlin.myblog_server.entity.User;
|
||||
import xin.merlin.myblog_server.service.impl.UserServiceImpl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -14,12 +14,15 @@ import java.util.ArrayList;
|
||||
public class LoginDetails implements UserDetailsService {
|
||||
|
||||
@Autowired
|
||||
private AccountServiceImpl accountServiceImpl;
|
||||
private UserServiceImpl userServiceImpl;
|
||||
|
||||
@Override
|
||||
public CustomUserDetails loadUserByUsername(String u_account) throws UsernameNotFoundException {
|
||||
Account account = accountServiceImpl.getAccountInfo(u_account);
|
||||
return new CustomUserDetails(account.getU_account(), account.getU_password(),account.getU_id(), account.getRole(),new ArrayList<>());
|
||||
QueryWrapper<User> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("account", u_account);
|
||||
User user = userServiceImpl.getOne(queryWrapper);
|
||||
if(user == null) return null;
|
||||
return new CustomUserDetails(user.getAccount(), user.getPassword(),user.getId(),new ArrayList<>());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user