| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- /**
- * Created by PhpStorm.
- * User: admin
- * Date: 2019/12/1
- * Time: 13:55
- */
- namespace ghs\controllers;
- use bizHd\goods\services\CategoryService;
- use bizHd\goods\services\GoodsCategoryService;
- use Yii;
- use common\components\util;
- use bizHd\goods\classes\CategoryClass;
- class CategoryController extends BaseController
- {
- //分类列表
- public function actionList()
- {
- $get = Yii::$app->request->get();
- //$property = $get['property'] ?? '';
- $list = CategoryService::getCategoryList($this->mainId);
- util::success($list);
- }
- //查看详情 ssh 2019.12.8
- public function actionDetail()
- {
- $id = Yii::$app->request->get('categoryId', 0);
- $category = CategoryService::getById($id);
- CategoryService::valid($category, $this->mainId);
- $info = CategoryService::getInfo($id);
- util::success($info);
- }
- //添加分类 ssh 2019.12.8
- public function actionAdd()
- {
- $post = Yii::$app->request->post();
- $post['sjId'] = $this->sjId;
- $cat = CategoryService::addCategory($post);
- util::success(['id' => $cat['id']]);
- }
- //更新分类 ssh 2019.12.8
- public function actionUpdate()
- {
- $post = Yii::$app->request->post();
- $categoryId = isset($post['categoryId']) ? $post['categoryId'] : 0;
- $category = CategoryService::getById($categoryId);
- CategoryService::valid($category, $this->mainId);
- CategoryService::updateCategory($category, $post);
- util::complete('修改成功');
- }
- //分类启用停用 ssh 2019.12.8
- public function actionChangeStatus()
- {
- $get = Yii::$app->request->get();
- $categoryId = isset($get['categoryId']) ? $get['categoryId'] : 0;
- $status = isset($get['status']) ? $get['status'] : 0;
- $category = CategoryService::getById($categoryId);
- CategoryService::valid($category, $this->mainId);
- CategoryService::changeStatus($categoryId, $status);
- util::complete();
- }
- //删除分类 ssh 2019.12.28
- public function actionDelete()
- {
- $get = Yii::$app->request->get();
- $categoryId = $get['categoryId'] ?? 0;
- $category = CategoryService::getById($categoryId);
- CategoryService::valid($category, $this->mainId);
- CategoryClass::deleteCategory($categoryId);
- util::complete('删除成功');
- }
- //分类排序 ssh 2020.3.11
- public function actionSort()
- {
- $id = Yii::$app->request->get('id', 0);
- $inTurn = Yii::$app->request->get('inTurn', 0);
- $category = CategoryService::getById($id);
- CategoryService::valid($category, $this->mainId);
- CategoryService::updateById($id, ['inTurn' => $inTurn]);
- util::complete();
- }
- }
|