Commit 36aa31cd by 朱继来

添加cms配置

parent 33a08254
<?php
return array(
'LOAD_EXT_CONFIG' => 'config_db,config_url,config_pwd,config_param,config_supplier,chain_config,footstone_config,config_pcb',
'LOAD_EXT_CONFIG' => 'config_db,config_url',
'VAR_PAGE' => 'p',
'APP_SUB_DOMAIN_DEPLOY' => true,
'APP_SUB_DOMAIN_RULES' => array(
......
<?php
return array(
'DB_TYPE' => 'mysql', // 数据库类型
'DB_HOST' => '192.168.2.232', // 服务器地址
'DB_NAME' => 'liexin', // 数据库名
'DB_USER' => 'liexin', // 用户名
'DB_PWD' => 'liexin#zsyM', // 密码
'DB_PORT' => '3306', // 端口
'DB_PREFIX' => 'lie_', // 数据库表前缀
'DB_PARAMS' => array(), // 数据库连接参数
'DB_DEBUG' => true, // 数据库调试模式 开启后可以记录SQL日志
'DB_FIELDS_CACHE' => true, // 启用字段缓存
'DB_CHARSET' => 'utf8', // 数据库编码默认采用utf8
'DB_DEPLOY_TYPE' => 0, // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
'DB_RW_SEPARATE' => false, // 数据库读写是否分离 主从式有效
'DB_MASTER_NUM' => 1, // 读写分离后 主服务器数量
'DB_SLAVE_NO' => '', // 指定从服务器序号
'DB_OTHER' => array(
'CMS' => array(
'db_type' => 'mysql',
'db_user' => 'ichuntcms',
'db_pwd' => 'ichuntcms#zsyM',
'db_host' => '192.168.2.232',
'db_port' => '3306',
'db_name' => 'ichuntcms',
'db_charset'=>'utf8',
),
'FS' => array(
'db_type' => 'mysql',
'db_user' => 'spu',
'db_pwd' => 'spu',
'db_host' => '192.168.1.234',
'db_port' => '3306',
'db_name' => 'liexin_spu',
'db_charset'=>'utf8',
),
),
/*撮合数据库*/
"MATCHES_DB_CONFIG" => array(
'db_type' => 'mysql',
'db_user' => 'matches',
'db_pwd' => 'matches#zsyM',
'db_host' => 'db1.ichunt.com',
'db_port' => '3306',
'db_name' => 'matches',
'db_prefix' => 'lie_',
'db_charset'=>'utf8',
),
//数据中心mysql 后面记得要拼接数据库名称
'SUPPLIER_CENTER_MYSQL' => 'mysql://root:HuntxB9#zsyM@192.168.2.232:3306/',
//Mongo
'DB_MONGO' => array(
'db_type' => 'mongo',
'db_user' => 'ichunt',
'db_pwd' => 'huntmon6699',
'db_host' => '192.168.1.237',
'db_port' => '27017',
'db_name' => 'logs',
'db_charset'=>'utf8',
),
'SUPPLIER_CENTER_DB_CONFIG' => array(
/* 数据库配置 */
'db_type' => 'mongo', // 数据库类型
'db_host' => '192.168.1.237',// 服务器地址
'db_name' => 'ichunt', // 数据库名
'db_user' => 'ichunt', // 用户名
'db_pwd' => 'huntmon6699', // 密码
'db_port' => '27017', // 端口
'db_prefix' => '', // 数据库表前缀
),
//REDIS
'REDIS_HOST' => '192.168.1.235,192.168.1.237',
'REDIS_PORT' => 6379,
'REDIS_PASSWORD' => 'icDb29mLy2s',
'REDIS_RW_SEPARATE' => true,
'DATA_CACHE_TIMEOUT'=> false,
'DATA_CACHE_PERSISTENT' => false,
//基石系统redis
'FS_REDIS_HOST'=>'192.168.1.235,192.168.1.237',
'FS_REDIS_PORT' => 6379,
'FS_REDIS_PASSWORD' => 'icDb29mLy2s',
//spu与sku的数据库连接
'SPU_SKU_MYSQL' => 'mysql://spu:spu@192.168.1.234:3306/',
//rabbitmq链接信息
'RABBITMQ_FLAG'=>true,//为true时打开记录信息
'RABBITMQ_CONFIG'=>array(
"host" => "192.168.2.232",
"port" => "5672",
"user_name" => "guest",
"password" => "guest",
),
//神策
'RABBITMQ_SENSOR_CONFIG'=>array(
"host" => "192.168.2.232",
"port" => "5672",
"user_name" => "guest",
"password" => "guest",
'vhost'=>'/'
),
);
\ No newline at end of file
<?php
namespace Home\Controller;
use Think\Controller;
class BaseController extends Controller
{
public function _initialize()
{
$datas['logo'] = $this->apiBaseCache('pc_logo_set'); // logo
$datas['bottom_qrcode'] = $this->apiBaseCache('pc_bottom_qrcode'); // 底部二维码
foreach ($datas as $k => $v) {
$this->assign($k, $v['data']);
}
}
/**
* 通过bcat_id获取CMS分类数据 --- 图片、文字等
* @param [type] $tags [标签]
* @param [type] $where [搜索条件,用&连接,如:a=1&b=2]
* @param [type] $limit [数量]
* @return [type] [description]
*/
public function apiBaseCache($tags, $where='', $limit=1)
{
$cms = D('Home/Scms');
$datas = $cms->getBaseList($tags, $where, $limit);
if (!empty($datas)) {
return $this->apiReturn(0, '', $datas);
} else {
return $this->apiReturn(7004, '未找到数据');
}
}
/**
* 统一格式返回
* @param integer $code [description]
* @param string $msg [description]
* @param array $extend [description]
* @return [type] [description]
*/
protected function apiReturn($code = 0, $msg = '', $extend = array())
{
$data = array(
'err_code' => $code,
'err_msg' => $msg,
'data' => $extend,
);
if(isset($_GET['callback']) && !empty($_GET['callback'])){
echo $_GET['callback'].'('.json_encode($data).')';exit;
}else{
return $data;exit;
}
}
}
\ No newline at end of file
<?php
namespace Home\Controller;
use Think\Controller;
use Home\Controller\BaseController;
class IndexController extends Controller
class IndexController extends BaseController
{
/**
......@@ -12,6 +11,12 @@ class IndexController extends Controller
*/
public function index()
{
$datas['cooperation_pf'] = $this->apiBaseCache('pc_home_cooperation_pf', '', ''); // 合作平台
foreach ($datas as $k => $v) {
$this->assign($k, $v['data']);
}
$this->display('Index/index');
}
......
<?php
/**
* 获取CMS缓存
*/
namespace Home\Model;
class ScmsModel
{
/**
* 获取bcat_id
* @param [type] $key [键]
* @param integer $type [取值类型:1-通过tags,2-通过tem_id(楼层类目)]
* @return [type] [description]
*/
public function getBcatId($key, $type=1)
{
return $type == 1 ? S_cms('icsales:lie_base_cat:tags', $key, 'bcat_id') : S_cms('icsales:lie_base_cat:tem_id:'.$key);
}
/**
* 获取base数据
* @param [type] $key [键]
* @param string $limit [限制数量]
* @param integer $type [取值类型:1-通过bcat_id, 2-通过tem_id,3-通过model_id]
* @return [type] $condition [搜索条件,用&连接,如:a=1&b=2]
* @param [type] $table [表名]
* @return [type] [description]
*/
public function getBase($key, $limit='', $condition='', $type=1, $table='lie_base')
{
if ($type == 1)
$datas = S_cms('icsales:'.$table.':bcat_id:'.$key, '', '', 'sort');
else if ($type == 2)
$datas = S_cms('icsales:'.$table.':tem_id:'.$key, '', '', 'sort');
else
$datas = S_cms('icsales:'.$table.':model_id:'.$key, '', '', 'sort');
if (!$datas) return $datas;
if ($condition) {
parse_str($condition, $arr); // 解析条件,输出数组
$isTrue = true;
$datas = array_filter($datas, function($base) use ($arr, $isTrue) {
foreach ($arr as $k=>$v) {
if (isset($base[$k]) && $base[$k] != $v) { // 判断每个搜索条件是否存在且值相等,若不相等,则过滤对应的datas数组值
$isTrue = false;
}
}
return $isTrue;
});
array_multisort($datas); // 重新索引
}
$datas = $limit ? array_slice($datas, 0, $limit) : $datas;
return $datas;
}
/**
* 获取Base表配置内容
* @param [type] $tags [tags值]
* @param string $where [条件]
* @param string $limit [限制数量]
* @return [type] [description]
*/
public function getBaseList($tags, $where='', $limit=1)
{
$bcat_id = $this->getBcatId($tags); // 分类ID
return $this->getBase($bcat_id, $limit, $where);
}
/**
* 获取楼层模板
* @param [type] $key [键]
* @return [type] [description]
*/
public function getTemplate($key)
{
return S_cms('icsales:lie_template:tag:'.$key, '', '', 'sort');
}
/**
* 获取模块
* @param [type] $field [字段值]
* @param string $column [指定列]
* @return [type] [description]
*/
public function getModel($field, $column='')
{
return $column ? S_cms('icsales:lie_model:model_key', $field, $column) : S_cms('icsales:lie_model:model_key', $field);
}
/**
* 获取导航
* @param integer $model_id [所属模块ID]
* @param integer $parent_id [所属父级ID] <先查找模块下所有导航,遍历后,根据nav_id查找对应子级>
* @return [type] [description]
*/
public function getNavigation($model_id, $parent_id=0)
{
return $parent_id == 0 ? S_cms('icsales:lie_navigation:model_id:'.$model_id, '', '', 'sort') : S_cms('icsales:lie_navigation:model_id:'.$model_id.':parent_id:'.$parent_id, '', '', 'sort');
}
/**
* 获取帮助中心分类
* @param integer $model_id [所属模块ID]
* @param integer $parent_id [所属父级ID] <先查找模块下所有分类,遍历后,根据hccat_id查找对应子级>
* @return [type] [description]
*/
public function getHelpCenterCat($model_id, $parent_id=0)
{
return $parent_id == 0 ? S_cms('icsales:lie_help_center_cat:model_id:'.$model_id, '', '', 'sort') : S_cms('icsales:lie_help_center_cat:model_id:'.$model_id.':parent_id:'.$parent_id, '', '', 'sort');
}
/**
* 获取帮助中心内容
* @param [type] $hccat_id [帮助中心分类ID]
* @return [type] [description]
*/
public function getHelpCenter($hccat_id)
{
return S_cms('icsales:lie_help_center:hccat_id:'.$hccat_id, '', '', 'sort');
}
/**
* 获取底部链接分类
* @param integer $fcat_key [所属模块ID]
* @param integer $column [指定字段]
* @param integer $parent_id [所属父级ID] <先查找模块下所有分类,遍历后,根据fcat_id查找对应子级>
* @return [type] [description]
*/
public function getFooterLinkCat($fcat_key, $column='', $parent_id=0)
{
return $parent_id == 0 ? S_cms('icsales:lie_footer_link_cat:fcat_key', $fcat_key, $column, 'sort') : S_cms('icsales:lie_footer_link_cat:parent_id:'.$parent_id, '', '', 'sort');
}
/**
* 获取底部链接内容
* @param [type] $fcat_id [帮助中心分类ID]
* @return [type] [description]
*/
public function getFooterLink($fcat_id)
{
return S_cms('icsales:lie_footer_link:fcat_id:'.$fcat_id, '', '', 'sort');
}
/**
* 获取页面分类
* @param integer $model_id [所属模块ID]
* @return [type] [description]
*/
public function getPageCat($model_id)
{
return S_cms('icsales:lie_page_cat:model_id:'.$model_id);
}
/**
* 获取页面内容
* @param [type] $pagecat_id [页面分类ID]
* @return [type] [description]
*/
public function getPage($pagecat_id)
{
return S_cms('icsales:lie_page:pagecat_id:'.$pagecat_id);
}
/************************************** 信宏泰配置 **************************************/
/**
* 获取公司
* @return [type] [description]
*/
public function getCompany()
{
return S_cms('icsales:xht:lie_company', '', '', 'sort');
}
/**
* 获取公司信息
* @param [type] $com_id [公司ID]
* @return [type] [description]
*/
public function getCompanyInfo($com_id)
{
return S_cms('icsales:xht:lie_company_info:com_id:'.$com_id, '', '', 'sort');
}
/**
* 获取公司图片
* @param [type] $com_id [公司ID]
* @return [type] [description]
*/
public function getCompanyImg($com_id)
{
return S_cms('icsales:xht:lie_company_img:com_id:'.$com_id, '', '', 'sort');
}
}
\ No newline at end of file
<?php
return array(
//'配置项'=>'配置值'
);
\ No newline at end of file
\ No newline at end of file
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment