first commit
This commit is contained in:
26
controllers/api/v1/IndexController.php
Normal file
26
controllers/api/v1/IndexController.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace app\controllers\api\v1;
|
||||
|
||||
use app\controllers\BaseController;
|
||||
use app\models\Brand;
|
||||
use app\models\BrandRunway;
|
||||
use yii\web\Controller;
|
||||
|
||||
class IndexController extends BaseController
|
||||
{
|
||||
public function actionMain()
|
||||
{
|
||||
|
||||
$model = BrandRunway::find()->where(['is_deleted' => 0])->limit(2)->asArray()->all();
|
||||
|
||||
foreach ($model as &$item) {
|
||||
$item['cover'] = 'http://static.23cm.cn/11133613f321ed5eae0dc597f3451cae/37fdd980e520e8632f271730a30e88fc-h480';
|
||||
$item['brand_name'] = Brand::findOne($item['brand_id'])->name;
|
||||
}
|
||||
return $this->asJson([
|
||||
'code' => 0,
|
||||
'data' => $model
|
||||
]);
|
||||
}
|
||||
}
|
||||
39
controllers/api/v1/RunwayController.php
Normal file
39
controllers/api/v1/RunwayController.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace app\controllers\api\v1;
|
||||
|
||||
use app\common\ImageHelper;
|
||||
use app\components\serializers\Serializer;
|
||||
use app\controllers\BaseController;
|
||||
use app\models\Brand;
|
||||
use app\models\BrandRunway;
|
||||
use app\models\BrandRunwayImages;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\web\Controller;
|
||||
|
||||
class RunwayController extends BaseController
|
||||
{
|
||||
|
||||
public function actionView()
|
||||
{
|
||||
|
||||
$runwayId = \Yii::$app->request->get('id');
|
||||
|
||||
$runway = BrandRunway::find()->where(['id' => $runwayId])->asArray()->one();
|
||||
$runway['brand_name'] = Brand::findOne($runway['brand_id'])->name;
|
||||
$runwayImages = BrandRunwayImages::find()->where(['runway_id' => $runway['id']])->asArray()->all();
|
||||
|
||||
foreach ($runwayImages as &$image) {
|
||||
$image['s'] = ImageHelper::imageMogr2H480(\Yii::$app->params['cdnAddress'] . $image['name']);
|
||||
$image['xl'] = ImageHelper::imageMogr2H1080(\Yii::$app->params['cdnAddress'] . $image['name']);
|
||||
}
|
||||
|
||||
return $this->asJson([
|
||||
'code' => 0,
|
||||
'data' => [
|
||||
'info' => $runway,
|
||||
'images' => $runwayImages
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user