import 'package:get/get.dart'; import 'package:sk_base_mobile/apis/api.dart'; import 'package:sk_base_mobile/models/resource.model.dart'; import 'package:sk_base_mobile/store/auth.store.dart'; import 'package:sk_base_mobile/util/logger_util.dart'; class ResourceService extends GetxService { static ResourceService get to => Get.find(); Future init() async { if (AuthStore.to.userInfo.value.id == null) return this; await getResources(); return this; } RxList resources = RxList([]); Future getResources() async { try { final response = await Api.getResources(); resources.value = (response.data as List) .map((item) => ResourceModel.fromJson(item)) .toList(); } catch (e) { LoggerUtil().error('getResources error: $e'); } } // List getDictItemsByCode(String code) { // return dictTypes.firstWhereOrNull((item) => item.code == code)?.dictItems ?? // []; // } }