package com.ruoyi.framework.web.service;

import com.ruoyi.common.constant.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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;

/**
 * 用户验证处理
 *
 * @author ruoyi
 */
@Service
public class AllUserDetailsServiceImpl implements UserDetailsService
{
    private static final Logger log = LoggerFactory.getLogger(AllUserDetailsServiceImpl.class);

	@Autowired
	private UserDetailsServiceImpl userDetailsService;

	@Autowired
	private AppUserDetailsServiceImpl appUserDetailsService;


    @Override
    public UserDetails loadUserByUsername(String var) throws UsernameNotFoundException
    {
       if(var.contains(Constants.BGT)||var.contains(Constants.WGZ)){
		   return appUserDetailsService.loadUserByUsername(var);
	   } else {
		   return userDetailsService.loadUserByUsername(var);
	   }

    }
}
