<?php

namespace App\Ad\Models;

use App\Models\BaseModel;

class SysAdPositionModel extends BaseModel
{
    protected $table = 'sys_ad_position';


    /**
     * 获取广告列表
     * */
    public function getAdPositionList($params){
        list($pageSize, $page, $skip) = $this->getPaginatorParams($params);
        $where=[];
        if(isset($params['status'])){
            $where[]=['a.status','=',$params['status']];
        }else{
            $where[]=['a.status','<',2];
        }
        $query= $this->newInstance()->alias('a')->where($where);
        $totalCount = $query->count();
        $list= $query->skip($skip)
            ->limit($pageSize)
            ->selectRaw('a.*')
            ->orderBy('a.update_time','desc')
            ->get();
        if(!empty($list)){
            $list=$list->toArray();
        }else{
            $list=[];
        }
        $result = $this->buildPaginator($list, $skip, $page, $pageSize, $totalCount);
        return $result;
    }
}
