Index.php 26.2 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763
<?php

namespace app\api\controller;

use app\common\controller\Api;
use think\Db;

/**
 * 首页接口
 */
class Index extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * @ApiTitle    (首页轮播图列表)
     * @ApiSummary  (首页轮播图列表)
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/index/pic)
     *
     * @ApiReturn({
        "code": 1,
        "msg": "成功",
        "time": "1571492001",
        "data": {
            "id": //图片id,
            "thumbnail": //图片,
            "createtime" ://创建时间
        }
        })
     */
    public function pic()
    {
        $host = get_addon_config('qiniu')['cdnurl'];//域名
        $data = Db::name('pic')
            ->field('id,thumbnail,createtime')
            ->order('id desc')
            ->limit(5)
            ->select();
        foreach ($data as &$v){
            $v['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
            $v['thumbnail'] = $host.$v['thumbnail'];
        }
        $this->success('请求成功',$data);
    }

    /**
     * @ApiTitle    (轮播图详情)
     * @ApiSummary  (轮播图详情)
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/index/picdetail)
     *
     * @ApiParams   (name="id", type="int", required=false, description="图片id")
     *
     * @ApiReturn({
        "code": 1,
        "msg": "成功",
        "time": "1571492001",
        "data": {
        "content"://内容
    }
    })
     */
    public function picdetail()
    {
        $id = $this->request->param('id');
        if(empty($id)){
            $this->error('缺少必要参数');
        }
        $data = Db::name('pic')
            ->where('id',$id)
            ->find();
        $this->success('success',$data);
    }

    /**
     * @ApiTitle    (首页咨询分类列表)
     * @ApiSummary  (首页咨询分类列表)
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/index/typeList)
     *
     * @ApiParams   (name="type", type="int", required=false, description="类型(如果为空或者为1是经营管理 2是职业发展)")
     *
     * @ApiReturn({
        "code": 1,
        "msg": "成功",
        "time": "1571492001",
        "data": {
            "id": //id,
            "title"://标题,
        }
        })
     */
    public function typeList(){
        $type = $this->request->param('type');
        if(empty($type) || $type == 1){
            $data = Db::name('contype')
                ->field('updatetime,createtime,type',true)
                ->where('type',1)
                ->order('id desc')
                ->limit(8)
                ->select();
            $this->success('success',$data);
        }elseif($type == 2){
            $data = Db::name('contype')
                ->field('updatetime,createtime,type',true)
                ->where('type',2)
                ->order('id desc')
                ->limit(8)
                ->select();
            $this->success('success',$data);
        }else{
            $this->error('类型错误');
        }
    }

    /**
     * @ApiTitle    (咨询分类更多列表)
     * @ApiSummary  (咨询分类更多列表)
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/index/moreList)
     *
     * @ApiReturn({
    "code": 1,
    "msg": "成功",
    "time": "1571492001",
    "data": {
    "id": //id,
    "title"://标题,
    "type"://1经营管理2职业发展
    }
    })
     */
    public function moreList(){
        $data = Db::name('contype')
            ->field('updatetime,createtime',true)
            ->order('id desc')
            ->select();
        $this->success('success',$data);
    }

    /**
     * @ApiTitle    (首页今日推荐/更多老师列表(带搜索))
     * @ApiSummary  (首页今日推荐/更多老师列表(带搜索))
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/index/today)
     *
     * @ApiHeaders  (name=token, type=string, required=true, description="请求的Token")
     *
     * @ApiParams   (name="type", type="int", required=false, description="类型(如果为空或者为1是今日推荐列表 2是更多老师列表)")
     * @ApiParams   (name="keyword", type="string", required=false, description="关键字")
     * @ApiParams   (name="page", type="inter", required=false, description="当前页(默认1)")
     * @ApiParams   (name="pageNum", type="inter", required=false, description="每页显示数据个数(默认10)")
     *
     *
     * @ApiReturn({
        "code": 1,
        "msg": "成功",
        "time": "1571492001",
        "data": {
              "id": //老师id,
              "user_id"://用户ID
              "name"://老师名字
              "sex"://性别
              "birth"://出生日期
              "idcard"://身份证号
              "before"://身份证正面照
              "behind"://身份证反面照
              "phone"://手机号
              "thumbnail"://头像
              "address"://常住地
              "honor"://头衔
              "content"://个人履历
              "show"://展示在最前
              "desc"://个人简历
              "online"://在线时段
              "territory_id"://擅长领域ID
              "help_num"://帮助人数
              "level"://星级
              "createtime"://创建时间
        }
        })
     */
    public function today()
    {
        $token = $this->request->header('token');
        $page = $this->request->param('page', 1, 'intval');
        $pageNum = $this->request->param('pageNum', 10, 'intval');
        //接收类型值
        $type = $this->request->param('type');
        //未登录的状态下
        if(empty($token)){
            $keyword = $this->request->param('keyword');
            if($type == '' || $type == 1){
                $data = Db::name('teacher')
                    ->where('status',1)
                    ->where('is_recommend',1)
                    ->where('is_forbid',0)
                    ->field('status,updatetime',true)
                    ->order('is_stick desc')
                    ->page($page,$pageNum)
                    ->select();
            }else{
                if(!empty($keyword)){

                    $contype = Db::name('contype')
                        ->where('title',$keyword)
                        ->field('id,title')
                        ->find();
                    $territory = Db::name('territory')
                        ->where('contype_id',$contype['id'])
                        ->column('user_id');

                    $data = Db::name('teacher')
                        ->where('status',1)
                        ->where('is_forbid',0)
                        ->where('name','Like',"%$keyword%")
                        ->whereOr('honor','Like',"%$keyword%")
                        ->whereOr('user_id','In',$territory)
                        ->field('status,updatetime',true)
                        ->order('is_stick desc')
                        ->page($page,$pageNum)
                        ->select();
                }else{
                    $data = Db::name('teacher')
                        ->where('status',1)
                        ->where('is_forbid',0)
                        ->field('status,updatetime',true)
                        ->page($page,$pageNum)
                        ->order('is_stick desc')
                        ->select();
                }
            }
            $qiniu = get_addon_config('qiniu');
            $http = $qiniu['cdnurl'];
            foreach ($data as &$v){
                //查看老师的已帮助人数以及评分星级
                $comment = Db::name('comment')->where('teacher_id',$v['id'])->select();
                //评价为五星的人数
                $five =  Db::name('comment')->where('teacher_id',$v['id'])->where('level',5)->count();
                //评价为四星的人数
                $four =  Db::name('comment')->where('teacher_id',$v['id'])->where('level',4)->count();
                //评价为三星的人数
                $three =  Db::name('comment')->where('teacher_id',$v['id'])->where('level',3)->count();
                //评价为二星的人数
                $two =  Db::name('comment')->where('teacher_id',$v['id'])->where('level',2)->count();
                //评价为一星的人数
                $one =  Db::name('comment')->where('teacher_id',$v['id'])->where('level',1)->count();
                if(!empty($comment)){
                    $v['help_num'] = $five + $four + $three + $two + $one + $v['help_num'];
                    $v['level'] = ceil(($v['help_num'] * 5 + $four * 4 + $three * 3 + $two * 2 + $one)/$v['help_num']);
                }
                if($v['sex'] == 1){
                    $v['sex'] = '男';
                }else{
                    $v['sex'] = '女';
                }
                $v['before'] = $http.$v['before'];
                $v['behind'] = $http.$v['behind'];
                $v['thumbnail'] = $http.$v['thumbnail'];
                if(!empty($v['territory_id'])){
                    $v['territory_id'] = explode(',',$v['territory_id']);
                    foreach ($v['territory_id'] as &$val){
                        $val = Db::name('territory')
                            ->alias('a')
                            ->join('contype b','a.contype_id = b.id')
                            ->where('a.id',$val)
                            ->column('b.title');
                    }
                }else{
                    $v['territory_id'] = '';
                }
            }
            $this->success('success',$data);
        }
        //登录的状态下
        $user_id = $this->getUserId();
        $type = $this->request->param('type');
        $keyword = $this->request->param('keyword');
        if($type == '' || $type == 1){
            $data = Db::name('teacher')
                ->where('status',1)
                ->where('is_recommend',1)
                ->where('is_forbid',0)
                ->field('status,updatetime',true)
                ->order('is_stick desc')
                ->page($page,$pageNum)
                ->select();
        }else{
            if(!empty($keyword)){
                $history['user_id'] = $user_id;
                $history['keyword'] = $keyword;
                $history['createtime'] = time();
                //查询关键字是否已经存在
                $sel = Db::name('keyword')
                    ->where('user_id',$history['user_id'])
                    ->where('keyword',$history['keyword'])
                    ->find();
                if(empty($sel)){
                    Db::name('keyword')->insertGetId($history);
                }

                //将内容添加进热门搜索表去判断
                $hotword['keyword'] = $keyword;
                $hotword['createtime'] = time();
                $hot = Db::name('hotword')
                    ->where('keyword',$keyword)
                    ->find();
                if(!empty($hot)){
                    Db::name('hotword')->where('id',$hot['id'])->setInc('num');
                }else{
                    Db::name('hotword')->insertGetId($hotword);
                }
                $contype = Db::name('contype')
                    ->where('title',$keyword)
                    ->field('id,title')
                    ->find();
                $territory = Db::name('territory')
                    ->where('contype_id',$contype['id'])
                    ->column('user_id');

                $data = Db::name('teacher')
                    ->where('status',1)
                    ->where('is_forbid',0)
                    ->where('name','Like',"%$keyword%")
                    ->whereOr('honor','Like',"%$keyword%")
                    ->whereOr('user_id','In',$territory)
                    ->field('status,updatetime',true)
                    ->order('is_stick desc')
                    ->page($page,$pageNum)
                    ->select();
            }else{
                $data = Db::name('teacher')
                    ->where('status',1)
                    ->where('is_forbid',0)
                    ->field('status,updatetime',true)
                    ->order('is_stick desc')
                    ->page($page,$pageNum)
                    ->select();
            }
        }
        $qiniu = get_addon_config('qiniu');
        $http = $qiniu['cdnurl'];
        foreach ($data as &$v){
            //查看老师的已帮助人数以及评分星级
            $comment = Db::name('comment')->where('teacher_id',$v['id'])->select();
            //评价为五星的人数
            $five =  Db::name('comment')->where('teacher_id',$v['id'])->where('level',5)->count();
            //评价为四星的人数
            $four =  Db::name('comment')->where('teacher_id',$v['id'])->where('level',4)->count();
            //评价为三星的人数
            $three =  Db::name('comment')->where('teacher_id',$v['id'])->where('level',3)->count();
            //评价为二星的人数
            $two =  Db::name('comment')->where('teacher_id',$v['id'])->where('level',2)->count();
            //评价为一星的人数
            $one =  Db::name('comment')->where('teacher_id',$v['id'])->where('level',1)->count();
            if(!empty($comment)){
                $v['help_num'] = $five + $four + $three + $two + $one + $v['help_num'];
                $v['level'] = ceil(($v['help_num'] * 5 + $four * 4 + $three * 3 + $two * 2 + $one)/$v['help_num']);
            }
            if($v['sex'] == 1){
                $v['sex'] = '男';
            }else{
                $v['sex'] = '女';
            }
            $v['before'] = $http.$v['before'];
            $v['behind'] = $http.$v['behind'];
            $v['thumbnail'] = $http.$v['thumbnail'];
            if(!empty($v['territory_id'])){
                $v['territory_id'] = explode(',',$v['territory_id']);
                foreach ($v['territory_id'] as &$val){
                    $a = Db::name('territory')
                        ->alias('a')
                        ->join('contype b','a.contype_id = b.id')
                        ->where('a.id',$val)
                        ->field('b.title')
                        ->find();
                    $val = $a['title'];
                }
            }else{
                $v['territory_id'] = '';
            }
        }
        $this->success('success',$data);
    }

    /**
     * @ApiTitle    (历史记录)
     * @ApiSummary  (历史记录)
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/index/history)
     * @ApiHeaders  (name=token, type=string, required=true, description="请求的Token")
     *
     * @ApiReturn({
        "code": 1,
        "msg": "成功",
        "time": "1571492001",
        "data": {
        "list":[
                "id"://记录id,
                "keyword"://搜索的内容
         ],
          "hotlist":[
              "id"://记录id,
               "keyword"://搜索的内容
          ],

        }
        })
     */
    public function history()
    {
        $token = $this->request->header('token');
        if(empty($token)){
            $data['hotlist'] = Db::name('hotword')
                ->field('num,createtime',true)
                ->order('num desc')
                ->limit(10)
                ->select();
        }else{
            $user_id = $this->getUserId();
            $data['list'] = Db::name('keyword')
                ->where('user_id',$user_id)
                ->field('id,keyword')
                ->limit(4)
                ->order('id desc')
                ->select();
            $data['hotlist'] = Db::name('hotword')
                ->field('num,createtime',true)
                ->order('num desc')
                ->limit(10)
                ->select();
        }
        $this->success('SUCCESS',$data);
    }

    /**
     * @ApiTitle    (老师详情)
     * @ApiSummary  (老师详情)
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/index/detail)
     *
     * @ApiHeaders  (name=token, type=string, required=true, description="请求的Token")
     *
     * @ApiParams   (name="id", type="string", required=true, description="老师ID")
     *
     * @ApiReturn({
        "code": 1,
        "msg": "成功",
        "time": "1571492001",
        "data": {
        "id": //老师id,
        "user_id"://用户ID
        "name"://老师名字
        "sex"://性别
        "birth"://出生日期
        "idcard"://身份证号
        "before"://身份证正面照
        "behind"://身份证反面照
        "phone"://手机号
        "thumbnail"://头像
        "address"://常住地
        "honor"://头衔
        "content"://个人履历
        "show"://展示在最前
        "desc"://个人简历
        "online"://在线时段
        "territory_id"://擅长领域ID
        "help_num"://帮助人数
        "level"://星级
        "createtime"://创建时间
        "is_guan"://是否关注(1已关注2还未关注)
        "you_num"://优惠劵个数
        }
        })
     */
    public function detail()
    {
        $token = $this->request->header('token');
        if(empty($token)){
            $id = $this->request->param('id');
            if(empty($id)){
                $this->error('缺少必要参数');
            }
            $data = Db::name('teacher')
                ->where('id',$id)
                ->find();
            $qiniu = get_addon_config('qiniu');
            $http = $qiniu['cdnurl'];
            if($data['sex'] == 1){
                $data['sex'] = '男';
            }else{
                $data['sex'] = '女';
            }
            //查看用户是否已经关注该老师

            $data['is_guan'] = 2;

            //查看老师的已帮助人数以及评分星级
            $comment = Db::name('comment')->where('teacher_id',$id)->select();
            //评价为五星的人数
            $five =  Db::name('comment')->where('teacher_id',$id)->where('level',5)->count();
            //评价为四星的人数
            $four =  Db::name('comment')->where('teacher_id',$id)->where('level',4)->count();
            //评价为三星的人数
            $three =  Db::name('comment')->where('teacher_id',$id)->where('level',3)->count();
            //评价为二星的人数
            $two =  Db::name('comment')->where('teacher_id',$id)->where('level',2)->count();
            //评价为一星的人数
            $one =  Db::name('comment')->where('teacher_id',$id)->where('level',1)->count();
            if(!empty($comment)){
                $data['help_num'] = $five + $four + $three + $two + $one + $data['help_num'];
                $data['level'] = ceil(($data['help_num'] * 5 + $four * 4 + $three * 3 + $two * 2 + $one)/$data['help_num']);
            }
            $data['before'] = $http.$data['before'];
            $data['behind'] = $http.$data['behind'];
            $data['thumbnail'] = $http.$data['thumbnail'];
            $territory_id = explode(',',$data['territory_id']);
            $data['territory_id'] = Db::name('territory')
                ->alias('a')
                ->join('contype b','a.contype_id = b.id')
                ->field('a.id,a.money,a.content,b.title,b.type')
                ->whereIn('a.id',$territory_id)
                ->select();

            $this->success('success',$data);
        }else{
            $user_id = $this->getUserId();
            $id = $this->request->param('id');
            if(empty($id)){
                $this->error('缺少必要参数');
            }
            $data = Db::name('teacher')
                ->where('id',$id)
                ->find();
            $qiniu = get_addon_config('qiniu');
            $http = $qiniu['cdnurl'];
            if($data['sex'] == 1){
                $data['sex'] = '男';
            }else{
                $data['sex'] = '女';
            }
            //查看用户是否已经关注该老师
            $good = Db::name('good')
                ->where('user_id',$user_id)
                ->where('teacher_id',$id)
                ->find();
            if(empty($good)){
                $data['is_guan'] = 2;
            }else{
                $data['is_guan'] = 1;
            }
            //查看用户是否有优惠劵
            $data['you_num'] = Db::name('coupon')
                ->where('user_id',$user_id)
                ->where('is_use',0)
                ->whereTime('expirationtime','>',time())
                ->count();

            //查看老师的已帮助人数以及评分星级
            $comment = Db::name('comment')->where('teacher_id',$id)->select();
            //评价为五星的人数
            $five =  Db::name('comment')->where('teacher_id',$id)->where('level',5)->count();
            //评价为四星的人数
            $four =  Db::name('comment')->where('teacher_id',$id)->where('level',4)->count();
            //评价为三星的人数
            $three =  Db::name('comment')->where('teacher_id',$id)->where('level',3)->count();
            //评价为二星的人数
            $two =  Db::name('comment')->where('teacher_id',$id)->where('level',2)->count();
            //评价为一星的人数
            $one =  Db::name('comment')->where('teacher_id',$id)->where('level',1)->count();
            if(!empty($comment)){
                $data['help_num'] = $five + $four + $three + $two + $one + $data['help_num'];
                $data['level'] = ceil(($data['help_num'] * 5 + $four * 4 + $three * 3 + $two * 2 + $one)/$data['help_num']);
            }
            $data['before'] = $http.$data['before'];
            $data['behind'] = $http.$data['behind'];
            $data['thumbnail'] = $http.$data['thumbnail'];
            $territory_id = explode(',',$data['territory_id']);
            $data['territory_id'] = Db::name('territory')
                ->alias('a')
                ->join('contype b','a.contype_id = b.id')
                ->field('a.id,a.money,a.content,b.title,b.type')
                ->whereIn('a.id',$territory_id)
                ->select();

            $this->success('success',$data);
        }

    }

    /**
     * @ApiTitle    (学员评价列表)
     * @ApiSummary  (学员评价列表)
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/index/commentlist)
     *
     * @ApiParams   (name="id", type="string", required=true, description="老师ID")
     * @ApiParams   (name="page", type="inter", required=false, description="当前页(默认1)")
     * @ApiParams   (name="pageNum", type="inter", required=false, description="每页显示数据个数(默认10)")
     *
     * @ApiReturn({
        "code": 1,
        "msg": "成功",
        "time": "1571492001",
        "data": {
        'id'://评价ID
        'content'://评价内容
        'nickname'://昵称
        'avatar'://头像
        'createtime':创建时间
        }
        })
     */
    public function commentlist()
    {
        $id = $this->request->param('id');
        $page = $this->request->param('page', 1, 'intval');
        $pageNum = $this->request->param('pageNum', 10, 'intval');
        if(empty($id)){
            $this->error('缺少必要参数');
        }
        $data = Db::name('comment')
            ->alias('a')
            ->join('user b','a.user_id = b.id')
            ->field('a.id,a.content,a.createtime,b.nickname,b.avatar')
            ->where('a.teacher_id',$id)
            ->order('a.createtime desc')
            ->page($page,$pageNum)
            ->select();
        foreach ($data as &$v){
            $v['createtime'] = date('Y-m-d',$v['createtime']);
        }
        $this->success('success',$data);
    }

    /**
     * @ApiTitle    (老师关注/取消关注接口)
     * @ApiSummary  (老师关注/取消关注接口)
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/index/good)
     * @ApiHeaders  (name=token, type=string, required=true, description="请求的Token")
     *
     * @ApiParams   (name="id", type="int", required=false, description="老师ID")
     *
     * @ApiReturn({
        "code": 1,
        "msg": "SUCCESS",
        "time": "1553839125",
        "data": {
        }
        })
     */
    public function good()
    {
        $user_id = $this->getUserId();
        $param['teacher_id'] = $this->request->param('id');
        if(empty($param['teacher_id'])){
            $this->error('缺少必要参数');
        }
        $param['user_id'] = $user_id;
        $info = Db::name('good')
            ->where('user_id',$param['user_id'])
            ->where('teacher_id',$param['teacher_id'])
            ->find();
        if(empty($info)){
            $param['createtime'] = time();
            $data = Db::name('good')
                ->insertGetId($param);
            if(!empty($data)){
                $this->success('关注成功');
            }else{
                $this->error('关注失败');
            }
        }else{
            $data = Db::name('good')->where('teacher_id',$param['teacher_id'])->where('user_id',$param['user_id'])->delete();
            if(!empty($data)){
                $this->success('取消关注成功');
            }else{
                $this->error('关注失败');
            }

        }
    }

    /**
     * @ApiTitle    (提现内容)
     * @ApiSummary  (体现内容)
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/index/with)
     *
     * @ApiReturn({
    "code": 1,
    "msg": "成功",
    "time": "1571492001",
    "data": {
    "id": //id,
    "content": //内容,
    "createtime" ://创建时间
    }
    })
     */
    public function with()
    {
        $data = Db::name('with')
            ->where('id',1)
            ->find();
        $this->success('success',$data);
    }

    /**
     * @ApiTitle    (常见问题内容)
     * @ApiSummary  (常见问题内容)
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/index/question)
     *
     * @ApiReturn({
    "code": 1,
    "msg": "成功",
    "time": "1571492001",
    "data": {
    "id": //id,
    "content": //内容,
    "createtime" ://创建时间
    }
    })
     */
    public function question()
    {
        $data = Db::name('questions')
            ->where('id',1)
            ->find();
        $this->success('success',$data);
    }

    /**
     * @ApiTitle    (购买提醒内容)
     * @ApiSummary  (购买提醒内容)
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/index/hint)
     *
     * @ApiReturn({
    "code": 1,
    "msg": "成功",
    "time": "1571492001",
    "data": {
    "id": //id,
    "content": //内容,
    "createtime" ://创建时间
    }
    })
     */
    public function hint()
    {
        $data = Db::name('hint')
            ->where('id',1)
            ->find();
        $this->success('success',$data);
    }


}