12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- /**
- * 前台分类相关接口
- * Created by PhpStorm.
- * User: wxj
- * Date: 2019/11/15
- * Time: 17:09
- */
- namespace JinDouYun\Controller\GoodsCategory;
- use Mall\Framework\Core\ErrorCode;
- use Mall\Framework\Core\StatusCode;
- use JinDouYun\Controller\BaseController;
- use JinDouYun\Model\GoodsCategory\MGoodsCategory;
- class ApiGoodsCategory extends BaseController
- {
- private $objMGoodsCategory;
- /**
- * GoodsCategory constructor.
- * @param bool $isCheckAcl
- * @param bool $isMustLogin
- * @throws \Exception
- */
- public function __construct($isCheckAcl = false, $isMustLogin = false)
- {
- parent::__construct($isCheckAcl, $isMustLogin);
- $this->objMGoodsCategory = new MGoodsCategory($this->onlineUserId, $this->onlineEnterpriseId);
- $authorization = $this->request->getServerParam('HTTP_AUTHORIZATION');
- if (!empty($authorization)) {
- self::getUserIdByAuthorization();
- }
- }
- /**
- * 商品分类
- */
- public function getAllCategory()
- {
- $params = $this->request->getRawJson();
- if($this->onlineUserId){
- $data['userCenterId'] = $this->onlineUserId;
- }
- $data['enableStatus'] = StatusCode::$standard;
- $result = $this->objMGoodsCategory->apiGetAllCategory($data);
- if ($result->isSuccess()) {
- $returnData = $result->getData();
- parent::sendOutput($returnData['data'], 0, ['pageTotal'=>count($returnData['data'])]);
- } else {
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- /**
- * 获取所有一级分类或一级分类下的二级分类
- */
- public function getAllCategoryByPid()
- {
- $params['id'] = $this->request->param('request_id');
- $selectParams['pid'] = 0;
- if (isset($params['id']) && (int)$params['id']) {
- $selectParams['pid'] = (int)$params['id'];
- }
- $selectParams['deleteStatus'] = StatusCode::$standard;
- $result = $this->objMGoodsCategory->getCategoryTitleByIds($selectParams);
- if ($result->isSuccess()) {
- $returnData = $result->getData();
- $pageData = [
- 'pageIndex' => 0,
- 'pageSize' => 10,
- 'pageTotal' => count($returnData),
- ];
- parent::sendOutput($returnData, 0, $pageData);
- } else {
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- }
|