<?php namespace app\api\controller; use app\api\BaseController; use app\api\middleware\Auth; use think\facade\Db; use app\common\model\SlideInfo; use think\facade\Env; /** * 首页接口. */ class Slide extends BaseController { /** * 控制器中间件 [不需要鉴权] * @var array */ protected $middleware = [ Auth::class => ['except' => ['get_slide','get_slide_two'] ] ]; /** * 获取轮播 * * //php think crud -t slide_info -c work/slideinfo * php think menu -c work/slideinfo */ public function get_slide() { $township = get_params('township'); // 乡镇 if($township){ $where['township'] = $township; }else{ $where['township'] = 0; } $slide_id = get_params('slide_id'); // 位置 if($slide_id == 'index'){ $where['slide_id'] = 3; }else{ $where['slide_id'] = 2; } $where['status'] = 1; $list = Db::table('fa_slide_info')->where($where) ->order('sort desc') ->select(); $is_arr = $list->toarray(); if($is_arr){ $this->apiSuccess('获取成功',$list); }else{ $this->apiError('暂无数据',[]); } } //获取轮播,不管区域 public function get_slide_two() { $township = get_params('township'); // 乡镇 if($township){ $where['township'] = $township; } $slide_id = get_params('slide_id'); // 位置 if($slide_id){ $where['slide_id'] = $slide_id; } $where['status'] = 1; $list = Db::table('fa_slide_info')->where($where) ->order('sort desc') ->select(); $is_arr = $list->toarray(); if($is_arr){ $this->apiSuccess('获取成功',$list); }else{ $this->apiError('暂无数据',[]); } } }