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