Files
fast/addons/shopro/controller/zy/Game.php
xiadc 98eda4e5ff feat(zy): 添加俱乐部功能和用户消息功能
- 新增俱乐部相关接口和功能,包括创建俱乐部、申请加入俱乐部、邀请加入俱乐部等
- 添加用户消息功能,包括发送消息、查看消息等
- 优化了部分代码结构,提高了可维护性
- 更新了文档,添加了新的接口说明
2025-05-04 11:11:44 +08:00

61 lines
1.6 KiB
PHP

<?php
namespace addons\shopro\controller\zy;
class Game extends Base
{
public function __construct()
{
$this->model = new \app\admin\model\zy\game\Game;
parent::__construct();
}
public function index()
{
$params = $this->request->param();
$model = $this->model;
if (isset($params['name'])) {
$model->where('name', 'like', '%' . $params['name'] . '%');
}
if (isset($params['club_id'])) {
$model->where('club_id', $params['club_id']);
}
if (isset($params['week'])) {
$model->where('week', $params['week']);
}
if (isset($params['pid'])) {
$model->where('pid', $params['pid']);
} else {
$model->where('pid', 0);
}
if (isset($params['public_time'])) {
$model->where('public_time', $params['public_time']);
} else {
$model->where('public_time', '<=', date('Y-m-d H:i:s'));
}
$res = $model->select();
foreach ($res as &$v) {
$v['cost'] = json_decode($v['cost'] ?? '[]', true);
$v['referee'] = explode(',', $v['referee']);
}
$this->success('Success', $res);
}
public function view()
{
$model = $this->model->get($this->request->param('id'));
if (empty($model)) {
$this->error(__('No rows were found'));
}
$model['cost'] = json_decode($model['cost'] ?? '[]', true);
$model['referee'] = explode(',', $model['referee']);
$this->success('Success', $model);
}
}