1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- namespace app\api\controller;
- use app\api\model\GonggaoModel;
- use app\api\model\ImagesModel;
- use app\api\model\MemberHouseModel;
- use app\common\controller\Api;
- use app\api\model\ArticleModel;
- /**
- * 首页接口
- * @ApiWeigh (101)
- */
- class Index extends Api
- {
- protected $noNeedLogin = ['phpi'];//,'my_keys','my_detail'
- protected $noNeedRight = ['*'];
- /**
- * 首页接口-轮播图,头条,资讯
- *
- * @ApiTitle (首页接口-轮播图,头条,资讯)
- * @ApiSummary (首页接口-轮播图,头条,资讯)
- * @ApiMethod (POST)
- * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
- * @ApiRoute (/api/index/index)
- *
- * @ApiParams (name="user_id", type="int", required=true, description="用户id")
- * @ApiParams (name="token", type="int", required=true, description="请求的Token")
- * @ApiReturn ()
- */
- public function index(){
- $userId = $this->request->post('user_id');
- if (empty($userId)){
- $this->result('登录信息丢失');
- }
- $get_image=ImagesModel::where(['status'=>'1'])->order('weigh desc')->field('id,image')->select();
- $get_gonggao=GonggaoModel::where(['status'=>'1','is_delete'=>'0'])->order('id desc')->field('id,title')->find();
- $get_list=ArticleModel::where(['status'=>'1','is_delete'=>'0'])->order('id desc')->field('id,title,createtime,images')->limit('5')->select();
- $get_house=MemberHouseModel::where('mid',$userId)
- ->where('is_delete','0')
- ->with(['village'])
- ->field('village_id,id')
- ->select();
- foreach ($get_house as $k=>$v){
- $get_house[$k]['name']=$v['village']['name'];
- unset($get_house[$k]['village']);
- }
- $this->result('success', ['images'=>$get_image,'gonggao'=>$get_gonggao,'article'=>$get_list,'house'=>$get_house], 1);
- }
- }
|