Пример #1
0
 public static function flushCacheConfig()
 {
     $data = AdminConfig::find()->all();
     if (is_array($data) && !empty($data)) {
         foreach ($data as $one) {
             $key = $one['key'];
             $value = $one['value'];
             $cache_key = self::ADMIN_CONFIG_CONFIX . $key;
             CCache::set($cache_key, $value);
         }
     }
 }
Пример #2
0
 public function valiadateKey($attribute, $params)
 {
     $key = $this->key;
     $id = $this->id;
     if ($id) {
         $one = AdminConfig::find()->where(["key" => $key])->andWhere(" id != {$id} ")->one();
         if ($one['id']) {
             $this->addError($attribute, "该条目已经存在[{$key}]");
         }
     } else {
         $one = AdminConfig::find()->where(["key" => $key])->one();
         if ($one['id']) {
             $this->addError($attribute, "该条目已经存在[{$key}]");
         }
     }
 }
Пример #3
0
 public function delete()
 {
     //$request_param 		= CRequest::param();
     //$this->_param		= $request_param;
     //$this->initParam();
     # admin 用户不能删除
     if ($id = CRequest::param('id')) {
         $model = AdminConfig::findOne(['id' => $id]);
         if ($model->id) {
             $model->delete();
             echo json_encode(["statusCode" => "200", "message" => 'Delete Success!']);
             exit;
         } else {
             echo json_encode(["statusCode" => "300", "message" => "id => {$id} , is not exist"]);
             exit;
         }
     } else {
         if ($ids = CRequest::param('ids')) {
             $id_arr = explode(",", $ids);
             AdminConfig::deleteAll(['in', 'id', $id_arr]);
             echo json_encode(["statusCode" => "200", "message" => "{$ids} Delete Success!"]);
             exit;
         }
     }
     echo json_encode(["statusCode" => "300", "message" => "id or ids Param is not Exist!"]);
     exit;
 }