get()->toArray(); foreach ($aArticleList as $row) { $this->oTGHttp->sendToTG(json_encode($row, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); } $this->oHttp::response(200, 'ok'); } public function Like($aParams) { $aArticleList = ModelArticle::where($this->cmdGood($aParams['aOption'][1]), 'like', '%' . $aParams['aArg'][1] . '%') ->orderBy("user_name") ->get() ->toArray(); if (empty($aArticleList)) { $this->oTGHttp->sendToTG("没有"); } foreach ($aArticleList as $row) { $this->oTGHttp->sendToTG(json_encode($row, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); } $this->oHttp::response(200, 'ok'); } public function Add($aParams) { $newArticle = new ModelArticle(); $newArticle->user_name = $aParams['aArg'][1]; $r = $newArticle->save(); $this->oTGHttp->sendToTG(json_encode($r, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); $this->oHttp::response(200, 'ok'); } public function Del($aParams) { $article = ModelArticle::find($aParams['aArg'][1]); if ($article) { $r = $article->delete(); } else { $r = false; } $this->oTGHttp->sendToTG(json_encode($r, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); $this->oHttp::response(200, 'ok'); } // /ArticleSet__id__user_name xxx public function Set($aParams) { $sField = $this->cmdGood($aParams['aOption'][2]); $article = ModelArticle::find($aParams['aOption'][1]); $sSet = $aParams['aArg'][1]; if ($article) { $article->$sField = $sSet; $r = $article->save(); } else { // 处理未找到的情况 throw new \Exception("Article not found"); } $this->oTGHttp->sendToTG(json_encode($r, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); $this->oHttp::response(200, 'ok'); } }