10 changed files with 102 additions and 15 deletions
@ -0,0 +1,16 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace app\home\controller; |
||||
|
|
||||
|
use app\home\service\ConfigService; |
||||
|
|
||||
|
class Config extends HomeBaseController{ |
||||
|
|
||||
|
// 获取管理端添加的配置 |
||||
|
public function getConfigByKey() |
||||
|
{ |
||||
|
$service = new ConfigService(); |
||||
|
$result = $service->getConfigByKey($this->request->param()); |
||||
|
return json($result); |
||||
|
} |
||||
|
} |
@ -0,0 +1,25 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace app\home\service; |
||||
|
|
||||
|
use app\model\ConfigModel; |
||||
|
|
||||
|
class ConfigService extends BaseHomeService |
||||
|
{ |
||||
|
public function getConfigByKey($param) |
||||
|
{ |
||||
|
try { |
||||
|
if (empty($param['name'])) { |
||||
|
return $this->toData('400', '参数错误'); |
||||
|
} |
||||
|
$configData = []; |
||||
|
$config = ConfigModel::where(['name'=>trim($param['name'])])->find(); |
||||
|
if (!empty($config)) { |
||||
|
$configData = $config->toArray(); |
||||
|
} |
||||
|
return $this->toData('0', 'SUCCESS', ['data' => $configData]); |
||||
|
} catch (\Exception $e) { |
||||
|
return $this->toData('500', 'The system is busy. Please try again later.', [$e->getMessage()]); |
||||
|
} |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue