| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- namespace business\controllers;
- use biz\goods\services\PicCategoryService;
- use biz\goods\services\PicService;
- use Yii;
- use common\components\util;
- class PicController extends BaseController
- {
-
- //图库列表 shish 2019.12.7
- public function actionList()
- {
- $get = Yii::$app->request->get();
- $where = [];
- $where['merchantId'] = $this->merchantId;
- $categoryId = isset($get['categoryId']) && is_numeric($get['categoryId']) ? $get['categoryId'] : -1;
- if ($categoryId != -1) {
- $where['categoryId'] = $get['categoryId'];
- }
- $list = PicCategoryService::getPicList($where);
- util::success($list);
- }
-
- //上传图片 shish 2019.12.7
- public function actionAdd()
- {
- $img = '/uploads/201905/25/jpg/19052591518_12358.jpg';
- $prefix = Yii::$app->params['imgUrl'];
- $url = $prefix . $img;
- $merchantId = Yii::$app->params['merchantId'];
- $time = time();
- $name = '未命名';
- $data = ['img' => $img, 'merchantId' => $merchantId, 'name' => $name, 'addTime' => $time];
- $pic = PicService::add($data);
- util::success(['id' => $pic['id'], 'url' => $url, 'shortUrl' => $img]);
- }
- }
|