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
57f76bcd
Commit
57f76bcd
authored
Jun 04, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
api request header
parent
5d981bc1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
109 additions
and
10 deletions
+109
-10
BaseController.php
api/base/BaseController.php
+1
-1
CoinController.php
api/controllers/CoinController.php
+16
-1
CoinController.php
backend/controllers/CoinController.php
+36
-0
add.php
backend/views/coin/add.php
+28
-4
edit.php
backend/views/coin/edit.php
+28
-4
No files found.
api/base/BaseController.php
View file @
57f76bcd
...
...
@@ -30,7 +30,7 @@ class BaseController extends Controller
public
function
fzmCrossHeader
()
{
$this
->
lang
=
\Yii
::
$app
->
request
->
headers
->
get
(
'lang'
)
??
'zh'
;
$this
->
lang
=
\Yii
::
$app
->
request
->
headers
->
get
(
'lang'
)
??
'zh
-CN
'
;
}
public
function
beforeAction
(
$action
)
...
...
api/controllers/CoinController.php
View file @
57f76bcd
...
...
@@ -39,7 +39,12 @@ class CoinController extends BaseController
if
(
$id
)
{
$ret
=
CoinBusiness
::
getCoinAllById
(
$id
);
if
(
$ret
)
{
return
$ret
[
0
];
$data
=
$ret
[
0
];
$nickname
=
json_decode
(
$data
[
'nickname'
],
true
);
$introduce
=
json_decode
(
$data
[
'introduce'
],
true
);
$data
[
'nickname'
]
=
$nickname
[
$this
->
lang
];
$data
[
'introduce'
]
=
$introduce
[
$this
->
lang
];
return
$data
;
}
}
return
[];
...
...
@@ -134,6 +139,10 @@ class CoinController extends BaseController
$coin_ids
=
array_column
(
$coin_recommends
,
'cid'
);
//获取币种信息
$coin_infos
=
Coin
::
getCoinInfoByIds
(
$coin_ids
,
$select
,
'id'
);
foreach
(
$coin_infos
as
$key
=>
&
$val
){
$nickname
=
json_decode
(
$val
[
'nickname'
],
true
);
$val
[
'nickname'
]
=
$nickname
[
$this
->
lang
];
}
//获取行情信息
$coin_names
=
array_column
(
$coin_infos
,
'name'
);
$coin_names
=
array_merge
(
$coin_names
,
array_column
(
$coin_infos
,
'chain'
));
...
...
@@ -231,6 +240,8 @@ class CoinController extends BaseController
$chain_quotation
[
$value
]
=
ExchangeBusiness
::
getquatation
(
$value
);
}
foreach
(
$result
[
'data'
]
as
$key
=>
&
$value
)
{
$nickname
=
json_decode
(
$value
[
'nickname'
],
true
);
$value
[
'nickname'
]
=
$nickname
[
$this
->
lang
];
$value
[
'chain_quotation'
]
=
$chain_quotation
[
$value
[
'chain'
]]
?:
null
;
}
return
$result
;
...
...
@@ -279,6 +290,10 @@ class CoinController extends BaseController
foreach
(
$result
as
$key
=>
$value
)
{
$result
[
$key
][
'chain_quotation'
]
=
$chain_quotation
[
$value
[
'chain'
]]
?:
null
;
}
foreach
(
$result
as
$key
=>
&
$value
)
{
$nickname
=
json_decode
(
$value
[
'nickname'
],
true
);
$value
[
'nickname'
]
=
$nickname
[
$this
->
lang
];
}
return
[
'code'
=>
0
,
'count'
=>
$total
,
'data'
=>
$result
];
}
}
...
...
backend/controllers/CoinController.php
View file @
57f76bcd
...
...
@@ -92,6 +92,24 @@ class CoinController extends BaseController
$data
[
'name'
]
=
strtoupper
(
$data
[
'name'
]);
$data
[
'platform'
]
=
strtolower
(
$data
[
'platform'
]);
$data
[
'chain'
]
=
strtoupper
(
$data
[
'chain'
]);
$lang
=
[
'zh-CN'
,
'en-US'
,
'ja'
];
$nickname_arr
=
$data
[
'nickname'
];
$introduce_arr
=
$data
[
'introduce'
];
$nickname
=
[];
$introduce
=
[];
foreach
(
$nickname_arr
as
$key
=>
$val
){
$nickname
[
$lang
[
$key
]]
=
$val
;
}
foreach
(
$introduce_arr
as
$key
=>
$val
){
$introduce
[
$lang
[
$key
]]
=
$val
;
}
unset
(
$data
[
'nickname'
]);
$data
[
'nickname'
]
=
$nickname
;
$data
[
'introduce'
]
=
$introduce
;
$result
=
$coin
->
addOne
(
$data
);
if
(
$result
===
true
)
{
$this
->
success
(
'添加成功'
,
'/admin/coin/index'
);
...
...
@@ -142,6 +160,24 @@ class CoinController extends BaseController
$can
=
true
;
}
if
(
$can
)
{
$lang
=
[
'zh-CN'
,
'en-US'
,
'ja'
];
$nickname_arr
=
$data
[
'nickname'
];
$introduce_arr
=
$data
[
'introduce'
];
$nickname
=
[];
$introduce
=
[];
foreach
(
$nickname_arr
as
$key
=>
$val
){
$nickname
[
$lang
[
$key
]]
=
$val
;
}
foreach
(
$introduce_arr
as
$key
=>
$val
){
$introduce
[
$lang
[
$key
]]
=
$val
;
}
unset
(
$data
[
'nickname'
]);
$data
[
'nickname'
]
=
$nickname
;
$data
[
'introduce'
]
=
$introduce
;
$coin
=
Yii
::
createObject
(
Coin
::
className
());
$result
=
$coin
->
updateOne
(
$data
);
if
(
$result
===
true
)
{
...
...
backend/views/coin/add.php
View file @
57f76bcd
...
...
@@ -25,8 +25,20 @@
</div>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
中文名
</label>
<div
class=
"layui-input-block"
>
<input
class=
"layui-input"
name=
"nickname"
value=
"
<?=
$model
->
nickname
?>
"
>
<div
class=
"layui-input-block"
style=
"width: 250px"
>
<input
class=
"layui-input"
name=
"nickname[]"
value=
"
<?=
$model
->
nickname
[
'zh-CN'
]
?>
"
>
</div>
</div>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
英文名
</label>
<div
class=
"layui-input-block"
style=
"width: 250px"
>
<input
class=
"layui-input"
name=
"nickname[]"
value=
"
<?=
$model
->
nickname
[
'en-US'
]
?>
"
>
</div>
</div>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
日文名
</label>
<div
class=
"layui-input-block"
style=
"width: 250px"
>
<input
class=
"layui-input"
name=
"nickname[]"
value=
"
<?=
$model
->
nickname
[
'ja'
]
?>
"
>
</div>
</div>
<div
class=
"layui-form-item"
>
...
...
@@ -113,9 +125,21 @@
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
介绍
</label>
<label
class=
"layui-form-label"
>
中文介绍
</label>
<div
class=
"layui-input-block"
>
<textarea
class=
"layui-textarea"
name=
"introduce[]"
>
<?=
$model
->
introduce
[
'zh-CN'
]
?>
</textarea>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
英文介绍
</label>
<div
class=
"layui-input-block"
>
<textarea
class=
"layui-textarea"
name=
"introduce[]"
>
<?=
$model
->
introduce
[
'en-US'
]
?>
</textarea>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
日文介绍
</label>
<div
class=
"layui-input-block"
>
<textarea
class=
"layui-textarea"
name=
"introduce
"
>
<?=
$model
->
introduce
?>
</textarea>
<textarea
class=
"layui-textarea"
name=
"introduce
[]"
>
<?=
$model
->
introduce
[
'ja'
]
?>
</textarea>
</div>
</div>
<div
class=
"layui-inline"
>
...
...
backend/views/coin/edit.php
View file @
57f76bcd
...
...
@@ -25,8 +25,20 @@
</div>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
中文名
</label>
<div
class=
"layui-input-block"
>
<input
class=
"layui-input"
name=
"nickname"
value=
"
<?=
$model
->
nickname
?>
"
>
<div
class=
"layui-input-block"
style=
"width: 250px"
>
<input
class=
"layui-input"
name=
"nickname[]"
value=
"
<?=
$model
->
nickname
[
'zh-CN'
]
?>
"
>
</div>
</div>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
英文名
</label>
<div
class=
"layui-input-block"
style=
"width: 250px"
>
<input
class=
"layui-input"
name=
"nickname[]"
value=
"
<?=
$model
->
nickname
[
'en-US'
]
?>
"
>
</div>
</div>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
日文名
</label>
<div
class=
"layui-input-block"
style=
"width: 250px"
>
<input
class=
"layui-input"
name=
"nickname[]"
value=
"
<?=
$model
->
nickname
[
'ja'
]
?>
"
>
</div>
</div>
<div
class=
"layui-form-item"
>
...
...
@@ -117,9 +129,21 @@
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
介绍
</label>
<label
class=
"layui-form-label"
>
中文介绍
</label>
<div
class=
"layui-input-block"
>
<textarea
class=
"layui-textarea"
name=
"introduce[]"
>
<?=
$model
->
introduce
[
'zh-CN'
]
?>
</textarea>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
英文介绍
</label>
<div
class=
"layui-input-block"
>
<textarea
class=
"layui-textarea"
name=
"introduce[]"
>
<?=
$model
->
introduce
[
'en-US'
]
?>
</textarea>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
日文介绍
</label>
<div
class=
"layui-input-block"
>
<textarea
class=
"layui-textarea"
name=
"introduce
"
>
<?=
$model
->
introduce
?>
</textarea>
<textarea
class=
"layui-textarea"
name=
"introduce
[]"
>
<?=
$model
->
introduce
[
'ja'
]
?>
</textarea>
</div>
</div>
<div
class=
"layui-inline"
>
...
...
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