add:俱乐部

This commit is contained in:
2025-04-29 18:28:12 +08:00
parent 0bd7421371
commit abfbb8d1ee
17 changed files with 614 additions and 89 deletions

View File

@@ -2,24 +2,25 @@
namespace addons\shopro\controller\zy;
use think\Db;
use think\Exception;
use app\admin\model\zy\Stadium;
use think\exception\PDOException;
use addons\shopro\controller\Common;
use think\exception\ValidateException;
class Gym extends Common
class Gym extends Base
{
// protected $noNeedLogin = ['index'];
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
public function __construct()
{
$this->model = new \app\admin\model\zy\Stadium;
parent::__construct();
}
public function index()
{
$params = $this->request->param();
$model = Stadium::where('status', 1);
$model = $this->model->where('status', 1);
if (isset($params['name'])) {
$model->where('name', 'like', '%' . $params['name'] . '%');
}
@@ -28,53 +29,4 @@ class Gym extends Common
$this->success('获取成功', $res);
}
public function add()
{
$result = false;
$params = $this->request->param();
Db::startTrans();
try {
$result = (new Stadium)->allowField(true)->save($params);
Db::commit();
} catch (ValidateException | PDOException | Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if ($result === false) {
$this->error(__('No rows were inserted'));
}
$this->success();
}
public function update()
{
$result = false;
$params = $this->request->param();
$model = Stadium::get($params['id']);
if (empty($model)) {
$this->error(__('No rows were found'));
}
Db::startTrans();
try {
$result = $model->allowField(true)->save($params);
Db::commit();
} catch (ValidateException | PDOException | Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if ($result === false) {
$this->error(__('No rows were inserted'));
}
$this->success();
}
public function view()
{
$model = Stadium::get($this->request->param('id'));
if (empty($model)) {
$this->error(__('No rows were found'));
}
$this->success($model);
}
}