From c31b9627d25ad852b963c61184f577de6cde8399 Mon Sep 17 00:00:00 2001 From: Terry <2358269014@qq.com> Date: Tue, 24 Sep 2019 20:59:39 +0800 Subject: [PATCH] category services --- services/Category.php | 8 ++++++++ services/category/CategoryMongodb.php | 7 ++++++- services/category/CategoryMysqldb.php | 13 ++++++++++--- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/services/Category.php b/services/Category.php index 1b1521e9..f5c6f2e9 100644 --- a/services/Category.php +++ b/services/Category.php @@ -221,4 +221,12 @@ class Category extends Service { return $this->_category->getFilterCategory($category_id, $parent_id); } + + /** + * 得到category model的全名. + */ + public function getChildCategory($category_id) + { + return $this->_category->getChildCategory($category_id); + } } diff --git a/services/category/CategoryMongodb.php b/services/category/CategoryMongodb.php index 0fdcd8e8..6598da3c 100644 --- a/services/category/CategoryMongodb.php +++ b/services/category/CategoryMongodb.php @@ -500,7 +500,10 @@ class CategoryMongodb extends Service implements CategoryInterface return $data; } - + public function getChildCategory($category_id) { + + return $this->getChildCate($category_id); + } protected function getChildCate($category_id) { //echo $category_id; @@ -521,6 +524,8 @@ class CategoryMongodb extends Service implements CategoryInterface 'name' => $currentName, 'url_key' => $currentUrlKey, 'parent_id' => $one['parent_id'], + 'thumbnail_image' => $one['thumbnail_image'], + 'image' => $one['image'], ]; } } diff --git a/services/category/CategoryMysqldb.php b/services/category/CategoryMysqldb.php index b72f49bf..9c09e485 100644 --- a/services/category/CategoryMysqldb.php +++ b/services/category/CategoryMysqldb.php @@ -578,6 +578,11 @@ class CategoryMysqldb extends Service implements CategoryInterface return $data; } + + public function getChildCategory($category_id) { + + return $this->getChildCate($category_id); + } protected function getChildCate($category_id) { @@ -593,17 +598,19 @@ class CategoryMysqldb extends Service implements CategoryInterface $one =$this->unserializeData($one) ; $currentUrlKey = $one['url_key']; $currentName = $one['name']; - $currentId = (string) $one['_id']; - + $currentId = (string) $one['id']; + $arr[$currentId] = [ //'_id' => $currentId, 'name' => $currentName, 'url_key' => $currentUrlKey, 'parent_id' => $one['parent_id'], + 'thumbnail_image' => $one['thumbnail_image'], + 'image' => $one['image'], ]; } } - + return $arr; } -- GitLab