Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYPC
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
2
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
hf
10 years ago
Commit
e46ac678e9a875374c3e4a3ca1e6d9582971ea74
1 parent
79846eef
do add models to handle tempate data
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
439 additions
and
143 deletions
docs/data-structure.md
framework
library/Action/AbstractAction.php
library/Api/Yohobuy.php
library/Configs/CacheConfig.php
library/LibModels/Wap/Home/IndexData.php
library/LibModels/Wap/Product/DetailData.php
library/LibModels/Wap/Product/RecomData.php
library/Plugin/Cache.php
library/Plugin/DataProcess/FloorProcess.php
script/nginx/conf/vhosts/yohobuy.test.conf
yohobuy/m.yohobuy.com/application/controllers/Boys.php
yohobuy/m.yohobuy.com/application/controllers/Girls.php
yohobuy/m.yohobuy.com/application/controllers/Index.php
yohobuy/m.yohobuy.com/application/controllers/Kids.php
yohobuy/m.yohobuy.com/application/controllers/Lifestyle.php
yohobuy/m.yohobuy.com/application/models/index/IndexModel.php
yohobuy/m.yohobuy.com/configs/core/cache.testing.config.ini
yohobuy/m.yohobuy.com/configs/core/db.developer.config.ini
yohobuy/m.yohobuy.com/configs/core/db.production.config.ini
yohobuy/m.yohobuy.com/configs/core/db.testing.config.ini
yohobuy/m.yohobuy.com/public/index-dev.php
yohobuy/m.yohobuy.com/public/index-test.php
yohobuy/m.yohobuy.com/public/index.php
docs/data-structure.md
View file @
e46ac67
...
...
@@ -13,22 +13,22 @@
price: 1000,
tags: [
{
is
N
ew: true //NEW
is
_n
ew: true //NEW
},
{
is
Sale
: true //SALE
is
_discount
: true //SALE
},
{
is
Limit
: false //限量商品
is
_limited
: false //限量商品
},
{
is
NewFestival: false //新品节
is
_yohood: // YOHOOD
},
{
is
ReNew
: true //再到着
is
_advance
: true //再到着
}
],
is
Few
: true //即将售罄
is
_soon_sold_out
: true //即将售罄
}
### 侧栏导航
...
...
framework
@
75bbc3b0
Subproject commit
119c247f5cf929aa1e059e40609bb16dd6b58f05
Subproject commit
75bbc3b075de19f239532f60c5995d06c5f814e2
...
...
library/Action/AbstractAction.php
View file @
e46ac67
...
...
@@ -25,12 +25,19 @@ class AbstractAction extends Controller_Abstract
* @var object
*/
protected
$_request
;
/**
* 用户相关信息
*/
protected
$_uid
;
protected
$_uname
;
protected
$_uid
=
0
;
protected
$_uname
=
''
;
/**
* 存放模板数据
*
* @var array
*/
protected
$_data
;
/**
* 初始化
...
...
@@ -38,7 +45,7 @@ class AbstractAction extends Controller_Abstract
public
function
init
()
{
$this
->
_request
=
$this
->
getRequest
();
// 设置环境变量
switch
(
APPLICATION_ENV
)
{
case
'production'
:
// 生产
...
...
@@ -166,7 +173,7 @@ class AbstractAction extends Controller_Abstract
{
return
$this
->
_request
->
getCookie
(
$name
,
$default
);
}
/**
* 设置缓存
*
...
...
@@ -179,7 +186,7 @@ class AbstractAction extends Controller_Abstract
{
Cache
::
set
(
$key
,
$value
,
$expire
);
}
/**
* 获取缓存
*
...
...
@@ -195,7 +202,7 @@ class AbstractAction extends Controller_Abstract
return
Cache
::
get
(
$key
,
'slave'
);
}
}
/**
* 获取当前登录的用户ID
*
...
...
@@ -216,7 +223,7 @@ class AbstractAction extends Controller_Abstract
}
return
$this
->
_uid
;
}
/**
* 获取客户端唯一标识
*
...
...
@@ -231,7 +238,7 @@ class AbstractAction extends Controller_Abstract
}
return
$udid
;
}
/**
* 获取当前登录的用户名字
*
...
...
@@ -258,6 +265,7 @@ class AbstractAction extends Controller_Abstract
* @param string $title 标题
* @return void
*/
protected
function
setTitle
(
$title
)
{
$this
->
_view
->
assign
(
'title'
,
$title
.
' | '
);
...
...
@@ -336,7 +344,7 @@ class AbstractAction extends Controller_Abstract
$this
->
_view
->
assign
(
'pageFooter'
,
$footer
);
}
/**
* 设置侧边栏信息
*
...
...
@@ -368,7 +376,7 @@ class AbstractAction extends Controller_Abstract
'textCn'
=>
'创意生活'
,
'textEn'
=>
'LIFE STYLE'
,
'styleClass'
=>
'life'
,
'url'
=>
'/life'
,
'url'
=>
'/life
style
'
,
),
4
=>
array
(
'textCn'
=>
'逛'
,
...
...
@@ -407,9 +415,8 @@ class AbstractAction extends Controller_Abstract
)
),
));
}
/**
* 返回顶部软件下载有关数据
* @return array 下载有关数据
...
...
@@ -418,7 +425,7 @@ class AbstractAction extends Controller_Abstract
{
return
array
(
'img'
=>
'http://img11.static.yhbimg.com/adpic/2015/02/28/18/01d83bfad41c8fca8fd1ad334216d7d733.jpg?imageView/2/w/640/h/480'
,
'url'
=>
'http://www.baidu.com'
'url'
=>
'http://www.baidu.com'
);
}
...
...
@@ -442,7 +449,7 @@ class AbstractAction extends Controller_Abstract
{
$download
=
array
(
'img'
=>
'http://img11.static.yhbimg.com/adpic/2015/02/28/18/01d83bfad41c8fca8fd1ad334216d7d733.jpg?imageView/2/w/640/h/480'
,
'url'
=>
'http://www.baidu.com'
'url'
=>
'http://www.baidu.com'
);
$this
->
_view
->
assign
(
'headerDownload'
,
$download
);
...
...
library/Api/Yohobuy.php
View file @
e46ac67
...
...
@@ -12,6 +12,8 @@
namespace
Api
;
use
Plugin\Cache
;
class
Yohobuy
{
...
...
@@ -100,11 +102,12 @@ class Yohobuy
*
* @param string $url 接口URL
* @param array $data 参数列表
* @parma mixed $cache 控制是否启用接口数据的缓存(时间单位为秒). 如3600表示缓存1小时, false表示不缓存
* @param bool $returnJson 控制是否返回json格式数据
* @param int $timeout 超时时间
* @return mixed
*/
public
static
function
get
(
$url
,
$data
=
array
(),
$returnJson
=
false
,
$timeout
=
5
)
public
static
function
get
(
$url
,
$data
=
array
(),
$
cache
=
false
,
$
returnJson
=
false
,
$timeout
=
5
)
{
// 销毁私钥参数
if
(
isset
(
$data
[
'private_key'
]))
{
...
...
@@ -114,6 +117,15 @@ class Yohobuy
$url
=
self
::
httpBuildQuery
(
$url
,
$data
);
}
/* 开启缓存的情况 */
if
(
$cache
)
{
// 先尝试获取一级缓存(master), 有数据则直接返回.
$result
=
Cache
::
get
(
$url
,
'master'
);
if
(
!
empty
(
$result
))
{
return
$result
;
}
}
$ch
=
curl_init
(
$url
);
curl_setopt
(
$ch
,
CURLOPT_HEADER
,
0
);
curl_setopt
(
$ch
,
CURLOPT_TIMEOUT
,
$timeout
);
...
...
@@ -125,6 +137,18 @@ class Yohobuy
curl_close
(
$ch
);
$data
=
array
();
/* 开启缓存的情况 */
if
(
$cache
)
{
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if
(
empty
(
$result
))
{
$result
=
Cache
::
get
(
$url
,
'slave'
);
}
// 接口调用成功时,这里会设置一级(master)和二级(slave)的缓存数据.
else
{
Cache
::
set
(
$url
,
$result
,
$cache
);
}
}
return
$result
;
}
...
...
@@ -182,12 +206,22 @@ class Yohobuy
*
* @param array $urlList 接口列表
* @param array $options CURL设置项
* @parma mixed $cache 控制是否启用接口数据的缓存
如3600表示缓存1小时, false表示不缓存
* @parma mixed $cache 控制是否启用接口数据的缓存
(时间单位为秒).
如3600表示缓存1小时, false表示不缓存
* @param int $timeout 超时时间,单位是秒
* @return array
*/
public
static
function
getMulti
(
$urlList
=
array
(),
$options
=
array
(),
$cache
=
false
,
$timeout
=
3
)
{
/* 开启缓存的情况 */
if
(
$cache
)
{
$key
=
md5
(
implode
(
','
,
array_values
(
$urlList
)));
// 先尝试获取一级缓存(master), 有数据则直接返回.
$result
=
Cache
::
get
(
$key
,
'master'
);
if
(
!
empty
(
$result
))
{
return
$result
;
}
}
$result
=
array
();
$response
=
array
();
$running
=
0
;
...
...
@@ -256,6 +290,18 @@ class Yohobuy
}
curl_multi_close
(
$mh
);
/* 开启缓存的情况 */
if
(
$cache
)
{
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if
(
empty
(
$result
))
{
$result
=
Cache
::
get
(
$key
,
'slave'
);
}
// 接口调用成功时,这里会设置一级(master)和二级(slave)的缓存数据.
else
{
Cache
::
set
(
$key
,
$result
,
$cache
);
}
}
return
$result
;
}
...
...
@@ -263,10 +309,25 @@ class Yohobuy
* rpc调用远程服务(YAR)
*
* @see http://php.net/manual/zh/yar-client.setopt.php
* @param string $uri
* @param string $method
* @param array $parameters
* @param mixed $cache 控制是否启用接口数据的缓存(时间单位为秒). 如3600表示缓存1小时, false表示不缓存
* @param int $timeout
* @return array
*/
public
static
function
yarClient
(
$uri
,
$method
,
$parameters
=
array
(),
$timeout
=
3000
)
public
static
function
yarClient
(
$uri
,
$method
,
$parameters
=
array
(),
$
cache
=
false
,
$
timeout
=
3000
)
{
/* 开启缓存的情况 */
if
(
$cache
)
{
$key
=
self
::
httpBuildQuery
(
$uri
.
$method
,
$parameters
);
// 先尝试获取一级缓存(master), 有数据则直接返回.
$result
=
Cache
::
get
(
$key
,
'master'
);
if
(
!
empty
(
$result
))
{
return
$result
;
}
}
$client
=
new
\Yar_Client
(
$uri
);
$client
->
SetOpt
(
YAR_OPT_PACKAGER
,
'php'
);
$client
->
SetOpt
(
YAR_OPT_TIMEOUT
,
$timeout
);
...
...
@@ -278,6 +339,18 @@ class Yohobuy
$result
=
array
();
}
/* 开启缓存的情况 */
if
(
$cache
)
{
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if
(
empty
(
$result
))
{
$result
=
Cache
::
get
(
$key
,
'slave'
);
}
// 接口调用成功时,这里会设置一级(master)和二级(slave)的缓存数据.
else
{
Cache
::
set
(
$key
,
$result
,
$cache
);
}
}
return
$result
;
}
...
...
library/Configs/CacheConfig.php
View file @
e46ac67
...
...
@@ -7,7 +7,12 @@ namespace Configs;
*/
class
CacheConfig
{
const
KEY_ACTION_INDEX_INDEX
=
'key_action_index_index'
;
/* 控制器方法中的数据缓存 */
const
KEY_ACTION_INDEX_INDEX
=
'key_action_index_index'
;
// 频道选择
const
KEY_ACTION_BOYS_INDEX
=
'key_action_boys_index'
;
// 男生首页
const
KEY_ACTION_GIRLS_INDEX
=
'key_action_girls_index'
;
// 女生首页
const
KEY_ACTION_KIDS_INDEX
=
'key_action_kids_index'
;
// 潮童首页
const
KEY_ACTION_LIFESTYLE_INDEX
=
'key_action_lifestyle_index'
;
// 创意生活首页
}
...
...
library/LibModels/Wap/Home/IndexData.php
View file @
e46ac67
...
...
@@ -20,21 +20,17 @@ class IndexData
/**
* 获取启动轮播图
*
* @param string $contentCode 内容位置码
* @return array 轮播图有关数据
*/
public
static
function
getBannerStart
()
public
static
function
getBannerStart
(
$contentCode
)
{
// 构建必传参数
$param
=
Yohobuy
::
param
();
$param
[
'content_code'
]
=
'7ba9118028f9b22090b57341487567eb'
;
$param
[
'content_code'
]
=
$contentCode
;
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
$response
=
Yohobuy
::
get
(
Yohobuy
::
SERVICE_URL
.
'operations/api/v5/resource/get'
,
$param
);
$result
=
''
;
if
(
isset
(
$response
[
'data'
][
0
][
'data'
][
'list'
][
0
][
'src'
]))
{
$result
=
$response
[
'data'
][
0
][
'data'
][
'list'
][
0
][
'src'
];
}
return
$result
;
return
Yohobuy
::
get
(
Yohobuy
::
SERVICE_URL
.
'operations/api/v5/resource/get'
,
$param
);
}
/**
...
...
@@ -53,42 +49,23 @@ class IndexData
}
/**
* 获取用户个人信息
*
* @param integer $uid 用户ID
* @return array 用户个人信息数据
*/
public
static
function
getUserProfile
(
$uid
)
{
// 构建必传参数
$param
=
Yohobuy
::
param
();
$param
[
'method'
]
=
'app.passport.profile'
;
$param
[
'uid'
]
=
$uid
;
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
return
Yohobuy
::
get
(
Yohobuy
::
API_URL
,
$param
);
}
/**
* 获取首页频道数据(除了可能喜欢的各楼层有关数据)
* @param integer $uid 用户ID
* @param string $gender 用户性别, "1,3"表示男, "2,3"表示女, "1,2,3"表示全部
* @param string $contentCode 内容位置码
* @param integer $limit 查询返回的最大限字数,默认为20
* @param integer $page 分页第几页,默认为第1页
* @return array 首页频道数据
*/
public
static
function
get
UserChannelData
(
$uid
,
$gender
,
$contentCode
,
$limit
=
20
,
$page
=
1
)
public
static
function
get
ResourceData
(
$gender
,
$contentCode
,
$limit
=
20
,
$page
=
1
)
{
$param
=
Yohobuy
::
param
();
$param
[
'uid'
]
=
$uid
;
$param
[
'gender'
]
=
$gender
;
$param
[
'content_code'
]
=
$contentCode
;
$param
[
'page'
]
=
$page
;
$param
[
'limit'
]
=
$limit
;
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
return
Yohobuy
::
get
(
Yohobuy
::
SERVICE_URL
.
'operations/api/v5/resource/home'
,
$param
);
return
Yohobuy
::
get
(
Yohobuy
::
SERVICE_URL
.
'operations/api/v5/resource/home'
,
$param
);
}
}
...
...
library/LibModels/Wap/Product/DetailData.php
View file @
e46ac67
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
namespace
LibModels\Wap\Product
;
use
Api\Sign
;
use
Api\Yohobuy
;
/**
* 商品详情相关的数据模型
*
* @name DetailData
* @package LibModels/Wap/Product
* @copyright yoho.inc
* @version 1.0 (2015-10-8 11:51:32)
* @author fei.hong <fei.hong@yoho.cn>
*/
class
DetailData
{
}
...
...
library/LibModels/Wap/Product/RecomData.php
View file @
e46ac67
...
...
@@ -8,7 +8,7 @@ use Api\Yohobuy;
/**
* 商品推荐相关的数据模型
*
* @name Recom
Model
* @name Recom
Data
* @package LibModels/Wap/Product
* @copyright yoho.inc
* @version 1.0 (2015-10-8 11:51:32)
...
...
library/Plugin/Cache.php
View file @
e46ac67
...
...
@@ -35,15 +35,19 @@ class Cache
*/
public
static
function
set
(
$key
,
$value
,
$expire
=
3600
)
{
// WINDOWS
if
(
PATH_SEPARATOR
===
'\\'
)
{
HoodCache
::
Memcache
(
'master'
)
->
set
(
self
::
makeKey
(
$key
,
'master'
),
$value
,
$expire
);
HoodCache
::
Memcache
(
'slave'
)
->
set
(
self
::
makeKey
(
$key
,
'slave'
),
$value
,
0
);
}
// LINUX
else
{
HoodCache
::
Memcached
(
'master'
)
->
set
(
self
::
makeKey
(
$key
,
'master'
),
$value
,
$expire
);
HoodCache
::
Memcached
(
'slave'
)
->
set
(
self
::
makeKey
(
$key
,
'slave'
),
$value
,
0
);
try
{
// WINDOWS
if
(
DIRECTORY_SEPARATOR
===
'\\'
)
{
HoodCache
::
Memcache
(
'master'
)
->
set
(
self
::
makeKey
(
$key
,
'master'
),
$value
,
$expire
);
HoodCache
::
Memcache
(
'slave'
)
->
set
(
self
::
makeKey
(
$key
,
'slave'
),
$value
,
0
);
}
// LINUX
else
{
HoodCache
::
Memcached
(
'master'
)
->
set
(
self
::
makeKey
(
$key
,
'master'
),
$value
,
$expire
);
HoodCache
::
Memcached
(
'slave'
)
->
set
(
self
::
makeKey
(
$key
,
'slave'
),
$value
,
0
);
}
}
catch
(
Exception
$e
)
{
// do nothing
}
}
...
...
@@ -58,13 +62,17 @@ class Cache
{
$result
=
array
();
// WINDOWS
if
(
PATH_SEPARATOR
===
'\\'
)
{
$result
=
HoodCache
::
Memcache
(
$node
)
->
get
(
self
::
makeKey
(
$key
,
$node
));
}
// LINUX
else
{
$result
=
HoodCache
::
Memcached
(
$node
)
->
get
(
self
::
makeKey
(
$key
,
$node
));
try
{
// WINDOWS
if
(
DIRECTORY_SEPARATOR
===
'\\'
)
{
$result
=
HoodCache
::
Memcache
(
$node
)
->
get
(
self
::
makeKey
(
$key
,
$node
));
}
// LINUX
else
{
$result
=
HoodCache
::
Memcached
(
$node
)
->
get
(
self
::
makeKey
(
$key
,
$node
));
}
}
catch
(
Exception
$e
)
{
$result
=
array
();
}
return
$result
;
...
...
@@ -79,7 +87,7 @@ class Cache
public
static
function
delete
(
$key
)
{
// WINDOWS
if
(
PATH
_SEPARATOR
===
'\\'
)
{
if
(
DIRECTORY
_SEPARATOR
===
'\\'
)
{
HoodCache
::
Memcache
(
'master'
)
->
delete
(
self
::
makeKey
(
$key
,
'master'
));
HoodCache
::
Memcache
(
'slave'
)
->
delete
(
self
::
makeKey
(
$key
,
'slave'
));
}
...
...
library/Plugin/DataProcess/FloorProcess.php
View file @
e46ac67
...
...
@@ -19,16 +19,17 @@ class FloorProcess
{
$result
=
array
();
if
(
!
empty
(
$data
[
'list'
]))
{
$build
=
array
();
foreach
(
$data
[
'list'
]
as
$v
)
{
$fun
=
$v
[
'template_name'
];
if
(
!
is_callable
(
"self::
$fun
"
))
{
continue
;
}
$data
=
self
::
$fun
(
$v
[
'data'
],
$type
);
if
(
empty
(
$data
))
{
$build
=
self
::
$fun
(
$v
[
'data'
],
$type
);
if
(
empty
(
$build
))
{
continue
;
}
$result
[]
=
$
data
;
$result
[]
=
$
build
;
}
}
return
$result
;
...
...
@@ -83,6 +84,7 @@ class FloorProcess
if
(
empty
(
$data
))
{
return
array
();
}
foreach
(
$data
as
&
$one
)
{
$one
[
'img'
]
=
Helpers
::
getImageUrl
(
$one
[
'src'
],
750
,
364
,
1
);
unset
(
$one
[
'src'
]);
...
...
@@ -257,7 +259,6 @@ class FloorProcess
*/
private
static
function
single_name_image
(
$data
,
$type
)
{
if
(
empty
(
$data
))
{
return
array
();
}
...
...
script/nginx/conf/vhosts/yohobuy.test.conf
0 → 100644
View file @
e46ac67
server
{
listen
80
;
server_name
wap
.
yohobuy
.
com
;
#access_log /Data/logs/access.wap.yohobuy.com.log combined;
error_log
/
Data
/
logs
/
error
.
wap
.
yohobuy
.
com
.
log
warn
;
root
/
Data
/
code
/
git
/
yohobuy
/
yohobuy
/
m
.
yohobuy
.
com
/
public
;
location
~* \.
html
$ {
root
/
Data
/
PE
/
yohobuy
/
assets
;
if
(!-
f
$
request_filename
){
root
/
Data
/
PE
/
yohobuy
/
yohobuy
/
m
.
yohobuy
.
com
/
public
;
rewrite
^/(.+)$ /
index
.
php
?$
1
&
last
;
}
expires
7
d
;
}
location
/ {
index
index
.
php
;
if
(!-
f
$
request_filename
){
rewrite
^/(.+)$ /
index
.
php
?$
1
&
last
;
}
}
location
~* \.(
ico
|
woff
)$ {
expires
7
d
;
}
location
= /
crossdomain
.
xml
{
expires
7
d
;
}
location
~ .*\.
php
?$ {
fastcgi_pass
127
.
0
.
0
.
1
:
9000
;
fastcgi_index
index
.
php
;
#fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param
SCRIPT_FILENAME
$
document_root
$
fastcgi_script_name
;
include
fastcgi_params
;
}
error_page
403
=
http
://
wap
.
yohobuy
.
com
;
error_page
404
=
http
://
wap
.
yohobuy
.
com
/
error
.
html
;
}
server
{
listen
80
;
server_name
static
.
wap
.
yohobuy
.
com
;
#access_log /Data/logs/access.static.wap.yohobuy.com.log combined;
#error_log /Data/logs/error.static.wap.yohobuy.com.log warn;
root
/
Data
/
PE
/
yohobuy
/
static
;
location
/ {
log_not_found
off
;
access_log
off
;
expires
30
d
;
}
location
~* \.(
svg
|
eot
|
ttf
|
woff
|
otf
)$ {
add_header
Access
-
Control
-
Allow
-
Origin
*;
expires
30
d
;
}
}
\ No newline at end of file
...
...
yohobuy/m.yohobuy.com/application/controllers/Boys.php
View file @
e46ac67
...
...
@@ -3,6 +3,7 @@
use
Action\AbstractAction
;
use
LibModels\Wap\Home\IndexData
;
use
Plugin\DataProcess\FloorProcess
;
use
Configs\CacheConfig
;
/**
* 男生首页
...
...
@@ -10,6 +11,16 @@ use Plugin\DataProcess\FloorProcess;
class
BoysController
extends
AbstractAction
{
// 数据缓存时间
const
DATA_EXPIRE
=
3600
;
// 楼层资源的位置码
const
CODE_FLOOR
=
'8512bf0755cc549ac323f852c9fd945d'
;
// 底部广告的位置码
const
CODE_BOTTOM_BANNER
=
'a2ec977c027d0cd9cdccb356ddf16b08'
;
/**
* 男生首页
*/
public
function
indexAction
()
{
// 设置网站标题
...
...
@@ -19,17 +30,34 @@ class BoysController extends AbstractAction
// 设置顶部信息(搜索)
$this
->
setHomeChannelHeader
();
$data
=
array
(
'boysHomePage'
=>
true
);
$uid
=
$this
->
getUid
();
// 频道数据
$channelData
=
IndexData
::
getUserChannelData
(
$uid
,
'1,3'
,
'201504091403001'
);
if
(
isset
(
$channelData
[
'code'
])
&&
$channelData
[
'code'
]
==
200
)
{
$data
[
'content'
]
=
FloorProcess
::
getContent
(
$channelData
[
'data'
]);
}
$data
=
array
();
$data
[
'boysHomePage'
]
=
true
;
$data
[
'maybeLike'
]
=
true
;
do
{
// 先尝试获取一级缓存(master), 有数据则直接返回.
$data
[
'content'
]
=
$this
->
getCache
(
CacheConfig
::
KEY_ACTION_BOYS_INDEX
,
true
);
if
(
!
empty
(
$data
[
'content'
]))
{
break
;
}
// 调用接口获取楼层数据, 并封装成模板渲染需要的数据格式
$channelData
=
IndexData
::
getResourceData
(
'1,3'
,
self
::
CODE_FLOOR
);
if
(
isset
(
$channelData
[
'code'
])
&&
$channelData
[
'code'
]
==
200
)
{
$data
[
'content'
]
=
FloorProcess
::
getContent
(
$channelData
[
'data'
]);
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
if
(
!
empty
(
$data
[
'content'
]))
{
$this
->
setCache
(
CacheConfig
::
KEY_ACTION_BOYS_INDEX
,
$data
[
'content'
],
self
::
DATA_EXPIRE
);
// 缓存1小时
break
;
}
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
$data
[
'content'
]
=
$this
->
getCache
(
CacheConfig
::
KEY_ACTION_BOYS_INDEX
,
false
);
}
while
(
false
);
$this
->
_view
->
display
(
'index'
,
$data
);
}
...
...
yohobuy/m.yohobuy.com/application/controllers/Girls.php
View file @
e46ac67
...
...
@@ -3,6 +3,7 @@
use
Action\AbstractAction
;
use
LibModels\Wap\Home\IndexData
;
use
Plugin\DataProcess\FloorProcess
;
use
Configs\CacheConfig
;
/**
* 女生首页
...
...
@@ -10,6 +11,16 @@ use Plugin\DataProcess\FloorProcess;
class
GirlsController
extends
AbstractAction
{
// 数据缓存时间
const
DATA_EXPIRE
=
3600
;
// 楼层资源的位置码
const
CODE_FLOOR
=
'189b6686065dbd6755dd6906cf03c002'
;
// 底部广告的位置码
const
CODE_BOTTOM_BANNER
=
'8c8bd1b89a22e5895f05882e0825b493'
;
/**
* 女生首页
*/
public
function
indexAction
()
{
// 设置网站标题
...
...
@@ -19,14 +30,33 @@ class GirlsController extends AbstractAction
// 设置顶部信息(搜索)
$this
->
setHomeChannelHeader
();
$data
=
array
(
'grilsHomePage'
=>
true
);
$uid
=
$this
->
getUid
();
$data
=
array
();
$data
[
'grilsHomePage'
]
=
true
;
$data
[
'maybeLike'
]
=
true
;
do
{
// 先尝试获取一级缓存(master), 有数据则直接返回.
$data
[
'content'
]
=
$this
->
getCache
(
CacheConfig
::
KEY_ACTION_GIRLS_INDEX
,
true
);
if
(
!
empty
(
$data
[
'content'
]))
{
break
;
}
// 调用接口获取楼层数据, 并封装成模板渲染需要的数据格式
$channelData
=
IndexData
::
getResourceData
(
'2,3'
,
self
::
CODE_FLOOR
);
if
(
isset
(
$channelData
[
'code'
])
&&
$channelData
[
'code'
]
==
200
)
{
$data
[
'content'
]
=
FloorProcess
::
getContent
(
$channelData
[
'data'
]);
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
if
(
!
empty
(
$data
[
'content'
]))
{
$this
->
setCache
(
CacheConfig
::
KEY_ACTION_GIRLS_INDEX
,
$data
[
'content'
],
self
::
DATA_EXPIRE
);
// 缓存1小时
break
;
}
// 频道数据
$channelData
=
IndexData
::
getUserChannelData
(
$uid
,
'2,3'
,
'201504091403002'
);
if
(
isset
(
$channelData
[
'code'
])
&&
$channelData
[
'code'
]
==
200
)
{
$data
[
'content'
]
=
FloorProcess
::
getContent
(
$channelData
[
'data'
],
2
);
}
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
$data
[
'content'
]
=
$this
->
getCache
(
CacheConfig
::
KEY_ACTION_GIRLS_INDEX
,
false
);
}
while
(
false
);
$this
->
_view
->
display
(
'index'
,
$data
);
}
...
...
yohobuy/m.yohobuy.com/application/controllers/Index.php
View file @
e46ac67
...
...
@@ -9,23 +9,23 @@ use Plugin\Helpers;
*/
class
IndexController
extends
AbstractAction
{
const
CODE_BANNER
=
'7ba9118028f9b22090b57341487567eb'
;
/**
* 启动首页频道选择
*/
public
function
indexAction
()
{
$data
=
array
(
'background'
=>
''
,
);
// 背景图获取
$banner
=
IndexData
::
getBannerStart
();
if
(
$banner
)
{
$data
[
'background'
]
=
Helpers
::
getImageUrl
(
$banner
,
640
,
800
,
1
);
$banner
=
IndexData
::
getBannerStart
(
self
::
CODE_BANNER
);
if
(
isset
(
$banner
[
'data'
][
0
][
'data'
][
'list'
][
0
][
'src'
]))
{
$data
[
'background'
]
=
Helpers
::
getImageUrl
(
$banner
[
'data'
][
0
][
'data'
][
'list'
][
0
][
'src'
],
640
,
800
,
1
);
}
// 设置底部导航信息
$this
->
setNavFooter
();
// 生成HTML (index.html)
$this
->
_view
->
html
(
'index'
);
$banner
=
array
();
// 渲染模板
$this
->
_view
->
display
(
'index'
,
$data
);
...
...
yohobuy/m.yohobuy.com/application/controllers/Kids.php
View file @
e46ac67
...
...
@@ -3,13 +3,21 @@
use
Action\AbstractAction
;
use
LibModels\Wap\Home\IndexData
;
use
Plugin\DataProcess\FloorProcess
;
use
Configs\CacheConfig
;
/**
* 儿童首页
*/
class
KidsController
extends
AbstractAction
{
// 数据缓存时间
const
DATA_EXPIRE
=
3600
;
// 楼层资源的位置码
const
CODE_FLOOR
=
'b8c1bff53d4ea60f978926d538620636'
;
// '66cad79d93e055ad6fc5c8744086066d';
/**
* 潮童首页
*/
public
function
indexAction
()
{
// 设置网站标题
...
...
@@ -19,17 +27,34 @@ class KidsController extends AbstractAction
// 设置顶部信息(搜索)
$this
->
setHomeChannelHeader
();
$data
=
array
(
'kidsHomePage'
=>
true
);
$uid
=
$this
->
getUid
();
$data
=
array
();
$data
[
'kidsHomePage'
]
=
true
;
$data
[
'maybeLike'
]
=
true
;
// 频道数据
$channelData
=
IndexData
::
getUserChannelData
(
$uid
,
''
,
'e9875682c1599a886bfbdb965b740022'
);
if
(
isset
(
$channelData
[
'code'
])
&&
$channelData
[
'code'
]
==
200
)
{
$data
[
'content'
]
=
FloorProcess
::
getContent
(
$channelData
[
'data'
],
3
);
}
do
{
// 先尝试获取一级缓存(master), 有数据则直接返回.
$data
[
'content'
]
=
$this
->
getCache
(
CacheConfig
::
KEY_ACTION_KIDS_INDEX
,
true
);
if
(
!
empty
(
$data
[
'content'
]))
{
break
;
}
// 调用接口获取楼层数据, 并封装成模板渲染需要的数据格式
$channelData
=
IndexData
::
getResourceData
(
''
,
self
::
CODE_FLOOR
);
if
(
isset
(
$channelData
[
'code'
])
&&
$channelData
[
'code'
]
==
200
)
{
$data
[
'content'
]
=
FloorProcess
::
getContent
(
$channelData
[
'data'
],
3
);
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
if
(
!
empty
(
$data
[
'content'
]))
{
$this
->
setCache
(
CacheConfig
::
KEY_ACTION_KIDS_INDEX
,
$data
[
'content'
],
self
::
DATA_EXPIRE
);
// 缓存1小时
break
;
}
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
$data
[
'content'
]
=
$this
->
getCache
(
CacheConfig
::
KEY_ACTION_KIDS_INDEX
,
false
);
}
while
(
false
);
$data
[
'maybeLike'
]
=
true
;
$this
->
_view
->
display
(
'index'
,
$data
);
}
...
...
yohobuy/m.yohobuy.com/application/controllers/Lifestyle.php
View file @
e46ac67
...
...
@@ -3,6 +3,7 @@
use
Action\AbstractAction
;
use
LibModels\Wap\Home\IndexData
;
use
Plugin\DataProcess\FloorProcess
;
use
Configs\CacheConfig
;
/**
* 创意生活首页
...
...
@@ -10,6 +11,14 @@ use Plugin\DataProcess\FloorProcess;
class
LifestyleController
extends
AbstractAction
{
// 数据缓存时间
const
DATA_EXPIRE
=
3600
;
// 楼层资源的位置码
const
CODE_FLOOR
=
'61cd852c6afcf60660196154f66a3a62'
;
/**
* 创意生活首页
*/
public
function
indexAction
()
{
// 设置网站标题
...
...
@@ -19,17 +28,34 @@ class LifestyleController extends AbstractAction
// 设置顶部信息(搜索)
$this
->
setHomeChannelHeader
();
$data
=
array
(
'lifestyleHomePage'
=>
true
);
$uid
=
$this
->
getUid
();
// 频道数据
$channelData
=
IndexData
::
getUserChannelData
(
$uid
,
''
,
'9aa25f5133f011ec96c2045eb15ae425'
);
if
(
isset
(
$channelData
[
'code'
])
&&
$channelData
[
'code'
]
==
200
)
{
$data
[
'content'
]
=
FloorProcess
::
getContent
(
$channelData
[
'data'
],
4
);
}
$data
=
array
();
$data
[
'lifestyleHomePage'
]
=
true
;
$data
[
'maybeLike'
]
=
true
;
do
{
// 先尝试获取一级缓存(master), 有数据则直接返回.
$data
[
'content'
]
=
$this
->
getCache
(
CacheConfig
::
KEY_ACTION_LIFESTYLE_INDEX
,
true
);
if
(
!
empty
(
$data
[
'content'
]))
{
break
;
}
// 调用接口获取楼层数据, 并封装成模板渲染需要的数据格式
$channelData
=
IndexData
::
getResourceData
(
''
,
'61cd852c6afcf60660196154f66a3a62'
);
if
(
isset
(
$channelData
[
'code'
])
&&
$channelData
[
'code'
]
==
200
)
{
$data
[
'content'
]
=
FloorProcess
::
getContent
(
$channelData
[
'data'
],
4
);
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
if
(
!
empty
(
$data
[
'content'
]))
{
$this
->
setCache
(
CacheConfig
::
KEY_ACTION_LIFESTYLE_INDEX
,
$data
[
'content'
],
self
::
DATA_EXPIRE
);
// 缓存1小时
break
;
}
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
$data
[
'content'
]
=
$this
->
getCache
(
CacheConfig
::
KEY_ACTION_LIFESTYLE_INDEX
,
false
);
}
while
(
false
);
$this
->
_view
->
display
(
'index'
,
$data
);
}
...
...
yohobuy/m.yohobuy.com/application/models/index/IndexModel.php
0 → 100644
View file @
e46ac67
<?php
use
LibModels\Wap\Home\IndexData
;
use
Plugin\Helpers
;
/**
* 首页相关的模板数据模型
*
* @author fei.hong
*/
class
IndexModel
{
/* 频道选择页取背景图片的位置码 */
const
CODE_BG
=
'7ba9118028f9b22090b57341487567eb'
;
/**
* 获取频道选择页的背景图片
*
* @return string | false
*/
public
static
function
getBgImage
()
{
$banner
=
IndexData
::
getBannerStart
(
self
::
CODE_BG
);
if
(
isset
(
$banner
[
'data'
][
0
][
'data'
][
'list'
][
0
][
'src'
]))
{
$result
=
Helpers
::
getImageUrl
(
$banner
[
'data'
][
0
][
'data'
][
'list'
][
0
][
'src'
],
640
,
800
,
1
);
}
else
{
$result
=
false
;
}
return
$result
;
}
}
...
...
yohobuy/m.yohobuy.com/configs/core/cache.testing.config.ini
View file @
e46ac67
[common]
servers.host
=
127.0.0.1:11211:90
[memcached:common]
servers.hosts
=
127.0.0.1:11213
[memcached]
master.hosts
=
127.0.0.1:11212,127.0.0.1:11213
slave.hosts
=
127.0.0.1:11212,127.0.0.1:11213
[redis]
servers.hosts
=
127.0.0.1:6379
\ No newline at end of file
...
...
yohobuy/m.yohobuy.com/configs/core/db.developer.config.ini
View file @
e46ac67
...
...
@@ -5,7 +5,7 @@ collation = utf8_unicode_ci
timeout
=
3
[database]
yhb_bill.username
=
yohodb
yhb_bill.passwd
=
yohonj_9646_mysql
yhb_bill.write
=
123.56.86.219:5511
yhb_bill.read
=
123.56.86.219:5511
\ No newline at end of file
yhb_test.username
=
test
yhb_test.passwd
=
123456
yhb_test.write
=
127.0.0.1:5511
yhb_test.read
=
127.0.0.1:5511
\ No newline at end of file
...
...
yohobuy/m.yohobuy.com/configs/core/db.production.config.ini
View file @
e46ac67
...
...
@@ -5,7 +5,7 @@ collation = utf8_unicode_ci
timeout
=
3
[database]
yhb_bill.username
=
yohodb
yhb_bill.passwd
=
yohonj_9646_mysql
yhb_bill.write
=
123.56.86.219:5511
yhb_bill.read
=
123.56.86.219:5511
\ No newline at end of file
yhb_test.username
=
test
yhb_test.passwd
=
123456
yhb_test.write
=
127.0.0.1:5511
yhb_test.read
=
127.0.0.1:5511
\ No newline at end of file
...
...
yohobuy/m.yohobuy.com/configs/core/db.testing.config.ini
View file @
e46ac67
...
...
@@ -5,7 +5,7 @@ collation = utf8_unicode_ci
timeout
=
3
[database]
yhb_bill.username
=
yohodb
yhb_bill.passwd
=
yohonj_9646_mysql
yhb_bill.write
=
10.170.183.158:5511
yhb_bill.read
=
10.170.183.158:5511
\ No newline at end of file
yhb_test.username
=
test
yhb_test.passwd
=
123456
yhb_test.write
=
127.0.0.1:5511
yhb_test.read
=
127.0.0.1:5511
\ No newline at end of file
...
...
yohobuy/m.yohobuy.com/public/index-dev.php
View file @
e46ac67
<?php
use
Yaf\Application
;
define
(
'DOMAIN'
,
'm.dev.yohobuy.com'
);
define
(
'APPLICATION_PATH'
,
dirname
(
__DIR__
));
define
(
'ROOT_PATH'
,
dirname
(
dirname
(
APPLICATION_PATH
)));
defined
(
'APPLICATION_ENV'
)
||
define
(
'APPLICATION_ENV'
,
'developer'
);
...
...
yohobuy/m.yohobuy.com/public/index-test.php
View file @
e46ac67
<?php
use
Yaf\Application
;
define
(
'DOMAIN'
,
'buy.test.yoho.cn'
);
define
(
'APPLICATION_PATH'
,
dirname
(
__DIR__
));
define
(
'ROOT_PATH'
,
dirname
(
dirname
(
APPLICATION_PATH
)));
defined
(
'APPLICATION_ENV'
)
||
define
(
'APPLICATION_ENV'
,
'testing'
);
...
...
yohobuy/m.yohobuy.com/public/index.php
View file @
e46ac67
<?php
use
Yaf\Application
;
define
(
'DOMAIN'
,
'wap.yohobuy.com'
);
define
(
'APPLICATION_PATH'
,
dirname
(
__DIR__
));
define
(
'ROOT_PATH'
,
dirname
(
dirname
(
APPLICATION_PATH
)));
defined
(
'APPLICATION_ENV'
)
||
define
(
'APPLICATION_ENV'
,
'production'
);
...
...
Please
register
or
login
to post a comment