51 lines
1.1 KiB
PHP
51 lines
1.1 KiB
PHP
<?php
|
|
namespace App\Domains\Config\Http\Controllers;
|
|
|
|
use App\Core\Controller;
|
|
use Illuminate\Http\Request;
|
|
use App\Domains\Config\Services\ConfigService;
|
|
|
|
class ConfigController extends Controller
|
|
{
|
|
protected $request;
|
|
protected $configService;
|
|
|
|
/**
|
|
* 构造函数,自动注入.
|
|
*/
|
|
public function __construct(Request $request, ConfigService $configService)
|
|
{
|
|
$this->request = $request;
|
|
$this->configService = $configService;
|
|
$this->appid = app('dipper')->application->id ?: 0;
|
|
}
|
|
|
|
/**
|
|
* 获取配置
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function get()
|
|
{
|
|
$key = $this->request->get('key');
|
|
$config = $this->configService->get($this->appid, $key);
|
|
|
|
return res($config, '获取配置', 201);
|
|
}
|
|
|
|
|
|
/**
|
|
* 修改配置
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function set()
|
|
{
|
|
$key = $this->request->get('key');
|
|
$value = $this->request->get('value');
|
|
$config = $this->configService->set($this->appid, $key, $value);
|
|
|
|
return res(true, '配置成功');
|
|
}
|
|
}
|