100 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			100 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace app\api\controller\home;
 | 
						|
 | 
						|
 | 
						|
use app\common\model\home\Information as InformationModel;
 | 
						|
use app\common\model\home\NewsCate;
 | 
						|
 | 
						|
/**
 | 
						|
 * 信息公开接口
 | 
						|
 */
 | 
						|
class Information extends Base
 | 
						|
{
 | 
						|
    protected $noNeedLogin = ['*'];
 | 
						|
    protected $noNeedRight = ['*'];
 | 
						|
 | 
						|
    /**
 | 
						|
     * @var \app\common\model\home\Information
 | 
						|
     */
 | 
						|
    protected $model = null;
 | 
						|
 | 
						|
    public function _initialize()
 | 
						|
    {
 | 
						|
        parent::_initialize();
 | 
						|
        $this->model = new InformationModel;
 | 
						|
 | 
						|
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    /**
 | 
						|
     * @ApiTitle( 信息公开文章列表)
 | 
						|
     * @ApiSummary(信息公开文章列表)
 | 
						|
     * @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->param('page/d', 0); //页数
 | 
						|
        $limit =  $this->request->param('limit/d', 0); //条数
 | 
						|
        $keywords =  $this->request->param('keywords/s', ''); //搜索关键字
 | 
						|
        $recommend =  $this->request->param('recommend/s', ''); //搜索关键字
 | 
						|
        $params =[];
 | 
						|
        $cate_id =  $this->request->param('cate_id/s', ''); //搜索关键字
 | 
						|
//        $params["flag"]  =  $this->request->get('flag/s', ''); //搜索关键字
 | 
						|
//        $params["hot"]  =  $this->request->get('hot/s', ''); //搜索关键字
 | 
						|
//        $params["fine"]  =  $this->request->get('fine/s', ''); //搜索关键字
 | 
						|
 | 
						|
 | 
						|
//        $type =  $this->request->get('type/s', ''); //筛选学员和教练单
 | 
						|
 | 
						|
 | 
						|
        try{
 | 
						|
            //当前申请状态
 | 
						|
            $res = $this->model::allList($page, $limit,$keywords,$recommend,$cate_id,$params);
 | 
						|
//             var_dump($this->model->getLastSql());
 | 
						|
        }catch (\Exception $e){
 | 
						|
 | 
						|
            $this->error($e->getMessage());
 | 
						|
        }
 | 
						|
        $this->success('查询成功', $res);
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    /**
 | 
						|
     * 查看信息公开文章详情
 | 
						|
     *
 | 
						|
     * @ApiMethod (GET)
 | 
						|
     * @ApiParams (name="id", type="string", required=true, description="ID")
 | 
						|
     */
 | 
						|
    public function detail()
 | 
						|
    {
 | 
						|
        $user_id = 0;
 | 
						|
        $user = $this->auth->getUser();//登录用户
 | 
						|
        if($user)$user_id = $user['id'];
 | 
						|
        $id = $this->request->param('id/d');
 | 
						|
 | 
						|
        try{
 | 
						|
            $menulist = $this->model->detail($id,$show_field=[],$except_field=[],$user_id);
 | 
						|
        } catch (\Exception $e) {
 | 
						|
            $this->error($e->getMessage());
 | 
						|
        }
 | 
						|
 | 
						|
        $this->success('查询成功', $menulist);
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
} |