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
30559b18
Commit
30559b18
authored
Nov 06, 2018
by
ZhuChunYang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
应用搜索功能添加
parent
5be45e39
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
77 additions
and
4 deletions
+77
-4
ApplicationController.php
api/controllers/ApplicationController.php
+53
-3
ApplicationBusiness.php
common/business/ApplicationBusiness.php
+12
-0
CoinAppCate.php
common/models/psources/CoinAppCate.php
+4
-0
CoinApplicateRank.php
common/models/psources/CoinApplicateRank.php
+1
-1
CoinApplication.php
common/models/psources/CoinApplication.php
+7
-0
No files found.
api/controllers/ApplicationController.php
View file @
30559b18
...
@@ -11,6 +11,8 @@ namespace api\controllers;
...
@@ -11,6 +11,8 @@ namespace api\controllers;
use
api\base\BaseController
;
use
api\base\BaseController
;
use
common\business\ApplicationBusiness
;
use
common\business\ApplicationBusiness
;
use
common\models\psources\CoinApplicateRank
;
use
common\models\psources\CoinApplicateRank
;
use
common\models\psources\CoinApplication
;
use
common\models\psources\CoinImage
;
use
Yii
;
use
Yii
;
...
@@ -85,10 +87,57 @@ class ApplicationController extends BaseController
...
@@ -85,10 +87,57 @@ class ApplicationController extends BaseController
{
{
$request
=
Yii
::
$app
->
request
;
$request
=
Yii
::
$app
->
request
;
$type
=
$request
->
post
(
'type'
,
1
);
$type
=
$request
->
post
(
'type'
,
1
);
if
(
$id
){
$result
[
'code'
]
=
0
;
return
CoinApplicateRank
::
appList
(
$type
);
$data
=
CoinApplicateRank
::
getAppList
(
$type
);
$icon_Items
=
array_column
(
$data
,
'icon'
);
$icon_Infos
=
CoinImage
::
getItemsByIds
(
$icon_Items
);
foreach
(
$data
as
$key
=>
&
$value
){
if
(
$value
[
'icon'
]){
$value
[
'icon'
]
=
$icon_Infos
[
$value
[
'icon'
]][
'base_url'
]
.
$icon_Infos
[
$value
[
'icon'
]][
'file_url'
];
}
else
{
}
else
{
return
[
'code'
=>
1
,
'data'
=>
[],
'msg'
=>
'id不能为空'
]
;
$value
[
'icon'
]
=
""
;
}
}
}
}
$result
[
'data'
]
=
$data
;
return
$result
;
}
/**
* 应用搜索
*/
public
function
actionAppSearch
()
{
$request
=
Yii
::
$app
->
request
;
$name
=
$request
->
get
(
'name'
,
''
);
if
(
$name
){
$appItems
=
CoinApplication
::
getAppItemsByName
(
$name
);
if
(
$appItems
){
$appIds
=
array_column
(
$appItems
,
'id'
);
$icon_Items
=
array_column
(
$appItems
,
'icon'
);
$icon_Infos
=
CoinImage
::
getItemsByIds
(
$icon_Items
);
foreach
(
$appItems
as
&
$value
){
if
(
$value
[
'icon'
]){
$value
[
'icon'
]
=
$icon_Infos
[
$value
[
'icon'
]][
'base_url'
]
.
$icon_Infos
[
$value
[
'icon'
]][
'file_url'
];
}
else
{
$value
[
'icon'
]
=
''
;
}
}
$cateItems
=
ApplicationBusiness
::
getCateInfoByAppIds
(
$appIds
);
foreach
(
$cateItems
as
$item
){
$cate_id
=
$item
[
'cate_id'
];
$app_id
=
$item
[
'app_id'
];
$cate_app_items
[
$cate_id
][
'cate_id'
]
=
$cate_id
;
$cate_app_items
[
$cate_id
][
'name'
]
=
$item
[
'name'
];
$cate_app_items
[
$cate_id
][
'app'
][]
=
$appItems
[
$app_id
];
}
foreach
(
$cate_app_items
as
$item
){
$categoryItems
[]
=
$item
;
}
return
[
'code'
=>
0
,
'data'
=>
$categoryItems
];
}
}
return
[
'code'
=>
0
,
'data'
=>
[]];
}
}
}
\ No newline at end of file
common/business/ApplicationBusiness.php
View file @
30559b18
...
@@ -134,5 +134,16 @@ class ApplicationBusiness
...
@@ -134,5 +134,16 @@ class ApplicationBusiness
return
$app_user_num
;
return
$app_user_num
;
}
}
public
static
function
getCateInfoByAppIds
(
$appIds
)
{
$app_cate_Model
=
CoinAppCate
::
find
();
$data
=
$app_cate_Model
->
JoinWith
([
'category'
],
false
)
->
select
(
'cate_id,app_id,name'
)
->
where
([
'in'
,
'app_id'
,
$appIds
])
->
orderBy
(
CoinApplicationCategory
::
tableName
()
.
'.sort asc'
)
->
asArray
()
->
all
();
return
$data
;
}
}
}
\ No newline at end of file
common/models/psources/CoinAppCate.php
View file @
30559b18
...
@@ -28,6 +28,10 @@ class CoinAppCate extends BaseActiveRecord
...
@@ -28,6 +28,10 @@ class CoinAppCate extends BaseActiveRecord
return
$this
->
hasOne
(
CoinApplication
::
class
,
[
'id'
=>
'app_id'
]);
return
$this
->
hasOne
(
CoinApplication
::
class
,
[
'id'
=>
'app_id'
]);
}
}
public
function
getCategory
()
{
return
$this
->
hasOne
(
CoinApplicationCategory
::
class
,
[
'id'
=>
'cate_id'
]);
}
public
static
function
getAppIdByCateId
(
$cate_id
)
public
static
function
getAppIdByCateId
(
$cate_id
)
...
...
common/models/psources/CoinApplicateRank.php
View file @
30559b18
...
@@ -46,7 +46,7 @@ class CoinApplicateRank extends BaseActiveRecord
...
@@ -46,7 +46,7 @@ class CoinApplicateRank extends BaseActiveRecord
{
{
$applicate_rank_model
=
self
::
find
();
$applicate_rank_model
=
self
::
find
();
$data
=
$applicate_rank_model
->
JoinWith
([
'application'
],
false
)
$data
=
$applicate_rank_model
->
JoinWith
([
'application'
],
false
)
->
select
(
'relate_id as id,sort,name,icon'
.
self
::
tableName
()
.
".type"
)
->
select
(
'relate_id as id,sort,name,icon
,advertise,
'
.
self
::
tableName
()
.
".type"
)
->
orderBy
(
self
::
tableName
()
.
'.sort asc'
)
->
where
([
self
::
tableName
()
.
'.type'
=>
$type
])
->
asArray
()
->
all
();
->
orderBy
(
self
::
tableName
()
.
'.sort asc'
)
->
where
([
self
::
tableName
()
.
'.type'
=>
$type
])
->
asArray
()
->
all
();
return
$data
;
return
$data
;
}
}
...
...
common/models/psources/CoinApplication.php
View file @
30559b18
...
@@ -149,5 +149,11 @@ class CoinApplication extends BaseActiveRecord
...
@@ -149,5 +149,11 @@ class CoinApplication extends BaseActiveRecord
return
self
::
find
()
->
select
(
'id,name'
)
->
asArray
()
->
all
();
return
self
::
find
()
->
select
(
'id,name'
)
->
asArray
()
->
all
();
}
}
public
static
function
getAppItemsByName
(
$name
)
{
return
array_column
(
self
::
find
()
->
select
(
'id,name,icon'
)
->
where
([
'like'
,
'name'
,
$name
])
->
asArray
()
->
all
(),
null
,
'id'
);
}
}
}
\ No newline at end of file
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