package com.jiayue.ssi.service.impl;

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 com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jiayue.ssi.entity.SysUser;
import com.jiayue.ssi.mapper.SysUserMapper;

/**
 * TODO
 *
 * @author xsl
 * @version 3.0
 */
@Service
public class UserServiceImpl implements UserDetailsService {
    @Autowired
    SysUserMapper sysUserMapper;

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        SysUser sysUser = sysUserMapper.selectOne(new QueryWrapper<SysUser>().eq("c_name",username));
        if (sysUser == null) {
            throw new UsernameNotFoundException("用户名错误！");
        }
        return sysUser;
    }
}
