123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- declare (strict_types = 1);
- namespace app\model\system;
- use library\basic\BaseModel;
- use library\traits\JwtAuthModelTrait;
- use library\traits\ModelTrait;
- use think\Model;
- /**
- * @mixin \think\Model
- */
- class Advert extends BaseModel
- {
- use ModelTrait;
- use JwtAuthModelTrait;
- /**
- * 获取列表数据
- * @param $page
- * @param $where
- * @param $pageCount
- * @param $desc
- */
- public function getList($page,$where = [],$pageCount = 20,$filed = '*',$desc = ''){
- $data = $this
- ->field("p.*,ap.cate_name,ap.json")
- ->alias("p")
- ->join("adver_page ap",'ap.id=p.page_id')
- ->when(!empty($where),function ($query) use($where){
- if(!empty($where['page_id'])) {
- $query->where('p.page_id',$where['page_id']);
- }
- if(!empty($where['title'])) {
- $query->wherelike('p.title','%' . $where['title'] . '%');
- }
- if(isset($where['sassid'])) {
- $query->where('p.sassid',$where['sassid']);
- }
- })
- ->order($desc)
- ->paginate(['list_rows'=>$pageCount,'page'=>$page])
- ->toArray();
- foreach ($data['data'] as $k=>$v) {
- $data['data'][$k]['time'] = date('Y-m-d',$v['time']);
- $data['data'][$k]['jsonAr'] = json_decode($v['data'],true);
- }
- //echo $this->getLastSql();
- return [$data['total'],$data['data']];
- }
- /**
- * 保存分类
- * @param $post
- * @return bool
- */
- public function savePage($post){
- if(!empty($post['id'])) {
- $this->where('id',$post['id'])->save($post);
- return true;
- } else {
- unset($post['id']);
- $post['time'] = time();
- $bool = $this->insert($post);
- return $bool;
- }
- }
- //
- }
|