Files
fast/addons/shopro/controller/zy/Gym.php
xiadc c2478c1aea refactor(zy): 重构查询接口并添加分页功能
- 重构了 Activity、Circle、Club、Game 和 Gym 控制器中的查询方法
- 添加了分页功能,支持指定页码和每页数量
- 优化了查询结果,返回包含总数的格式化数据
- 使用 alias 和 join 方法改进了查询效率
- 删除了 Base 控制器中的通用查询方法
2025-05-11 17:58:45 +08:00

35 lines
839 B
PHP

<?php
namespace addons\shopro\controller\zy;
class Gym extends Base
{
protected $noNeedRight = ['*'];
public function __construct()
{
$this->model = new \app\admin\model\zy\Stadium;
parent::__construct();
}
public function index()
{
$params = $this->request->param();
$query = $this->model->where('status', 1);
if (isset($params['name'])) {
$query->where('name', 'like', '%' . $params['name'] . '%');
}
if (isset($params['page'])) {
$pageSize = intval($params['pageSize'] ?? 10);
$offeset = (intval($params['page']) - 1) * $pageSize;
$query->limit($offeset, $pageSize);
}
$res = $query->select();
$this->success('Success', ['list' => $res, 'count' => $query->count()]);
}
}