初始化项目:添加后端代码、ThinkPHP框架、前端资源
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller\app\recommend;
|
||||
|
||||
use app\common\controller\Api;
|
||||
|
||||
/**
|
||||
* 推荐商品
|
||||
*/
|
||||
class Goods extends Api
|
||||
{
|
||||
|
||||
protected $noNeedLogin = ['getRecommendGoods'];
|
||||
// 无需鉴权的接口,*表示全部
|
||||
protected $noNeedRight = ['*'];
|
||||
|
||||
protected $model;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
|
||||
\app\common\model\fill\Handle::check('app_config','recommend');
|
||||
|
||||
$this->model = new \app\api\model\app\recommend\Goods;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取推荐商品
|
||||
* @return void
|
||||
*/
|
||||
public function getRecommendGoods()
|
||||
{
|
||||
|
||||
$config = \app\common\model\app\Config::getConfig('recommend');
|
||||
|
||||
if($config['status'] != 1 && $config['show_count'] > 0){
|
||||
$this->success("暂未开启商品推荐");
|
||||
}
|
||||
|
||||
|
||||
$list = $this->model->getGoodsList($config['show_count']);
|
||||
|
||||
if(!$list){
|
||||
$this->success("暂未可推荐商品");
|
||||
}
|
||||
|
||||
$this->success("获取成功",$list);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user