// Path: auth-server/src/main/java/com/lanshiqin/authserver/core/entity/Account.java
// public class Account {
//     @Id
//     private String id;          // 主键
//     private String userName;    // 用户名
//     private String passWord;    // 密码
//     private String[] roles;     // 角色
// 
//     public String getId() {
//         return id;
//     }
// 
//     public void setId(String id) {
//         this.id = id;
//     }
// 
//     public String getUserName() {
//         return userName;
//     }
// 
//     public void setUserName(String userName) {
//         this.userName = userName;
//     }
// 
//     public String getPassWord() {
//         return passWord;
//     }
// 
//     public void setPassWord(String passWord) {
//         this.passWord = passWord;
//     }
// 
//     public String[] getRoles() {
//         return roles;
//     }
// 
//     public void setRoles(String[] roles) {
//         this.roles = roles;
//     }
// }
// 
// Path: auth-server/src/main/java/com/lanshiqin/authserver/core/repository/AccountRepository.java
// @Component
// public interface AccountRepository extends MongoRepository<Account, String> {
// 
//     /**
//      * 根据用户名查找账户信息
//      * @param username 用户名
//      * @return 账户信息
//      */
//     Account findByUserName(String username);
// }


import com.lanshiqin.authserver.core.entity.Account;
import com.lanshiqin.authserver.core.repository.AccountRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.User;
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;
package com.lanshiqin.authserver.core.security;


/**
 * 用户信息服务
 * 实现 Spring Security的UserDetailsService接口方法，用于身份认证
 */
@Service
public class DomainUserDetailsService implements UserDetailsService {

    @Autowired
    private AccountRepository accountRepository;    // 账户数据操作接口

    /**
     * 根据用户名查找账户信息并返回用户信息实体
     * @param username 用户名
     * @return 用于身份认证的 UserDetails 用户信息实体
     * @throws UsernameNotFoundException
     */
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
// Path: auth-server/src/main/java/com/lanshiqin/authserver/core/entity/Account.java
// public class Account {
//     @Id
//     private String id;          // 主键
//     private String userName;    // 用户名
//     private String passWord;    // 密码
//     private String[] roles;     // 角色
// 
//     public String getId() {
//         return id;
//     }
// 
//     public void setId(String id) {
//         this.id = id;
//     }
// 
//     public String getUserName() {
//         return userName;
//     }
// 
//     public void setUserName(String userName) {
//         this.userName = userName;
//     }
// 
//     public String getPassWord() {
//         return passWord;
//     }
// 
//     public void setPassWord(String passWord) {
//         this.passWord = passWord;
//     }
// 
//     public String[] getRoles() {
//         return roles;
//     }
// 
//     public void setRoles(String[] roles) {
//         this.roles = roles;
//     }
// }
// 
// Path: auth-server/src/main/java/com/lanshiqin/authserver/core/repository/AccountRepository.java
// @Component
// public interface AccountRepository extends MongoRepository<Account, String> {
// 
//     /**
//      * 根据用户名查找账户信息
//      * @param username 用户名
//      * @return 账户信息
//      */
//     Account findByUserName(String username);
// }


// Path: auth-server/src/main/java/com/lanshiqin/authserver/core/security/DomainUserDetailsService.java
import com.lanshiqin.authserver.core.entity.Account;
import com.lanshiqin.authserver.core.repository.AccountRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.User;
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;

package com.lanshiqin.authserver.core.security;


/**
 * 用户信息服务
 * 实现 Spring Security的UserDetailsService接口方法，用于身份认证
 */
@Service
public class DomainUserDetailsService implements UserDetailsService {

    @Autowired
    private AccountRepository accountRepository;    // 账户数据操作接口

    /**
     * 根据用户名查找账户信息并返回用户信息实体
     * @param username 用户名
     * @return 用于身份认证的 UserDetails 用户信息实体
     * @throws UsernameNotFoundException
     */
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        Account account = accountRepository.findByUserName(username);