package com.example.myapplication.service;

import android.content.Context;
import android.content.SharedPreferences;

public class UserService {
    public static String getUser(Context ctx) {
        SharedPreferences prefs = ctx.getSharedPreferences("app_prefs", Context.MODE_PRIVATE);
        String account = prefs.getString("currentUser", null);
        if (account == null) return "张三";

        com.example.myapplication.repository.UserRepository repo = new com.example.myapplication.repository.UserRepository(ctx);
        com.example.myapplication.domain.User u = repo.getUserByAccount(account);
        return u != null ? u.getName() : account;
    }
}