Authored by hf

Merge branch 'master' into develop

... ... @@ -269,6 +269,50 @@ class IndexModel
return $result;
}
/**
* 逛标签列表或作者内容列表
*
* @param string $gender "1,3"表示男, "2,3"表示女, "1,2,3"表示所有
* @param int $sortId 分类ID
* @param int $uid 用户ID
* @param string $udid 客户端唯一标识
* @param int $page 分页第几页, 默认第1页
* @param string $tag 标签
* @param int $authorId 作者ID
* @return array
*/
public static function getArticleByTagOrEditor($gender, $sortId, $uid = 0, $udid = '', $page = 1, $tag = null, $authorId = null)
{
// 缓存键名
if (isset($tag)) {
$key = CacheConfig::KEY_ACTION_GUANG_LIST_DATA . sprintf('tag_%s_%s_%s_%s', $gender, $sortId, $page, $tag);
} else {
$key = CacheConfig::KEY_ACTION_GUANG_LIST_DATA . sprintf('editor_%s_%s_%s_%s', $gender, $sortId, $page, $authorId);
}
// 调用接口,获取内容
$article = ListData::article($gender, $sortId, $uid, $udid, $page, $tag, $authorId);
// 内容列表
if (!empty($article['data']['list']['artList'])) {
if (USE_CACHE) {
$result = Cache::get($key, 'master');
if (empty($result)) {
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
Cache::set($key, $article, 3600);
}
}
}
// 当接口异常时,尝试从二级缓存(slave)获取
elseif (USE_CACHE) {
$result = Cache::get($key, 'slave');
if (!empty($result)) {
return $result;
}
}
return $article;
}
/**
* 构建信息内容
... ...
... ... @@ -90,7 +90,8 @@ class IndexController extends AbstractAction
}
// 标签聚合内容列表
$article = ListData::article($gender, 0, $uid, $udid, 1, $tag);
//$article = ListData::article($gender, 0, $uid, $udid, 1, $tag);
$article = Guang\IndexModel::getArticleByTagOrEditor($gender, 0, $uid, $udid, 1, $tag);
// 标签聚合内容不存在, 跳到错误页面
if (empty($article['data']['list']['artList'])) {
$this->error();
... ... @@ -182,7 +183,8 @@ class IndexController extends AbstractAction
$data['authorInfo']['id'] = $id;
// 标签聚合内容列表
$article = ListData::article($gender, 0, $uid, $udid, 1, null, $id);
//$article = ListData::article($gender, 0, $uid, $udid, 1, null, $id);
$article = Guang\IndexModel::getArticleByTagOrEditor($gender, 0, $uid, $udid, 1, null, $id);
// 构建资讯文章内容
if (!empty($article['data']['list']['artList'])) {
$build = array();
... ... @@ -267,7 +269,7 @@ class IndexController extends AbstractAction
}
/**
* @todo 清缓存
* 内部清缓存
*/
public function clearAction()
{
... ... @@ -278,39 +280,46 @@ class IndexController extends AbstractAction
$type = $this->get('type');
switch (strval($type)) {
case 'boys':
case 'boys': // 男首
Cache::delete(CacheConfig::KEY_ACTION_BOYS_INDEX);
break;
case 'girls':
case 'girls': // 女首
Cache::delete(CacheConfig::KEY_ACTION_GIRLS_INDEX);
break;
case 'kids':
case 'kids': // 潮童
Cache::delete(CacheConfig::KEY_ACTION_KIDS_INDEX);
break;
case 'lifestyle':
case 'lifestyle': // 创意生活
Cache::delete(CacheConfig::KEY_ACTION_LIFESTYLE_INDEX);
break;
case 'bgimg':
case 'bgimg': // 频道选择背景图
Cache::delete(CacheConfig::KEY_ACTION_INDEX_INDEX);
break;
case 'brands':
case 'brands': // 品牌一览
Cache::delete('3206a153b0cebbd6e47be90c6ac41ee8');
Cache::delete('1c6bb62c480aec413b247d6f21e9c23a');
Cache::delete('60bb7899f49b3549dde438ac53526dea');
Cache::delete('9085ba21ac3d4f849c977da37a290a23');
break;
case 'new':
case 'new': // 新品
Cache::delete(CacheConfig::KEY_ACTION_PRODUCT_NEWSALE_INDEX . '3cf2c1be5217fbab6009ce83959e1e12');
Cache::delete(CacheConfig::KEY_ACTION_PRODUCT_NEWSALE_INDEX . '1cf7f9f10e2a2670e73d05c568793ad9');
Cache::delete(CacheConfig::KEY_ACTION_PRODUCT_NEWSALE_INDEX . '57457adececa6c748b29c90cad0ae940');
Cache::delete(CacheConfig::KEY_ACTION_PRODUCT_NEWSALE_INDEX . '04953a61cbf1db426a681e55d496d2fe');
break;
case 'sale':
case 'sale': // SALE
Cache::delete(CacheConfig::KEY_ACTION_PRODUCT_NEWSALE_DISCOUNT . '153180b9a88c0b565848850c523bb637');
Cache::delete(CacheConfig::KEY_ACTION_PRODUCT_NEWSALE_DISCOUNT . '0b2d133419a0f7c381306fd3522365e1');
Cache::delete(CacheConfig::KEY_ACTION_PRODUCT_NEWSALE_DISCOUNT . 'de23648d28ee1e8a3f087a9dbac506f8');
Cache::delete(CacheConfig::KEY_ACTION_PRODUCT_NEWSALE_DISCOUNT . '01269e498ff5b07756e0733ec0e88c75');
break;
case 'nav': // 首页左侧边栏
Cache::delete(CacheConfig::KEY_COMMON_SIDE_NAV);
break;
case 'index': // 频道选择
Cache::delete(CacheConfig::KEY_ACTION_INDEX_INDEX);
Cache::delete(CacheConfig::KEY_ACTION_INDEX_CONFIG);
break;
}
}
... ...