You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.5 KiB
66 lines
1.5 KiB
<?php
|
|
|
|
namespace app\api\controller;
|
|
|
|
use app\common\controller\Api;
|
|
|
|
/**
|
|
* 首页接口
|
|
*/
|
|
class Portfolio extends Api
|
|
{
|
|
protected $noNeedLogin = ['*'];
|
|
protected $noNeedRight = ['*'];
|
|
protected $portfolio = null;
|
|
protected $indsutry = null;
|
|
|
|
public function _initialize()
|
|
{
|
|
parent::_initialize();
|
|
$this->portfolio = new \app\admin\model\portfolio\Index;
|
|
$this->indsutry = new \app\admin\model\portfolio\Indsutry;
|
|
}
|
|
|
|
|
|
/**
|
|
* get portfolio list
|
|
*
|
|
*/
|
|
public function getPortfolio()
|
|
{
|
|
$exp = new \think\db\Expression("sort!=0 desc,sort");
|
|
$indsutry = $this->indsutry->order($exp)->select();
|
|
|
|
foreach ($indsutry as $k=>$v){
|
|
$exp = new \think\db\Expression("sort!=0 desc,sort,createtime desc");
|
|
$children = $this->portfolio->where(['indsutry_id'=>$v['id']])->order($exp)->select();
|
|
$indsutry[$k]['children'] = $children;
|
|
}
|
|
|
|
$this->success('Request succeeded',$indsutry);
|
|
}
|
|
|
|
/**
|
|
* view research
|
|
*
|
|
*/
|
|
public function clickPortfolio()
|
|
{
|
|
$portfolio_id = (int)$this->request->request('portfolio_id',0);
|
|
if(!$portfolio_id){
|
|
$this->error('Parameter error');
|
|
}
|
|
|
|
$where = [];
|
|
$where['id'] = $portfolio_id;
|
|
$info = $this->portfolio->where($where)->find();
|
|
if(!$info){
|
|
$this->error('Media does not exist');
|
|
}
|
|
|
|
$this->portfolio->where($where)->setInc('clicks',1);
|
|
|
|
$this->success('Request succeeded');
|
|
}
|
|
}
|