161 lines
		
	
	
		
			5.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
		
		
			
		
	
	
			161 lines
		
	
	
		
			5.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| 
								 | 
							
								<?php
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								namespace app\api\controller\school;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								use app\common\model\school\classes\order\Order as OrderModel;
							 | 
						|||
| 
								 | 
							
								use app\common\model\school\classes\Teacher as Teachermodel;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								/**
							 | 
						|||
| 
								 | 
							
								 * 用户端:帮助接口
							 | 
						|||
| 
								 | 
							
								 */
							 | 
						|||
| 
								 | 
							
								class Help extends Base
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    protected $noNeedLogin = '*';
							 | 
						|||
| 
								 | 
							
								    protected $noNeedRight = '*';
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    protected $model = null;
							 | 
						|||
| 
								 | 
							
								    protected $catemodel = null;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    /**
							 | 
						|||
| 
								 | 
							
								     * 初始化操作
							 | 
						|||
| 
								 | 
							
								     * @access protected
							 | 
						|||
| 
								 | 
							
								     */
							 | 
						|||
| 
								 | 
							
								    protected function _initialize()
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        $this->model = new \app\common\model\school\help\Article;
							 | 
						|||
| 
								 | 
							
								        $this->catemodel = new \app\common\model\school\help\Cate;
							 | 
						|||
| 
								 | 
							
								        parent::_initialize();
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        //判断登录用户是否是员工
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    /**
							 | 
						|||
| 
								 | 
							
								     * @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 = "help_cate_ids", type = "string",required=false,description = "帮助分类id")
							 | 
						|||
| 
								 | 
							
								     * @ApiParams(name = "hot", type = "string",required=false,description = "平台热门:0=否,1=是")
							 | 
						|||
| 
								 | 
							
								     * @ApiParams(name = "time", type = "string",required=false,description = "复合时间查询:today今天,week本周,month本月,year本年,yesterday昨天,last year上一年,last week上周,last month上個月,lately7最近7天 , lately30最近30天,按开始时间区间查传值格式:Y/m/d H:M:S-Y/m/d H:M:S")
							 | 
						|||
| 
								 | 
							
								     *
							 | 
						|||
| 
								 | 
							
								     * @ApiReturn({
							 | 
						|||
| 
								 | 
							
								     *
							 | 
						|||
| 
								 | 
							
								     *})
							 | 
						|||
| 
								 | 
							
								     */
							 | 
						|||
| 
								 | 
							
								    public function article_list()
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        $user_id = 0;
							 | 
						|||
| 
								 | 
							
								        $user = $this->auth->getUser();//登录用户
							 | 
						|||
| 
								 | 
							
								        if($user)$user_id = $user['id'];
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        $params = [];
							 | 
						|||
| 
								 | 
							
								        $my  =  $this->request->get('my/d', 0); //我的评价
							 | 
						|||
| 
								 | 
							
								        if($my && $user_id){
							 | 
						|||
| 
								 | 
							
								            $params['user_id'] = $user_id;
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        $page  =  $this->request->get('page/d', 0); //页数
							 | 
						|||
| 
								 | 
							
								        $limit =  $this->request->get('limit/d', 0); //条数
							 | 
						|||
| 
								 | 
							
								        $params["keywords"] = $this->request->get('keywords/s', ''); //搜索关键字
							 | 
						|||
| 
								 | 
							
								        $params["help_cate_ids"] = $this->request->get('help_cate_ids/s', ''); //搜索关键字
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        $params["hot"] =  $this->request->get('hot/s', ''); //时间
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        $params["time"] =  $this->request->get('time/s', ''); //时间
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        try{
							 | 
						|||
| 
								 | 
							
								            //当前申请状态
							 | 
						|||
| 
								 | 
							
								            $res = $this->model::articleList($page, $limit,$params);
							 | 
						|||
| 
								 | 
							
								//            if($user_id =='670153'){
							 | 
						|||
| 
								 | 
							
								//               file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql());
							 | 
						|||
| 
								 | 
							
								//            }
							 | 
						|||
| 
								 | 
							
								        }catch (\Exception $e){
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            $this->error($e->getMessage());
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        $this->success('查询成功', $res);
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    /**
							 | 
						|||
| 
								 | 
							
								     * @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 = "pid", type = "string",required=true,description = "父级id")
							 | 
						|||
| 
								 | 
							
								     * @ApiReturn({
							 | 
						|||
| 
								 | 
							
								     *
							 | 
						|||
| 
								 | 
							
								     *})
							 | 
						|||
| 
								 | 
							
								     */
							 | 
						|||
| 
								 | 
							
								    public function cate_list()
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        $user_id = 0;
							 | 
						|||
| 
								 | 
							
								        $user = $this->auth->getUser();//登录用户
							 | 
						|||
| 
								 | 
							
								        if($user)$user_id = $user['id'];
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        $params = [];
							 | 
						|||
| 
								 | 
							
								        $my  =  $this->request->get('my/d', 0); //我的评价
							 | 
						|||
| 
								 | 
							
								        if($my && $user_id){
							 | 
						|||
| 
								 | 
							
								            $params['user_id'] = $user_id;
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        $page  =  $this->request->get('page/d', 0); //页数
							 | 
						|||
| 
								 | 
							
								        $limit =  $this->request->get('limit/d', 0); //条数
							 | 
						|||
| 
								 | 
							
								        $params["keywords"] = $this->request->get('keywords/s', ''); //搜索关键字
							 | 
						|||
| 
								 | 
							
								        $params["pid"] = $this->request->get('pid/s', ''); //搜索关键字
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        try{
							 | 
						|||
| 
								 | 
							
								            //当前申请状态
							 | 
						|||
| 
								 | 
							
								            $res = $this->catemodel::cateList($page, $limit,$params);
							 | 
						|||
| 
								 | 
							
								//            if($user_id =='670153'){
							 | 
						|||
| 
								 | 
							
								//               file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql());
							 | 
						|||
| 
								 | 
							
								//            }
							 | 
						|||
| 
								 | 
							
								        }catch (\Exception $e){
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            $this->error($e->getMessage());
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        $this->success('查询成功', $res);
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    /**
							 | 
						|||
| 
								 | 
							
								     * @ApiTitle( 文章详情)
							 | 
						|||
| 
								 | 
							
								     * @ApiSummary(文章详情)
							 | 
						|||
| 
								 | 
							
								     * @ApiMethod(GET)
							 | 
						|||
| 
								 | 
							
								     * @ApiParams(name = "id", type = "int",required=true,description = "文章id")
							 | 
						|||
| 
								 | 
							
								     * @ApiReturn({
							 | 
						|||
| 
								 | 
							
								     *
							 | 
						|||
| 
								 | 
							
								     *})
							 | 
						|||
| 
								 | 
							
								     */
							 | 
						|||
| 
								 | 
							
								    public function detail(){
							 | 
						|||
| 
								 | 
							
								        $id = $this->request->get('id/d','');
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        if(empty($id)){
							 | 
						|||
| 
								 | 
							
								            $this->error(__('缺少必要参数'));
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        try {
							 | 
						|||
| 
								 | 
							
								            $res =  $this->model->detail($id);
							 | 
						|||
| 
								 | 
							
								        } catch (\Exception $e){
							 | 
						|||
| 
								 | 
							
								//            Log::log($e->getMessage());
							 | 
						|||
| 
								 | 
							
								            $this->error($e->getMessage(),['errcode'=>$e->getCode()]);
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        $this->success('获取成功', ['detail' => $res]);
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								}
							 | 
						|||
| 
								 | 
							
								
							 |