get config to gen 512 feature

This commit is contained in:
dongpd 2021-04-20 10:33:22 +07:00
parent bf93f6c9d0
commit 1b1162f3c2

View File

@ -248,6 +248,8 @@ class ApiController extends Controller {
public function actionAutoGenFeature() {
Yii::$app->response->format = "json";
if (!$this->check512())
return ["status" => false];
$updating = \app\models\SyncUrl::findOne(['key_config' => 'updating']);
if (!$updating) {
$model = new \app\models\SyncUrl();
@ -410,26 +412,46 @@ class ApiController extends Controller {
}
}
public function check512() {
$tempConfig = json_decode(file_get_contents("http://localhost:4004/ReadEngineConfig", false, stream_context_create([
'http' => [
'header' => "Content-Type: application/json",
'method' => "POST"
]
])), true);
if (!$tempConfig['status'])
return false;
$engineConfig = json_decode($tempConfig['data'], true);
if (count($engineConfig['data']['engines']) == 0)
return false;
$checkConfig = json_decode(file_get_contents("http://localhost:4004/ReadConfig", false, stream_context_create([
'http' => [
'header' => "Content-Type: application/json",
'method' => "POST",
'content' => json_encode([
'path' => $engineConfig['data']['engines'][0]['path']
])
]
])), true);
if (!$checkConfig['status'])
return false;
$config_json = "";
if ($checkConfig['status']) {
$config_json = json_decode($checkConfig['data'], true);
$check512 = $config_json['feature']['type2']['enable'];
if ($check512 !== "0")
return true;
}
return false;
}
public function actionTest() {
$check = \app\models\SyncUrl::findOne(['key_config' => 'updating']);
$check->data = "false";
$check->save();
return var_dump($check);
// file_get_contents("http://localhost:2305/update-feature");
// return;
set_time_limit(0);
$lists = ListManagement::find()->all();
foreach ($lists as $key => $value) {
$extract = false;
$images = json_decode($value->image, true);
$newImgs = [];
foreach ($images as $k => $v) {
$v['features512'] = [];
$newImgs[] = $v;
}
$value->image = json_encode($newImgs);
$value->save();
}
$updating = \app\models\SyncUrl::findOne(['key_config' => 'updating']);
var_dump($updating->data);
}
public function actionReGenFeature() {
@ -441,6 +463,9 @@ class ApiController extends Controller {
'data' => "false"
]);
} else {
if ($this->check512())
$updating->data = "true";
else
$updating->data = "false";
$updating->save();
}