You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
3.1 KiB
93 lines
3.1 KiB
<?php
|
|
|
|
namespace app\admin\controller;
|
|
|
|
use app\admin\service\ConfigService;
|
|
use think\facade\Filesystem;
|
|
use app\model\ConfigModel;
|
|
|
|
class Config extends AdminBaseController
|
|
{
|
|
|
|
public function setConfig()
|
|
{
|
|
try {
|
|
$param = $this->request->param();
|
|
if (empty($param['name'])) return json(['code' => '1', 'message' => '参数错误', 'data' => []]);
|
|
$name = $param['name'];
|
|
$type = $param['type'] ?? 'string';
|
|
$value = $param['value'] ?? '';
|
|
$tip = $param['tip'] ?? '';
|
|
|
|
$insertData = [
|
|
'name' => $name,
|
|
'group' => 'config',
|
|
'title' => $name,
|
|
'tip' => $tip,
|
|
'type' => $type,
|
|
'value' => $value,
|
|
];
|
|
|
|
$config = ConfigModel::where('name', $name)->find();
|
|
if (empty($config)) {
|
|
$bool = ConfigModel::insert($insertData);
|
|
if (!$bool) return json(['code' => '100500', 'message' => '设置失败', 'data' => []]);
|
|
} else {
|
|
$bool = ConfigModel::where('name', $name)->update($insertData);
|
|
if (!$bool) return json(['code' => '100500', 'message' => '设置失败', 'data' => []]);
|
|
}
|
|
|
|
return json(['code' => '0', 'message' => 'Request successful', 'data' => []]);
|
|
} catch (\Exception $exception) {
|
|
return json(['code' => '100500', 'message' => '系统繁忙', 'data' => [$exception->getMessage()]]);
|
|
}
|
|
}
|
|
|
|
public function getConfig()
|
|
{
|
|
try {
|
|
$param = $this->request->param();
|
|
if (empty($param['name'])) return json(['code' => '1', 'message' => '参数错误', 'data' => []]);
|
|
$name = $param['name'];
|
|
$value = ConfigModel::where('name', $name)->value('value');
|
|
|
|
return json(['code' => '0', 'message' => 'Request successful', 'data' => ['value' => $value]]);
|
|
} catch (\Exception $exception) {
|
|
return json(['code' => '100500', 'message' => '系统繁忙', 'data' => [$exception->getMessage()]]);
|
|
}
|
|
}
|
|
|
|
public function getConfigList()
|
|
{
|
|
$returnData = (new ConfigService())->getConfigList($this->request->param());
|
|
return json($returnData);
|
|
}
|
|
|
|
// 获取邮箱模板列表
|
|
public function emailTemplateList()
|
|
{
|
|
$returnData = (new ConfigService())->emailTemplateList($this->request->param());
|
|
return json($returnData);
|
|
}
|
|
|
|
// 编辑邮箱模板列表
|
|
public function editEmailTemplate()
|
|
{
|
|
$returnData = (new ConfigService())->editEmailTemplate($this->request->param());
|
|
return json($returnData);
|
|
}
|
|
|
|
// 短信模板列表
|
|
public function smsTemplateList()
|
|
{
|
|
$returnData = (new ConfigService())->smsTemplateList($this->request->param());
|
|
return json($returnData);
|
|
}
|
|
|
|
// 编辑邮短信板列表
|
|
public function editSmsTemplate()
|
|
{
|
|
$returnData = (new ConfigService())->editSmsTemplate($this->request->param());
|
|
return json($returnData);
|
|
}
|
|
}
|