<?php
// +----------------------------------------------------------------------
// | saiadmin [ saiadmin快速开发框架 ]
// +----------------------------------------------------------------------
// | Author: your name
// +----------------------------------------------------------------------
namespace app\dice\logic\config;

use app\dice\basic\DiceBaseLogic;
use app\dice\helper\AdminScopeHelper;
use app\dice\helper\ConfigScopeEditHelper;
use plugin\saiadmin\exception\ApiException;
use plugin\saiadmin\utils\Helper;
use app\dice\model\config\DiceConfig;

/**
 * 摇色子配置逻辑层
 */
class DiceConfigLogic extends DiceBaseLogic
{
    /**
     * 构造函数
     */
    public function __construct()
    {
        $this->model = new DiceConfig();
    }

    public function edit($id, array $data, ?array $adminInfo = null, $requestDeptId = null): mixed
    {
        $deptId = AdminScopeHelper::resolveConfigDeptId(
            $adminInfo,
            AdminScopeHelper::pickRequestDeptId($requestDeptId, $data)
        );
        return ConfigScopeEditHelper::updateByBusinessIdAndDept($this->model, (int) $id, $deptId, $data);
    }

}
