52 lines
1.2 KiB
PHP
52 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace app\api\controller;
|
|
|
|
use app\api\BaseController;
|
|
use app\api\middleware\Auth;
|
|
use think\facade\Db;
|
|
|
|
|
|
/**
|
|
* 教育培训
|
|
*/
|
|
class PublicBenefit extends BaseController
|
|
{
|
|
const ARTICLE_PUBLIC_BENEFIT = 'fa_article_public_benefit';
|
|
|
|
/**
|
|
* 控制器中间件 [不需要鉴权]
|
|
* @var array
|
|
*/
|
|
protected $middleware = [
|
|
Auth::class => ['except' => ['Enroll','Activites'] ]
|
|
];
|
|
|
|
protected function getData($cid){
|
|
$where = ['category_id'=>$cid];
|
|
$list = Db::table('fa_article')->withAttr('enroll',
|
|
function($value, $data){
|
|
return Db::table(self::ARTICLE_PUBLIC_BENEFIT)->field('promoter,enrolled_num')->where('article_id', $data['id'])->find();
|
|
}
|
|
)
|
|
->where($where)
|
|
->page(1)
|
|
->limit(10)
|
|
->order('id desc')
|
|
->select();
|
|
|
|
return $list;
|
|
}
|
|
|
|
public function Enroll(){
|
|
$data = $this->getData(368);
|
|
$this->apiSuccess('ok', ['list' => $data]);
|
|
}
|
|
|
|
public function Activites(){
|
|
$data = $this->getData(369);
|
|
$this->apiSuccess('ok', ['list' => $data]);
|
|
}
|
|
|
|
}
|