import 'package:get/get.dart';
import 'package:naiyouwl/app/data/model/NodeMode.dart';
import 'package:naiyouwl/app/data/model/UserMode.dart';
import 'package:naiyouwl/app/network/api_service.dart';
import 'package:naiyouwl/app/controller/controllers.dart';

import '../common/constants.dart';
import '../controller/GlobalController.dart';
import '../data/model/LocalUser.dart';
import '../data/model/SysConfig.dart';
import 'local_storage_service.dart';

class UserService {
  final GlobalController globalController;

  UserService(this.globalController);



  Future<void> fetchUserinfo() async {
    try {
      final user = await ApiService().userinfo("/api/client/v4/userinfo");
      globalController.updateUserInfo(user);
      await globalController.fetchNodes();
      return;
    } catch (e) {
      globalController.handleApiError("获取用户信息失败: $e");
      return;
    }
  }


  Future<LocalUser?> fetchLocalUser() async {
    final localStorageService = Get.find<LocalStorageService>();
    return await localStorageService.fetchLocalUser();
  }
}


 
 
