diff --git a/server/Application/Api/Controller/HelpController.class.php b/server/Application/Api/Controller/HelpController.class.php new file mode 100644 index 0000000..72237cb --- /dev/null +++ b/server/Application/Api/Controller/HelpController.class.php @@ -0,0 +1,97 @@ + "", 'is_del' => 0); + $items = D("item")->where($w) + ->order("addtime desc") + ->field(array( + 'item_id', + 'item_name', + 'item_description', + 'addtime', + 'item_type', + 'is_del', + )) + ->select(); + $total = D("item")->where($w)->count(); + $this->sendResult(array("items" => $items, "total" => $total)); + } + + //展示 页面列表 + public function search($keyword = "") + { + //获取公开的项目id + $item_model = D("item"); +// $item_ids = $item_model->where(array("password" => "", "is_del" => 0))->getField("item_id", true); + $item_data = $this->getItems(); + $item_ids = array_keys($item_data); + + if (count($item_ids) <= 0) { + $this->sendResult(array("items" => null, "total" => 0)); + } + + $w = array("item_id" => array("in", $item_ids), 'is_del' => 0); + + if (trim($keyword)) { + $w["page_title|page_content"] = array("like", "%{$keyword}%"); + } + + $page_m = D("page"); + $t = $page_m->where($w)->field("page_id,page_title,item_id"); + $page = $_REQUEST['page']; + $page_size = $_REQUEST['page_size']; + if ($page > 0 && $page_size > 0) { + $t->page($page, $page_size); + } + $list = $t->order("addtime desc")->select(); + $total = $page_m->where($w)->count(); + + + foreach ($list as &$item) { + //项目数据 + $item['item_data'] = $item_data[$item['item_id']]; + $item['item_cat'] = $item['item_data']['item_cat']; + } + $this->sendResult(array("items" => $list, "total" => $total)); + } + + protected function getItems() + { + $item_data = D('item')->where(array('is_del' => 0, 'password' => ''))->getField('item_id,item_name,is_del'); + foreach ($item_data as &$item) { + $cat_arr = D('catalog') + ->where(array('item_id' => $item['item_id'])) + ->order("level asc,addtime asc") + ->getField('cat_name', true); + if (count($cat_arr) > 0) { + $item['item_cat'] = $item['item_name'] . '-' . implode('-', $cat_arr); + } else { + $item['item_cat'] = $item['item_name']; + } + } + return $item_data; + } +} +