add 基地列表

This commit is contained in:
chenbo 2024-01-15 15:32:21 +08:00
parent 1150d4eab4
commit 12b0e98a1c
1 changed files with 23 additions and 0 deletions

View File

@ -0,0 +1,23 @@
<?php
namespace app\api\controller;
use app\common\model\farm\Farm;
class FarmController extends BaseApiController
{
public function lists()
{
$params = $this->request->get(['page_no','page_size','keyword']);
$pageNo = empty($params['page_no']) ? 1 : $params['page_no'];
$pageSize = empty($params['page_size']) ? 6 : $params['page_size'];
$where = [
['user_id','=',$this->userId]
];
if(!empty($params['keyword'])){
$where[] = ['farm_name','like','%'.$params['keyword'].'%'];
}
$data = Farm::where($where)->page($pageNo,$pageSize)->order('create_time desc')->select()->toArray();
return $this->success('请求成功',$data);
}
}