提交 1fcaa327 编写于 作者: D Devil

协议管理优化

上级 cfcd94cf
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
namespace app\api\controller; namespace app\api\controller;
use app\service\ApiService; use app\service\ApiService;
use app\service\SystemBaseService; use app\service\AgreementService;
/** /**
* 协议 * 协议
...@@ -45,7 +45,7 @@ class Agreement extends Common ...@@ -45,7 +45,7 @@ class Agreement extends Common
*/ */
public function Index() public function Index()
{ {
return ApiService::ApiDataReturn(SystemBaseService::AgreementData($this->data_request)); return ApiService::ApiDataReturn(AgreementService::AgreementData($this->data_request));
} }
} }
?> ?>
\ No newline at end of file
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\index\controller; namespace app\index\controller;
use app\service\ConfigService;
use app\service\SeoService; use app\service\SeoService;
use app\service\AgreementService;
/** /**
* 协议 * 协议
...@@ -52,16 +52,19 @@ class Agreement extends Common ...@@ -52,16 +52,19 @@ class Agreement extends Common
$data = []; $data = [];
if(!empty($params['document'])) if(!empty($params['document']))
{ {
$key = 'common_agreement_'.$params['document']; // 获取协议内容
$ret = ConfigService::ConfigContentRow($key); $ret = AgreementService::AgreementData($params);
// 浏览器标题 // 浏览器标题
if(!empty($ret['data']))
{
if(!empty($ret['data']['name'])) if(!empty($ret['data']['name']))
{ {
MyViewAssign('home_seo_site_title', SeoService::BrowserSeoTitle($ret['data']['name'])); MyViewAssign('home_seo_site_title', SeoService::BrowserSeoTitle($ret['data']['name']));
} }
$data = $ret['data']; $data = $ret['data'];
} }
}
// 是否仅展示内容 // 是否仅展示内容
$is_content = (isset($params['is_content']) && $params['is_content'] == 1) ? 0 : 1; $is_content = (isset($params['is_content']) && $params['is_content'] == 1) ? 0 : 1;
......
<?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 app\service\ConfigService;
/**
* 协议服务层
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2021-07-25
* @desc description
*/
class AgreementService
{
/**
* 协议数据
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2021-04-25
* @desc description
* @param [array] $params [输入参数]
*/
public static function AgreementData($params = [])
{
// 请求参数
$p = [
[
'checked_type' => 'empty',
'key_name' => 'document',
'error_msg' => '协议文档类型有误',
],
];
$ret = ParamsChecked($params, $p);
if($ret !== true)
{
return DataReturn($ret, -1);
}
// 获取内容
return ConfigService::ConfigContentRow('common_agreement_'.$params['document']);
}
}
?>
\ No newline at end of file
...@@ -22,16 +22,22 @@ use app\service\ResourcesService; ...@@ -22,16 +22,22 @@ use app\service\ResourcesService;
*/ */
class ConfigService class ConfigService
{ {
// 不参与缓存的配置
public static $not_cache_field_list = [
'common_agreement_userregister',
'common_agreement_userprivacy',
];
// 富文本,不实例化的字段 // 富文本,不实例化的字段
public static $rich_text_list = [ public static $rich_text_list = [
'home_footer_info', 'common_agreement_userregister',
'common_agreement_userprivacy',
'common_email_currency_template', 'common_email_currency_template',
'home_footer_info',
'home_email_user_reg', 'home_email_user_reg',
'home_email_user_forget_pwd', 'home_email_user_forget_pwd',
'home_email_user_email_binding', 'home_email_user_email_binding',
'home_site_close_reason', 'home_site_close_reason',
'common_agreement_userregister',
'common_agreement_userprivacy',
'common_self_extraction_address', 'common_self_extraction_address',
'home_index_floor_top_right_keywords', 'home_index_floor_top_right_keywords',
'home_index_floor_manual_mode_goods', 'home_index_floor_manual_mode_goods',
...@@ -39,7 +45,6 @@ class ConfigService ...@@ -39,7 +45,6 @@ class ConfigService
'admin_email_login_template', 'admin_email_login_template',
'home_email_login_template', 'home_email_login_template',
'home_site_security_record_url', 'home_site_security_record_url',
'layout_index_home_data',
]; ];
// 附件字段列表 // 附件字段列表
...@@ -186,6 +191,7 @@ class ConfigService ...@@ -186,6 +191,7 @@ class ConfigService
// 单条配置缓存删除 // 单条配置缓存删除
MyCache($k, null); MyCache($k, null);
MyCache($k.'_row_data', null);
} }
} }
if($success > 0) if($success > 0)
...@@ -265,6 +271,12 @@ class ConfigService ...@@ -265,6 +271,12 @@ class ConfigService
// 数据处理 // 数据处理
foreach($data as $k=>&$v) foreach($data as $k=>&$v)
{ {
// 不参与缓存的配置
if(in_array($k, self::$not_cache_field_list))
{
continue;
}
// 富文本字段处理 // 富文本字段处理
if(in_array($k, self::$rich_text_list)) if(in_array($k, self::$rich_text_list))
{ {
...@@ -361,7 +373,8 @@ class ConfigService ...@@ -361,7 +373,8 @@ class ConfigService
*/ */
public static function ConfigContentRow($key) public static function ConfigContentRow($key)
{ {
$data = MyCache($key); $cache_key = $key.'_row_data';
$data = MyCache($cache_key);
if($data === null) if($data === null)
{ {
$data = Db::name('Config')->where(['only_tag'=>$key])->field('name,value,type,upd_time')->find(); $data = Db::name('Config')->where(['only_tag'=>$key])->field('name,value,type,upd_time')->find();
...@@ -376,7 +389,7 @@ class ConfigService ...@@ -376,7 +389,7 @@ class ConfigService
} else { } else {
$data = []; $data = [];
} }
MyCache($key, $data); MyCache($cache_key, $data);
} }
return DataReturn('操作成功', 0, $data); return DataReturn('操作成功', 0, $data);
......
...@@ -14,7 +14,6 @@ use think\facade\Db; ...@@ -14,7 +14,6 @@ use think\facade\Db;
use app\service\ResourcesService; use app\service\ResourcesService;
use app\service\QuickNavService; use app\service\QuickNavService;
use app\service\PluginsService; use app\service\PluginsService;
use app\service\ConfigService;
/** /**
* 系统基础公共信息服务层 * 系统基础公共信息服务层
...@@ -445,35 +444,6 @@ class SystemBaseService ...@@ -445,35 +444,6 @@ class SystemBaseService
return $status; return $status;
} }
/**
* 协议数据
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2021-04-25
* @desc description
* @param [array] $params [输入参数]
*/
public static function AgreementData($params = [])
{
// 请求参数
$p = [
[
'checked_type' => 'empty',
'key_name' => 'document',
'error_msg' => '协议文档类型有误',
],
];
$ret = ParamsChecked($params, $p);
if($ret !== true)
{
return DataReturn($ret, -1);
}
// 获取内容
return ConfigService::ConfigContentRow('common_agreement_'.$params['document']);
}
/** /**
* 附件地址 * 附件地址
* @author Devil * @author Devil
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册