<?php
// +----------------------------------------------------------------------
// | saiadmin [ saiadmin快速开发框架 ]
// +----------------------------------------------------------------------
namespace app\dice\logic\game;

use app\dice\basic\DiceBaseLogic;
use app\dice\helper\AdminScopeHelper;
use app\dice\helper\ConfigScopeEditHelper;
use app\dice\model\game\DiceGame;

/**
 * 游戏管理逻辑层
 */
class DiceGameLogic extends DiceBaseLogic
{
    public function __construct()
    {
        $this->model = new DiceGame();
    }

    public function edit($id, array $data, ?array $adminInfo = null, $requestDeptId = null): mixed
    {
        $pickedDeptId = AdminScopeHelper::pickRequestDeptId($requestDeptId, $data);
        $deptId = AdminScopeHelper::resolveConfigDeptId($adminInfo, $pickedDeptId);
        return ConfigScopeEditHelper::updateByPkAndDept(
            $this->model,
            $id,
            $deptId,
            $data,
            ['id', 'dept_id', 'create_time', 'update_time', 'delete_time', 'row_id'],
            $adminInfo,
            $pickedDeptId
        );
    }
}
