package cn.van.business.service;

import cn.hutool.crypto.digest.MD5;
import cn.van.business.model.user.AdminUser;
import cn.van.business.util.Util;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

@Service
public class AdminUserService {


    // 模拟数据库存储
    private static final Map<String, AdminUser> users = new HashMap<>();

    static {
        // 初始化一个测试用户（生产环境应从数据库加载）
        AdminUser user = new AdminUser();
        user.setUsername("van");
        String password = Util.md5("LK.807878712");
        user.setPassword(new BCryptPasswordEncoder().encode(password));
        users.put("van", user);
    }

    public AdminUser findByUsername(String username) {
        return users.get(username);
    }
}
