103 lines
3.0 KiB
PHP
103 lines
3.0 KiB
PHP
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | ShopXO 国内领先企业级B2C免费开源电商系统
|
|
// +----------------------------------------------------------------------
|
|
// | Copyright (c) 2011~2099 http://shopxo.net All rights reserved.
|
|
// +----------------------------------------------------------------------
|
|
// | Licensed ( https://opensource.org/licenses/mit-license.php )
|
|
// +----------------------------------------------------------------------
|
|
// | Author: Devil
|
|
// +----------------------------------------------------------------------
|
|
namespace app\service;
|
|
|
|
use think\Db;
|
|
use app\layout\service\BaseLayout;
|
|
|
|
/**
|
|
* 布局服务层
|
|
* @author Devil
|
|
* @blog http://gong.gg/
|
|
* @version 1.0.0
|
|
* @date 2021-06-22
|
|
* @desc description
|
|
*/
|
|
class LayoutService
|
|
{
|
|
// 布局key
|
|
public static $layout_key = [
|
|
'home' => 'layout_index_home_data',
|
|
];
|
|
|
|
/**
|
|
* 布局配置保存
|
|
* @author Devil
|
|
* @blog http://gong.gg/
|
|
* @version 1.0.0
|
|
* @date 2021-06-22
|
|
* @desc description
|
|
* @param [string] $key [数据key值]
|
|
* @param [array] $params [输入参数]
|
|
*/
|
|
public static function LayoutConfigSave($key, $params)
|
|
{
|
|
// key 值是否存在
|
|
if(!array_key_exists($key, self::$layout_key))
|
|
{
|
|
return DataReturn('布局key值有', -1);
|
|
}
|
|
|
|
// 配置信息
|
|
$config = empty($params['config']) ? '' : BaseLayout::ConfigSaveHandle($params['config']);
|
|
|
|
// 数据保存
|
|
$type = self::$layout_key[$key];
|
|
$data = [
|
|
$type => $config,
|
|
'upd_time' => time(),
|
|
];
|
|
if(Db::name('Layout')->where(['type'=>$type, 'is_enable'=>1])->update($data))
|
|
{
|
|
return DataReturn('更新成功', 0);
|
|
}
|
|
return DataReturn('更新失败', -1);
|
|
}
|
|
|
|
/**
|
|
* 布局配置获取-管理
|
|
* @author Devil
|
|
* @blog http://gong.gg/
|
|
* @version 1.0.0
|
|
* @date 2021-06-22
|
|
* @desc description
|
|
* @param [string] $key [数据key值]
|
|
*/
|
|
public static function LayoutConfigAdminData($key)
|
|
{
|
|
if(array_key_exists($key, self::$layout_key))
|
|
{
|
|
$config = Db::name('Layout')->where(['type'=>self::$layout_key[$key], 'is_enable'=>1])->value('config');
|
|
return BaseLayout::ConfigAdminHandle($config);
|
|
}
|
|
return '';
|
|
}
|
|
|
|
/**
|
|
* 布局配置获取-展示使用
|
|
* @author Devil
|
|
* @blog http://gong.gg/
|
|
* @version 1.0.0
|
|
* @date 2021-06-22
|
|
* @desc description
|
|
* @param [string] $key [数据key值]
|
|
*/
|
|
public static function LayoutConfigData($key)
|
|
{
|
|
if(array_key_exists($key, self::$layout_key))
|
|
{
|
|
$config = Db::name('Layout')->where(['type'=>self::$layout_key[$key], 'is_enable'=>1])->value('config');
|
|
return BaseLayout::ConfigHandle($config);
|
|
}
|
|
return '';
|
|
}
|
|
}
|
|
?>
|