114 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
		
		
			
		
	
	
			114 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| 
								 | 
							
								<?php
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								namespace app\api\controller\home;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								use app\common\model\home\LeaveWord as LeaveWordModel;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * 网站留言
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								class LeaveWord extends Base
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    protected $noNeedLogin = ['*'];
							 | 
						||
| 
								 | 
							
								    protected $noNeedRight = ['*'];
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    /**
							 | 
						||
| 
								 | 
							
								     * @var \app\common\model\home\LeaveWord
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    protected $model = null;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    public function _initialize()
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        parent::_initialize();
							 | 
						||
| 
								 | 
							
								        $this->model = new LeaveWordModel;
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    /**
							 | 
						||
| 
								 | 
							
								     * @ApiTitle( 发网站留言)
							 | 
						||
| 
								 | 
							
								     * @ApiSummary(发网站留言)
							 | 
						||
| 
								 | 
							
								     * @ApiMethod(POST)
							 | 
						||
| 
								 | 
							
								     * @ApiParams(name = "name", type = "string",required=true,description = "提交者姓名")
							 | 
						||
| 
								 | 
							
								     * @ApiParams(name = "mobile", type = "string",required=true,description = "联系电话")
							 | 
						||
| 
								 | 
							
								     * @ApiParams(name = "emil", type = "string",required=false,description = "邮箱地址")
							 | 
						||
| 
								 | 
							
								     * @ApiParams(name = "question", type = "string",required=true,description = "问题")
							 | 
						||
| 
								 | 
							
								     * @ApiParams(name = "message", type = "string",required=true,description = "描述")
							 | 
						||
| 
								 | 
							
								     * @ApiReturn({
							 | 
						||
| 
								 | 
							
								     *
							 | 
						||
| 
								 | 
							
								     *})
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    public function add()
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        $user_id = 0;
							 | 
						||
| 
								 | 
							
								        $user = $this->auth->getUser();//登录用户
							 | 
						||
| 
								 | 
							
								        if($user)$user_id = $user['id'];
							 | 
						||
| 
								 | 
							
								        $params=[];
							 | 
						||
| 
								 | 
							
								        $params["name"] =  $this->request->post('name/s', ''); //页数
							 | 
						||
| 
								 | 
							
								        $params["mobile"] =  $this->request->post('mobile/s', ''); //条数
							 | 
						||
| 
								 | 
							
								        $params["emil"] =  $this->request->post('emil/s', ''); //搜索关键字
							 | 
						||
| 
								 | 
							
								        $params["question"] =  $this->request->post('question/s', ''); //搜索关键字
							 | 
						||
| 
								 | 
							
								        $params["message"] =  $this->request->post('message/s', ''); //搜索关键字
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        try{
							 | 
						||
| 
								 | 
							
								            //当前申请状态
							 | 
						||
| 
								 | 
							
								            $res = $this->model->add($params,true);
							 | 
						||
| 
								 | 
							
								//             var_dump($this->model->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 = "status", type = "string",required=false,description = "状态:1=未处理,2=已处理")
							 | 
						||
| 
								 | 
							
								     * @ApiParams(name = "show", 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', ''); //搜索关键字
							 | 
						||
| 
								 | 
							
								        $status =  $this->request->get('status/s', ''); //搜索关键字
							 | 
						||
| 
								 | 
							
								        $params =[];
							 | 
						||
| 
								 | 
							
								        $show =  $this->request->get('show/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,$status,$show,$params);
							 | 
						||
| 
								 | 
							
								//             var_dump($this->model->getLastSql());
							 | 
						||
| 
								 | 
							
								        }catch (\Exception $e){
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								            $this->error($e->getMessage());
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								        $this->success('查询成功', $res);
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								}
							 |