first commit
This commit is contained in:
54
Web/imasBackend/postSetting.php
Normal file
54
Web/imasBackend/postSetting.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
include_once "db_config.php";
|
||||
date_default_timezone_set('Asia/Shanghai');
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
header("Access-Control-Allow-Methods: POST, GET, OPTIONS");
|
||||
header("Access-Control-Allow-Headers: Content-Type");
|
||||
|
||||
$input = json_decode(file_get_contents('php://input'), true);
|
||||
|
||||
if (!isset($input["boot"]) || !isset($input["shutdown"]) || !isset($input["start"]) ||
|
||||
!isset($input["end"]) || !isset($input["min_humidity"]) || !isset($input["max_humidity"]) ||
|
||||
!isset($input["min_temperature"]) || !isset($input["max_temperature"]) ||
|
||||
!isset($input["enable_boot"]) || !isset($input["enable_humidify"]) ||
|
||||
!isset($input["enable_temp_threshold"]) || !isset($input["enable_humi_threshold"])) {
|
||||
echo json_encode(["error" => "无效的请求数据"]);
|
||||
exit();
|
||||
}
|
||||
|
||||
// 获取输入数据
|
||||
$boot = $input["boot"];
|
||||
$shutdown = $input["shutdown"];
|
||||
$start = $input["start"];
|
||||
$end = $input["end"];
|
||||
$min_humidity = $input["min_humidity"];
|
||||
$max_humidity = $input["max_humidity"];
|
||||
$min_temperature = $input["min_temperature"];
|
||||
$max_temperature = $input["max_temperature"];
|
||||
$enable_boot = $input["enable_boot"];
|
||||
$enable_humidify = $input["enable_humidify"];
|
||||
$enable_temp_threshold = $input["enable_temp_threshold"];
|
||||
$enable_humi_threshold = $input["enable_humi_threshold"];
|
||||
|
||||
|
||||
// 更新数据库
|
||||
$queryString = "UPDATE control_list SET
|
||||
boot='$boot',
|
||||
shutdown='$shutdown',
|
||||
start='$start',
|
||||
end='$end',
|
||||
min_humidity='$min_humidity',
|
||||
max_humidity='$max_humidity',
|
||||
min_temperature='$min_temperature',
|
||||
max_temperature='$max_temperature',
|
||||
enable_boot='$enable_boot',
|
||||
enable_humidify='$enable_humidify',
|
||||
enable_temp_threshold='$enable_temp_threshold',
|
||||
enable_humi_threshold='$enable_humi_threshold'";
|
||||
|
||||
if (mysqli_query($conn, $queryString)) {
|
||||
echo json_encode(["success" => "设置更新成功"]);
|
||||
} else {
|
||||
echo json_encode(["error" => "设置更新失败: " . mysqli_error($conn)]);
|
||||
}
|
||||
|
Reference in New Issue
Block a user