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
6b276b39
Commit
6b276b39
authored
Sep 28, 2018
by
rlgy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
732b782a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
0 deletions
+62
-0
Coin.php
common/models/psources/Coin.php
+18
-0
CoinController.php
h5/controllers/CoinController.php
+44
-0
No files found.
common/models/psources/Coin.php
View file @
6b276b39
...
...
@@ -234,4 +234,22 @@ class Coin extends BaseActiveRecord
}
return
$data
;
}
/**
* 根据name批量返回币种信息
*
* @param array $names
* @return array
*/
public
static
function
getInfoByNames
(
array
$names
)
{
if
(
!
is_array
(
$names
))
{
$names
=
[
$names
];
}
$data
=
self
::
find
()
->
where
([
'in'
,
'name'
,
$names
])
->
asArray
()
->
all
();
if
(
$data
&&
is_array
(
$data
))
{
return
array_column
(
$data
,
null
,
'name'
);
}
return
$data
?
$data
:
[];
}
}
h5/controllers/CoinController.php
0 → 100644
View file @
6b276b39
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-9-28
* Time: 下午2:52
*/
namespace
h5\controllers
;
use
h5\base\ResponseBuild
;
use
Yii
;
use
common\models\psources\Coin
;
use
h5\base\BaseController
;
/**
* Class CoinController
* 币种信息控制器
*
* @package h5\controllers
*/
class
CoinController
extends
BaseController
{
public
function
actionGetIconByNames
()
{
$response_
=
new
ResponseBuild
();
$names
=
Yii
::
$app
->
request
->
POST
(
'names'
);
if
(
empty
(
$names
))
{
$response_
->
build
(
ResponseBuild
::
STATUS_PARAMS_NOT_VALIDATE
);
return
$response_
;
}
if
(
!
is_array
(
$names
))
{
$names
=
[
$names
];
}
$infos
=
Coin
::
getInfoByNames
(
$names
);
$data
=
[];
if
(
$infos
)
{
$data
=
array_column
(
$infos
,
'icon'
,
'name'
);
}
$response_
->
build
(
ResponseBuild
::
STATUS_SUCCEED
,
''
,
$data
);
return
$response_
;
}
}
\ 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