Преглед изворни кода

feat: NG-15: 新会员注册时增加国家与语言选项.

zhangl пре 1 година
родитељ
комит
0feb193ce7
1 измењених фајлова са 4 додато и 3 уклоњено
  1. 4 3
      common/models/Language.php

+ 4 - 3
common/models/Language.php

@@ -63,9 +63,10 @@ class Language extends \common\components\ActiveRecord
     public static function getFromCache()
     {
         $data = Yii::$app->cache->get(Cache::LANGUAGE_KEY);
+        Yii::$app->cache->delete(Cache::LANGUAGE_KEY);
         if (!$data) {
             // 获取信息
-            $data = static::find()->orderBy('ORDER DESC, ACTIVE ASC')->indexBy('ID')->asArray()->all();
+            $data = self::getAllData();
             Yii::$app->cache->set(Cache::LANGUAGE_KEY, $data);
         }
         // i18n转换
@@ -81,7 +82,7 @@ class Language extends \common\components\ActiveRecord
      */
     public static function getAllData()
     {
-        return static::find()->where('1=1')->indexBy('ID')->orderBy('ORDER DESC, ACTIVE ASC')->asArray()->all();
+        return static::find()->where('ACTIVE=1')->indexBy('ID')->orderBy('ORDER DESC, ACTIVE ASC')->asArray()->all();
     }
 
     /**
@@ -91,7 +92,7 @@ class Language extends \common\components\ActiveRecord
     public static function updateToCache()
     {
         // 获取配置
-        $data = static::find()->where('1=1')->orderBy('ORDER DESC, ACTIVE ASC')->asArray()->indexBy('ID')->all();
+        $data = self::getAllData();
         Yii::$app->cache->set(Cache::LANGUAGE_KEY, $data);
         return $data;
     }