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.
69 lines
2.2 KiB
69 lines
2.2 KiB
9 months ago
|
<?php
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | 天诚科技 [ 刘海东 17600099397赋能开发者,助力企业发展 ]
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | Copyright (c) 2016~2020 https://www.tczxkj.com All rights reserved.
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | Licensed 该系统并不是自由软件,未经许可不能去掉相关版权
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | Author:甘肃天诚志信电子商务有限公司 刘海东 联系电话维系17600099397
|
||
|
// +----------------------------------------------------------------------
|
||
|
|
||
|
namespace app\admin\controller\setting;
|
||
|
|
||
|
use app\admin\controller\AuthController;
|
||
|
use app\admin\model\system\SystemConfigContent as SystemConfigContentModel;
|
||
|
use service\JsonService;
|
||
|
|
||
|
/**
|
||
|
* 配置文章
|
||
|
* Class SystemConfigContent
|
||
|
* @package app\admin\controller\setting
|
||
|
*/
|
||
|
class SystemConfigContent extends AuthController
|
||
|
{
|
||
|
/**
|
||
|
* 展示数据
|
||
|
* @param int $id
|
||
|
* @return mixed|void
|
||
|
*/
|
||
|
public function index($id = 0)
|
||
|
{
|
||
|
if (!$id) {
|
||
|
return $this->failed('缺少参数');
|
||
|
}
|
||
|
$this->assign([
|
||
|
'id' => $id,
|
||
|
'content' => SystemConfigContentModel::getValue($id, 'id'),
|
||
|
'title' => SystemConfigContentModel::getValue($id, 'id', 'title'),
|
||
|
]);
|
||
|
return $this->fetch();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 保存数据
|
||
|
* @param int $id
|
||
|
* @throws \think\exception\DbException
|
||
|
*/
|
||
|
public function save($id = 0)
|
||
|
{
|
||
|
if (!$id) {
|
||
|
return $this->failed('缺少参数');
|
||
|
}
|
||
|
$content = $this->request->post('content', '');
|
||
|
$info = SystemConfigContentModel::get($id);
|
||
|
if (!$info) {
|
||
|
return JsonService::fail('您保存的配置不存在');
|
||
|
}
|
||
|
if (!$content) {
|
||
|
return JsonService::fail('内容不能为空');
|
||
|
}
|
||
|
$data['content'] = htmlspecialchars($content);
|
||
|
if (SystemConfigContentModel::edit($data, $id)) {
|
||
|
return JsonService::successful('保存成功');
|
||
|
} else {
|
||
|
return JsonService::fail('保存失败');
|
||
|
}
|
||
|
}
|
||
|
}
|