Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
token
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wallet
token
Commits
39b895f7
Commit
39b895f7
authored
Oct 18, 2018
by
ZhuChunYang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增api首页接口
parent
7d297e16
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
167 additions
and
0 deletions
+167
-0
ApplicationController.php
api/controllers/ApplicationController.php
+50
-0
ApplicationBusiness.php
common/business/ApplicationBusiness.php
+93
-0
CoinAppCate.php
common/models/psources/CoinAppCate.php
+9
-0
CoinApplicateRecommend.php
common/models/psources/CoinApplicateRecommend.php
+7
-0
CoinApplication.php
common/models/psources/CoinApplication.php
+2
-0
CoinApplicationCategory.php
common/models/psources/CoinApplicationCategory.php
+6
-0
No files found.
api/controllers/ApplicationController.php
0 → 100644
View file @
39b895f7
<?php
/**
* Created by PhpStorm.
* User: ZCY
* Date: 2018/10/17
* Time: 19:53
*/
namespace
api\controllers
;
use
api\base\BaseController
;
use
common\business\ApplicationBusiness
;
use
common\models\psources\CoinAppCate
;
class
ApplicationController
extends
BaseController
{
/**
* 首页接口
*/
public
function
actionIndex
()
{
$result
[
'code'
]
=
0
;
$recommendData
=
ApplicationBusiness
::
getRecommendList
();
$result
[
'recommend'
]
=
$recommendData
;
$cate_app_data
=
ApplicationBusiness
::
getCategoryAppList
();
$result
[
'cate_app_data'
]
=
$cate_app_data
;
return
$result
;
}
/**
* 分类/应用接口
*/
public
function
actionCateAppInfo
()
{
$result
[
'code'
]
=
0
;
$result
[
'data'
]
=
ApplicationBusiness
::
getCategoryAppList
();
return
$result
;
}
/**
* 获取应用详情
*/
public
function
actionAppInfo
()
{
}
}
\ No newline at end of file
common/business/ApplicationBusiness.php
0 → 100644
View file @
39b895f7
<?php
/**
* Created by PhpStorm.
* User: ZCY
* Date: 2018/10/17
* Time: 19:56
*/
namespace
common\business
;
use
common\models\psources\CoinAppCate
;
use
common\models\psources\CoinApplicateRecommend
;
use
common\models\psources\CoinApplicationCategory
;
use
common\models\psources\CoinImage
;
class
ApplicationBusiness
{
/**
* @return array|\yii\db\ActiveRecord[]
* 获取首页推荐
*/
public
static
function
getRecommendList
()
{
$data
=
CoinApplicateRecommend
::
getRecommendList
();
return
$data
;
}
public
static
function
getCategoryAppList
()
{
$data
=
CoinApplicationCategory
::
getAllList
();
$cate_app_data
=
[];
$icon_Items
=
array_column
(
$data
,
'icon'
);
$banner_Items
=
array_column
(
$data
,
'banner'
);
$image_Items
=
array_merge
(
$icon_Items
,
$banner_Items
);
$icon_Infos
=
CoinImage
::
getItemsByIds
(
$image_Items
);
$cate_app_Infos
=
self
::
getCateAppInfo
();
foreach
(
$data
as
$value
){
$cate_app_item
[
'id'
]
=
$value
[
'id'
];
$cate_app_item
[
'name'
]
=
$value
[
'name'
];
if
(
$value
[
'icon'
]){
$cate_app_item
[
'icon_url'
]
=
$icon_Infos
[
$value
[
'icon'
]][
'base_url'
]
.
$icon_Infos
[
$value
[
'icon'
]][
'file_url'
];
}
else
{
$cate_app_item
[
'icon_url'
]
=
''
;
}
if
(
$value
[
'banner'
]){
$cate_app_item
[
'banner_image_url'
]
=
$icon_Infos
[
$value
[
'banner'
]][
'base_url'
]
.
$icon_Infos
[
$value
[
'banner'
]][
'file_url'
];
}
else
{
$cate_app_item
[
'banner_image_url'
]
=
''
;
}
$cate_app_item
[
'banner_url'
]
=
$value
[
'banner_url'
];
if
(
isset
(
$cate_app_Infos
[
$value
[
'id'
]])){
//分类下面有应用
$cate_app_item
[
'apps'
]
=
$cate_app_Infos
[
$value
[
'id'
]];
}
else
{
$cate_app_item
[
'apps'
]
=
[];
}
$cate_app_data
[]
=
$cate_app_item
;
}
return
$cate_app_data
;
}
/**
* @return mixed
* 获取分类以及应用
*/
public
static
function
getCateAppInfo
()
{
$app_cate_Model
=
CoinAppCate
::
find
();
$data
=
$app_cate_Model
->
JoinWith
([
'application'
],
false
)
->
select
(
'cate_id,app_id,name,icon,sort,redirect_type'
)
->
orderBy
(
'sort asc'
)
->
asArray
()
->
all
();
$icon_Items
=
array_column
(
$data
,
'icon'
);
$icon_Items
=
array_unique
(
$icon_Items
);
$icon_Infos
=
CoinImage
::
getItemsByIds
(
$icon_Items
);
foreach
(
$data
as
&
$value
){
if
(
$value
[
'icon'
]){
$value
[
'icon_url'
]
=
$icon_Infos
[
$value
[
'icon'
]][
'base_url'
]
.
$icon_Infos
[
$value
[
'icon'
]][
'file_url'
];
}
else
{
$value
[
'icon_url'
]
=
''
;
}
}
foreach
(
$data
as
$item
){
$cate_app_item
[
$item
[
'cate_id'
]]
[]
=
$item
;
}
return
$cate_app_item
;
}
}
\ No newline at end of file
common/models/psources/CoinAppCate.php
View file @
39b895f7
...
...
@@ -23,6 +23,13 @@ class CoinAppCate extends BaseActiveRecord
return
'{{%coin_app_cate}}'
;
}
public
function
getApplication
()
{
return
$this
->
hasOne
(
CoinApplication
::
class
,
[
'id'
=>
'app_id'
]);
}
public
static
function
getAppIdByCateId
(
$cate_id
)
{
return
self
::
find
()
->
where
([
'cate_id'
=>
$cate_id
])
->
asArray
()
->
all
();
...
...
@@ -50,4 +57,5 @@ class CoinAppCate extends BaseActiveRecord
}
}
\ No newline at end of file
common/models/psources/CoinApplicateRecommend.php
View file @
39b895f7
...
...
@@ -60,6 +60,12 @@ class CoinApplicateRecommend extends BaseActiveRecord
}
}
public
static
function
getRecommendList
()
{
return
self
::
find
()
->
select
(
'relate_id as app_cate_id,name,type'
)
->
asArray
()
->
orderBy
(
'sort asc'
)
->
all
();
}
}
\ No newline at end of file
common/models/psources/CoinApplication.php
View file @
39b895f7
...
...
@@ -91,4 +91,5 @@ class CoinApplication extends BaseActiveRecord
{
return
self
::
find
()
->
where
([
'id'
=>
$id
])
->
one
();
}
}
\ No newline at end of file
common/models/psources/CoinApplicationCategory.php
View file @
39b895f7
...
...
@@ -97,5 +97,11 @@ class CoinApplicationCategory extends BaseActiveRecord
return
self
::
find
()
->
asArray
()
->
all
();
}
public
static
function
getAllList
()
{
return
self
::
find
()
->
orderBy
(
'sort asc'
)
->
asArray
()
->
all
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment