feat(俱乐部和比赛模块): 增加俱乐部和比赛的相关功能和优化
- 在 Club 控制器中添加了对俱乐部列表的查询,包括俱乐部名称、场馆名称、俱乐部标签等信息 - 在 Game 控制器中增加了对比赛列表的查询,包括比赛名称、场馆名称、俱乐部名称、参赛选手头像等信息 - 优化了 Game 控制器中的比赛详情查询,增加了参赛选手头像的解析 - 在 Game、GameJoin 和 Participant 模型中添加了 tableName 静态属性,便于统一管理表名
This commit is contained in:
@@ -4,6 +4,7 @@ namespace addons\shopro\controller\zy;
|
||||
|
||||
use app\admin\model\zy\Club;
|
||||
use app\admin\model\zy\Stadium;
|
||||
use app\admin\model\zy\game\Participant;
|
||||
|
||||
|
||||
class Game extends Base
|
||||
@@ -18,9 +19,10 @@ class Game extends Base
|
||||
{
|
||||
$params = $this->request->param();
|
||||
$query = $this->model->alias('g')
|
||||
->join([Participant::$tableName => 'p'], 'p.game_id=g.id', 'LEFT')
|
||||
->join([Stadium::$tableName => 's'], 's.id = g.gym_id', 'LEFT')
|
||||
->join([Club::$tableName => 'c'], 'c.id = g.club_id', 'LEFT')
|
||||
->field('g.*, s.name as gym_name, c.name as club_name');
|
||||
->field('g.*, s.name as gym_name, c.name as club_name,JSON_ARRAYAGG(p.avatar) as avatar,count(p.id) as join_num');
|
||||
if (isset($params['name'])) {
|
||||
$query->where('g.name', 'like', '%' . $params['name'] . '%');
|
||||
}
|
||||
@@ -49,6 +51,7 @@ class Game extends Base
|
||||
$list = $res->items();
|
||||
foreach ($list as &$v) {
|
||||
$v['cost'] = json_decode($v['cost'] ?? '[]', true);
|
||||
$v['avatar'] = json_decode($v['avatar'] ?? '[]', true);
|
||||
}
|
||||
$this->success('Success', ['list' => $list, 'count' => $res->total()]);
|
||||
}
|
||||
@@ -59,7 +62,7 @@ class Game extends Base
|
||||
if (empty($model)) {
|
||||
$this->error(__('No rows were found'));
|
||||
}
|
||||
|
||||
|
||||
$model['cost'] = json_decode($model['cost'] ?? '[]', true);
|
||||
$model['referee'] = explode(',', $model['referee']);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user