From 117569811ad67a03468ed571a609e9ec51804890 Mon Sep 17 00:00:00 2001 From: "DESKTOP-4RNDQIC\\29019" <290198252@qq.com> Date: Sun, 12 Jul 2020 15:59:34 +0800 Subject: [PATCH] no message --- App/Controllers/Doc.php | 83 +++++++++++++++++++++++++----------- App/Controllers/NewUi.php | 16 +++---- App/Models/Doc.php | 14 +++++++ App/Views/blog/index.html | 88 +++++++++++++++++++++++++++------------ Core/Controller.php | 4 +- 5 files changed, 147 insertions(+), 58 deletions(-) diff --git a/App/Controllers/Doc.php b/App/Controllers/Doc.php index 7249303..d8da6ba 100644 --- a/App/Controllers/Doc.php +++ b/App/Controllers/Doc.php @@ -4,48 +4,83 @@ namespace App\Controllers; use App\Models; class Doc extends \Core\Controller { - function docTypeAction(){ + function docTypeAction() + { $docModel = new Models\Doc(); $types = $docModel->getTypes(); - $type = json_encode($types,JSON_FORCE_OBJECT); - $this->JsonResp(200,$type,"ok"); + $type = json_encode($types, JSON_FORCE_OBJECT); + $this->JsonResp(200, $type, "ok"); } - public function docsAction(){ - if(isset($this->input->id)){ + + public function docsAction() + { + if (isset($this->input->id)) { $docs = new Models\Doc(); $ret = $docs->docs($this->input->id); - $this->JsonResp(200,$ret,"OK"); - }else{ - $this->JsonResp(200,null,"error"); + $this->JsonResp(200, $ret, "OK"); + } else { + $this->JsonResp(200, null, "error"); } } - public function docAction(){ - if(isset($this->input->id)) { + + public function docAction() + { + if (isset($this->input->id)) { $docs = new Models\Doc(); $ret = $docs->doc($this->input->id); - $this->JsonResp(200,$ret,"OK"); - }else{ - $this->JsonResp(200,null,"error"); + $this->JsonResp(200, $ret, "OK"); + } else { + $this->JsonResp(200, null, "error"); } } - public function docTitleAction(){ + + public function docTitleAction() + { $docs = new Models\Doc(); $ret = $docs->AllTitle(); - $this->JsonResp(200,$ret,"OK"); + $this->JsonResp(200, $ret, "OK"); } - public function countAction(){ - $docs = new Models\Doc(); - $ret = $docs->Count(); - $this->JsonResp(200,$ret,"OK"); + + public function countAction() + { + $docs = new Models\Doc(); + $ret = $docs->Count(); + $this->JsonResp(200, $ret, "OK"); } + // 查找文件名字 - function articleSearchAction(){ - if(isset($this->input->title)){ + function articleSearchAction() + { + if (isset($this->input->title)) { $docModel = new Models\Doc(); $titles = $docModel->titleLikeDoc($this->input->title); - $this->JsonResp(0,$titles,"OK"); - }else{ - $this->JsonResp(200,null,"error"); + $this->JsonResp(0, $titles, "OK"); + } else { + $this->JsonResp(200, null, "error"); } } + + function typedocAction() + { + $limit = 5; + $type = 0; + $offset = 0; + if (len($this->params) == 3) { + $limit = $this->params[0]; + $offset = $this->params[1]; + $type = $this->params[3]; + } + $docModel = new Models\Doc(); + $typedoc = $docModel->pageDoc($limit, $offset, $type); + $this->JsonResp(200, $typedoc, "error"); + + } + + function typeCountAction() + { + $type = $this->params[0]; + $docModel = new Models\Doc(); + $count = $docModel->typeCounts($type); + $this->JsonResp(200, $count, "error"); + } } \ No newline at end of file diff --git a/App/Controllers/NewUi.php b/App/Controllers/NewUi.php index c8e907f..fac1bec 100644 --- a/App/Controllers/NewUi.php +++ b/App/Controllers/NewUi.php @@ -13,18 +13,20 @@ class NewUi extends Controller { function indexAction(){ $docModel = new Models\Doc(); - $fisrtpage = $docModel->topDoc(); - + $limit = 5; + $offset = 0; $firstpagedocs = []; $typedocs = $docModel->getAllTypeDocs(); $titles = $docModel->AllTitle(); $groups = $docModel->getGroups(); $groupstype = $docModel->GetAllGroupType(); + if(sizeof($this->params) == 2){ + $limit = $this->params[0]; + $offset = $this->params[1]; + } echo "
"; - print_r($this->route_params); - print_r($this->params); - echo ""; - + echo ""; + $fisrtpage = $docModel->pageDoc($limit,$offset,5); foreach ($fisrtpage as $key => $value) { $obj['title'] = $value['title']; @@ -65,7 +67,7 @@ class NewUi extends Controller } function articleAction(){ if(sizeof($this->params) < 2){ - + } } } \ No newline at end of file diff --git a/App/Models/Doc.php b/App/Models/Doc.php index d8273db..92d364d 100644 --- a/App/Models/Doc.php +++ b/App/Models/Doc.php @@ -73,6 +73,20 @@ class Doc extends Model $recv = $stmt->fetchAll(); return $recv; } + public function typeCounts($type){ + $db = static::getDB(); + $stmt = $db->query('select count(id) from doc where doc.type = '.$type); + $recv = $stmt->fetchAll(); + return $recv; + } + public function pageDoc($limit ,$offset,$type){ + $result = []; + $db = static::getDB(); + $stmt = $db->query('select * from doc where doc.type = '.$type. ' limit '.$limit.' offset '.$offset); + $recv = $stmt->fetchAll(); + print_r('select * from doc where doc.type = '.$type. ' limit '.$limit.' offset '.$offset); + return $recv; + } public function doc($id){ if(is_integer($id)){ $db = static::getDB(); diff --git a/App/Views/blog/index.html b/App/Views/blog/index.html index b695231..a17f6b1 100644 --- a/App/Views/blog/index.html +++ b/App/Views/blog/index.html @@ -21,7 +21,7 @@