更新睡眠习惯
This commit is contained in:
@@ -306,6 +306,100 @@ class MHTBlueToothController extends GetControllerEx<MHTBlueToothModel> {
|
||||
return result; // 在 requestWithLog 完成之后返回 result
|
||||
}
|
||||
|
||||
saveJiYiData(sleepData) async {
|
||||
String serviceAddress = ServiceConstant.service_address;
|
||||
String serviceName = ServiceConstant.server_service;
|
||||
String serviceApi = ServiceConstant.user_setting;
|
||||
String type = "sleep_jiyi_${sleepData['mac']}";
|
||||
String queryUrl = "${serviceAddress}${serviceName}${serviceApi}";
|
||||
var data = {
|
||||
"type": type,
|
||||
"mac": sleepData['mac'],
|
||||
"time": DateTime.now().millisecondsSinceEpoch,
|
||||
"data": sleepData,
|
||||
};
|
||||
await requestWithLog(
|
||||
logTitle: "更新睡眠记忆",
|
||||
method: MyHttpMethod.put,
|
||||
queryUrl: queryUrl,
|
||||
data: data,
|
||||
);
|
||||
}
|
||||
|
||||
loadJiYiData(String mac, {int time = 3}) async {
|
||||
String serviceAddress = ServiceConstant.service_address;
|
||||
String serviceName = ServiceConstant.server_service;
|
||||
String serviceApi = ServiceConstant.user_setting;
|
||||
String type = "sleep_jiyi_${mac}";
|
||||
String queryUrl =
|
||||
"${serviceAddress}${serviceName}${serviceApi}?type=${type}";
|
||||
// 使用 Future 来等待异步操作完成
|
||||
Map<String, dynamic> result = {};
|
||||
await requestWithLog(
|
||||
logTitle: "更新记忆",
|
||||
method: MyHttpMethod.get,
|
||||
queryUrl: queryUrl,
|
||||
onSuccess: (res) {
|
||||
ef.log("加载记忆成功: ${res.data}");
|
||||
result = res.data; // 将返回的数据存入 result
|
||||
},
|
||||
onFailure: (res) {
|
||||
ef.log("加载记忆失败: ${res.msg}");
|
||||
result = {}; // 如果失败,可以返回空的 Map
|
||||
},
|
||||
);
|
||||
|
||||
return result; // 在 requestWithLog 完成之后返回 result
|
||||
}
|
||||
|
||||
saveMattressTimeData(sleepData) async {
|
||||
String serviceAddress = ServiceConstant.service_address;
|
||||
String serviceName = ServiceConstant.server_service;
|
||||
String serviceApi = ServiceConstant.user_setting;
|
||||
String type = "sleep_new_time_${sleepData['mac']}";
|
||||
String queryUrl = "${serviceAddress}${serviceName}${serviceApi}";
|
||||
var data = {
|
||||
"type": type,
|
||||
"mac": sleepData['mac'],
|
||||
"time": DateTime.now().millisecondsSinceEpoch,
|
||||
"data": sleepData,
|
||||
};
|
||||
await requestWithLog(
|
||||
logTitle: "更新新版倒计时",
|
||||
method: MyHttpMethod.put,
|
||||
queryUrl: queryUrl,
|
||||
data: data,
|
||||
);
|
||||
}
|
||||
|
||||
loadMattressTimeData(String mac,{int time = 3}) async {
|
||||
String serviceAddress = ServiceConstant.service_address;
|
||||
String serviceName = ServiceConstant.server_service;
|
||||
String serviceApi = ServiceConstant.user_setting;
|
||||
String type = "sleep_new_time_${mac}";
|
||||
String queryUrl =
|
||||
"${serviceAddress}${serviceName}${serviceApi}?type=${type}";
|
||||
|
||||
// 使用 Future 来等待异步操作完成
|
||||
Map<String, dynamic> result = {};
|
||||
|
||||
await requestWithLog(
|
||||
logTitle: "更新新版倒计时",
|
||||
method: MyHttpMethod.get,
|
||||
queryUrl: queryUrl,
|
||||
onSuccess: (res) {
|
||||
ef.log("更新新版倒计时成功: ${res.data}");
|
||||
result = res.data; // 将返回的数据存入 result
|
||||
},
|
||||
onFailure: (res) {
|
||||
ef.log("更新新版倒计时失败: ${res.msg}");
|
||||
result = {}; // 如果失败,可以返回空的 Map
|
||||
},
|
||||
);
|
||||
|
||||
return result; // 在 requestWithLog 完成之后返回 result
|
||||
}
|
||||
|
||||
//todo 解绑的时候删除自己所拥有的所有设备的睡眠习惯
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user