2023-11-13 11:28:42 +08:00
|
|
|
import 'package:get/get.dart';
|
2024-05-06 14:51:18 +08:00
|
|
|
import 'package:star_lock/tools/storage.dart';
|
2023-11-13 11:28:42 +08:00
|
|
|
|
|
|
|
|
import '../../../../network/api_repository.dart';
|
|
|
|
|
import '../../../../tools/baseGetXController.dart';
|
|
|
|
|
import '../../../../tools/eventBusEventManage.dart';
|
|
|
|
|
import 'groupEditLock_state.dart';
|
|
|
|
|
|
|
|
|
|
class GroupEditLockLogic extends BaseGetXController {
|
|
|
|
|
final GroupEditLockState state = GroupEditLockState();
|
|
|
|
|
|
|
|
|
|
//锁分组里面添加锁
|
2024-03-21 09:35:43 +08:00
|
|
|
Future<void> lockGroupAddLock(List lockIds) async {
|
2024-05-06 14:51:18 +08:00
|
|
|
if (lockIds.isEmpty) {
|
2024-06-05 14:36:31 +08:00
|
|
|
showToast('请选择锁'.tr);
|
2024-03-21 09:35:43 +08:00
|
|
|
return;
|
|
|
|
|
}
|
2023-11-13 11:28:42 +08:00
|
|
|
var entity = await ApiRepository.to.lockGroupAddLock(
|
2024-05-06 14:51:18 +08:00
|
|
|
lockIds: lockIds, groupId: state.selectGroupListItem.keyGroupId!);
|
2023-11-13 11:28:42 +08:00
|
|
|
if (entity.errorCode!.codeIsSuccessful) {
|
2024-10-19 09:38:57 +08:00
|
|
|
showToast('添加成功'.tr, something: () {
|
2024-06-05 14:36:31 +08:00
|
|
|
eventBus.fire(LockGroupEditGroupLockRefreshEvent());
|
|
|
|
|
eventBus.fire(RefreshLockListInfoDataEvent());
|
|
|
|
|
Get.close(2);
|
|
|
|
|
});
|
2023-11-13 11:28:42 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//锁分组里面添加锁
|
2024-03-21 09:35:43 +08:00
|
|
|
Future<void> lockGroupDeletLock(List lockIds) async {
|
2024-05-06 14:51:18 +08:00
|
|
|
if (lockIds.isEmpty) {
|
2024-06-05 14:36:31 +08:00
|
|
|
showToast('请选择锁'.tr);
|
2024-03-21 09:35:43 +08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var entity = await ApiRepository.to.lockGroupDeletLock(lockIds: lockIds);
|
2023-11-13 11:28:42 +08:00
|
|
|
if (entity.errorCode!.codeIsSuccessful) {
|
2024-08-21 14:12:15 +08:00
|
|
|
showToast('删除成功'.tr, something: () {
|
2024-06-05 14:36:31 +08:00
|
|
|
eventBus.fire(LockGroupEditGroupLockRefreshEvent());
|
|
|
|
|
eventBus.fire(RefreshLockListInfoDataEvent());
|
|
|
|
|
Get.close(2);
|
|
|
|
|
});
|
2023-11-13 11:28:42 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-13 18:07:00 +08:00
|
|
|
Future<void> getVipStatus() async {
|
|
|
|
|
final bool? isVip = await Storage.getBool(saveIsVip);
|
|
|
|
|
state.isVip.value = isVip ?? false;
|
|
|
|
|
state.isVip.refresh();
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-23 17:48:06 +08:00
|
|
|
}
|