[接口]新增获取游戏配置接口-玩法

This commit is contained in:
2026-03-06 17:47:12 +08:00
parent dc86d0ae86
commit 330bd3b525
2 changed files with 27 additions and 0 deletions

View File

@@ -9,6 +9,7 @@ use support\Response;
use app\api\logic\GameLogic;
use app\api\logic\PlayStartLogic;
use app\api\util\ReturnCode;
use app\dice\model\config\DiceConfig;
use app\dice\model\play_record\DicePlayRecord;
use app\dice\model\player\DicePlayer;
use app\dice\model\reward_config\DiceRewardConfig;
@@ -20,6 +21,31 @@ use plugin\saiadmin\exception\ApiException;
*/
class GameController extends OpenController
{
/**
* 获取游戏配置(按 group 分组)
* GET /api/game/config
* 返回 data[group] = [ { name, title, value, create_time, update_time }, ... ]
*/
public function config(Request $request): Response
{
$rows = DiceConfig::select('name', 'group', 'title', 'value', 'create_time', 'update_time')->get();
$data = [];
foreach ($rows as $row) {
$group = $row->group ?? '';
if (!isset($data[$group])) {
$data[$group] = [];
}
$data[$group][] = [
'name' => $row->name,
'title' => $row->title,
'value' => $row->value,
'create_time' => $row->create_time,
'update_time' => $row->update_time,
];
}
return $this->success($data);
}
/**
* 购买抽奖券
* POST /api/game/buyLotteryTickets