Commit b875193d authored by 张宏's avatar 张宏

1

parent 6456714b
......@@ -16,7 +16,8 @@ class DeviceControlRepository {
/// 远程送电
Future<ResponseModel<Map<String, dynamic>>> powerOn({required int deviceId}) {
return DioRequest.instance.post<Map<String, dynamic>>(
'/app/device/control/powerOn',
// '/app/device/control/powerOn',
'/app/room/device/power/single/on',
data: {'deviceId': deviceId},
);
}
......@@ -24,7 +25,8 @@ class DeviceControlRepository {
/// 远程断电
Future<ResponseModel<Map<String, dynamic>>> powerOff({required int deviceId}) {
return DioRequest.instance.post<Map<String, dynamic>>(
'/app/device/control/powerOff',
// '/app/device/control/powerOff',
'/app/room/device/power/single/off',
data: {'deviceId': deviceId},
);
}
......
......@@ -40,18 +40,18 @@ class RoomRepository {
}
/// 客房服务看板-送电
Future<ResponseModel> powerOn({required int deviceId}) {
Future<ResponseModel> powerOn({required int roomId}) {
return DioRequest.instance.post(
'/app/room/device/power/on',
data: {'deviceId': deviceId},
'/app/room/power/on',
data: {'roomId': roomId},
);
}
/// 客房服务看板-断电
Future<ResponseModel> powerOff({required int deviceId}) {
Future<ResponseModel> powerOff({required int roomId}) {
return DioRequest.instance.post(
'/app/room/device/power/off',
data: {'deviceId': deviceId},
'/app/room/power/off',
data: {'roomId': roomId},
);
}
......
......@@ -33,16 +33,16 @@ class RoomService {
}
/// 送电
Future<void> powerOn({required int deviceId}) async {
final result = await _repository.powerOn(deviceId: deviceId);
Future<void> powerOn({required int roomId}) async {
final result = await _repository.powerOn(roomId: roomId);
if (!result.success) {
throw Exception(result.msg);
}
}
/// 断电
Future<void> powerOff({required int deviceId}) async {
final result = await _repository.powerOff(deviceId: deviceId);
Future<void> powerOff({required int roomId}) async {
final result = await _repository.powerOff(roomId: roomId);
if (!result.success) {
throw Exception(result.msg);
}
......
......@@ -171,7 +171,7 @@ class ServiceIndexCubit extends Cubit<ServiceIndexState> {
if (room == null) {
throw Exception('未找到房间信息');
}
await _roomService.powerOn(deviceId: room['roomId'] as int);
await _roomService.powerOn(roomId: room['roomId'] as int);
emit(state.copyWith(isPoweringOn: false));
} catch (e) {
emit(state.copyWith(isPoweringOn: false));
......@@ -187,7 +187,7 @@ class ServiceIndexCubit extends Cubit<ServiceIndexState> {
if (room == null) {
throw Exception('未找到房间信息');
}
await _roomService.powerOff(deviceId: room['roomId'] as int);
await _roomService.powerOff(roomId: room['roomId'] as int);
emit(state.copyWith(isPoweringOff: false));
} catch (e) {
emit(state.copyWith(isPoweringOff: false));
......
......@@ -172,9 +172,9 @@ class ServiceRoomCubit extends Cubit<ServiceRoomState> {
emit(state.copyWith(isTogglingPower: true));
try {
if (value) {
await _service.powerOn(deviceId: _roomId);
await _service.powerOn(roomId: _roomId);
} else {
await _service.powerOff(deviceId: _roomId);
await _service.powerOff(roomId: _roomId);
}
emit(state.copyWith(isTogglingPower: false, mainPowerOn: value));
} catch (e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment