2025-05-20 16:33:23 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace app\api\controller\home;
|
|
|
|
|
|
|
|
|
2025-05-21 18:06:43 +08:00
|
|
|
use app\common\model\home\Encyclopedia as EncyclopediaModel;
|
|
|
|
use app\common\model\home\News as NewsModel;
|
|
|
|
use app\common\model\home\NewsCate;
|
2025-05-20 16:33:23 +08:00
|
|
|
|
|
|
|
/**
|
2025-05-21 18:06:43 +08:00
|
|
|
* 团务百科接口
|
2025-05-20 16:33:23 +08:00
|
|
|
*/
|
2025-05-21 18:06:43 +08:00
|
|
|
class Encyclopedia extends Base
|
2025-05-20 16:33:23 +08:00
|
|
|
{
|
|
|
|
protected $noNeedLogin = ['*'];
|
|
|
|
protected $noNeedRight = ['*'];
|
|
|
|
|
|
|
|
/**
|
2025-05-21 18:06:43 +08:00
|
|
|
* @var \app\common\model\home\Encyclopedia
|
2025-05-20 16:33:23 +08:00
|
|
|
*/
|
|
|
|
protected $model = null;
|
|
|
|
|
|
|
|
public function _initialize()
|
|
|
|
{
|
|
|
|
parent::_initialize();
|
2025-05-21 18:06:43 +08:00
|
|
|
$this->model = new EncyclopediaModel;
|
2025-05-20 16:33:23 +08:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-05-21 18:06:43 +08:00
|
|
|
* @ApiTitle( 团务百科文章列表)
|
|
|
|
* @ApiSummary(团务百科文章列表)
|
2025-05-20 16:33:23 +08:00
|
|
|
* @ApiMethod(GET)
|
|
|
|
* @ApiParams(name = "keywords", type = "string",required=false,description = "搜索关键字")
|
|
|
|
* @ApiParams(name = "page", type = "string",required=true,description = "页数")
|
|
|
|
* @ApiParams(name = "limit", type = "string",required=true,description = "条数")
|
|
|
|
* @ApiParams(name = "recommend", type = "string",required=false,description = "置顶:0=否,1=是")
|
|
|
|
* @ApiReturn({
|
|
|
|
*
|
|
|
|
*})
|
|
|
|
*/
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
$user_id = 0;
|
|
|
|
$user = $this->auth->getUser();//登录用户
|
|
|
|
if($user)$user_id = $user['id'];
|
|
|
|
$page = $this->request->get('page/d', 0); //页数
|
|
|
|
$limit = $this->request->get('limit/d', 0); //条数
|
|
|
|
$keywords = $this->request->get('keywords/s', ''); //搜索关键字
|
|
|
|
$recommend = $this->request->get('recommend/s', ''); //搜索关键字
|
2025-05-21 18:06:43 +08:00
|
|
|
$params =[];
|
2025-05-20 16:33:23 +08:00
|
|
|
$cate_id = $this->request->get('cate_id/s', ''); //搜索关键字
|
2025-05-21 18:06:43 +08:00
|
|
|
// $params["flag"] = $this->request->get('flag/s', ''); //搜索关键字
|
|
|
|
// $params["hot"] = $this->request->get('hot/s', ''); //搜索关键字
|
|
|
|
// $params["fine"] = $this->request->get('fine/s', ''); //搜索关键字
|
2025-05-20 16:33:23 +08:00
|
|
|
|
|
|
|
|
|
|
|
// $type = $this->request->get('type/s', ''); //筛选学员和教练单
|
|
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
//当前申请状态
|
2025-05-21 18:06:43 +08:00
|
|
|
$res = $this->model::allList($page, $limit,$keywords,$recommend,$cate_id,$params);
|
2025-05-20 16:33:23 +08:00
|
|
|
// var_dump($this->model->getLastSql());
|
|
|
|
}catch (\Exception $e){
|
|
|
|
|
|
|
|
$this->error($e->getMessage());
|
|
|
|
}
|
|
|
|
$this->success('查询成功', $res);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-05-21 18:06:43 +08:00
|
|
|
* 查看团务百科文章详情
|
2025-05-20 16:33:23 +08:00
|
|
|
*
|
2025-05-21 18:06:43 +08:00
|
|
|
* @ApiMethod (GET)
|
|
|
|
* @ApiParams (name="id", type="string", required=true, description="ID")
|
2025-05-20 16:33:23 +08:00
|
|
|
*/
|
2025-05-21 18:06:43 +08:00
|
|
|
public function detail()
|
2025-05-20 16:33:23 +08:00
|
|
|
{
|
|
|
|
$user_id = 0;
|
|
|
|
$user = $this->auth->getUser();//登录用户
|
|
|
|
if($user)$user_id = $user['id'];
|
2025-05-21 18:06:43 +08:00
|
|
|
$id = $this->request->get('id/d');
|
2025-05-20 16:33:23 +08:00
|
|
|
|
|
|
|
try{
|
2025-05-21 18:06:43 +08:00
|
|
|
$menulist = $this->model->detail($id,$show_field=[],$except_field=[],$user_id);
|
|
|
|
} catch (\Exception $e) {
|
2025-05-20 16:33:23 +08:00
|
|
|
$this->error($e->getMessage());
|
|
|
|
}
|
2025-05-21 18:06:43 +08:00
|
|
|
|
|
|
|
$this->success('查询成功', $menulist);
|
2025-05-20 16:33:23 +08:00
|
|
|
}
|
2025-05-21 18:06:43 +08:00
|
|
|
|
|
|
|
|
2025-05-20 16:33:23 +08:00
|
|
|
}
|