Commit b5b6252a authored by shajiaiming's avatar shajiaiming

Merge branch 'feature/ticker' into 'master'

钱包支持链信息 See merge request !250
parents f4eddeba 616d9c29
<?php
namespace api\controllers;
use Yii;
use api\base\BaseController;
use common\models\psources\CoinSupportedChain;
class SupportedChainController extends BaseController
{
public function actionIndex()
{
$header = Yii::$app->request->headers;
$platform_id = $header['FZM-PLATFORM-ID'] ?? null;
$data = null;
if (false == $platform_id) {
$msg = '参数错误';
$code = -1;
goto doEnd;
}
$supported_chain_model = CoinSupportedChain::find()->where(['platform_id' => $platform_id])->all();
if (false == $supported_chain_model) {
$msg = 'success';
$code = 0;
goto doEnd;
}
$data = [];
foreach ($supported_chain_model as $key => &$val) {
$data[] = !empty($val->coin) ? $val->coin : '';
}
$msg = 'success';
$code = 0;
doEnd :
return ['code' => $code, 'msg' => $msg, 'data' => $data];
}
}
\ No newline at end of file
<?php
namespace common\models\psources;
use Yii;
use common\core\BaseActiveRecord;
class CoinSupportedChain extends BaseActiveRecord
{
//定义场景
const SCENARIOS_CREATE = 'create';
const SCENARIOS_UPDATE = 'update';
public static function getDb()
{
return Yii::$app->get('p_sources');
}
public static function tableName()
{
return '{{%coin_supported_chain}}';
}
public function rules()
{
return [
[['coin_id', 'platform_id'], 'required'],
[['coin_id', 'platform_id'], 'integer'],
];
}
public function scenarios()
{
$scenarios = [
self:: SCENARIOS_CREATE => ['coin_id', 'platform_id'],
self:: SCENARIOS_UPDATE => ['id', 'coin_id', 'platform_id']
];
return array_merge(parent:: scenarios(), $scenarios);
}
public function attributes()
{
return array_merge(parent::attributes(), ['coins']);
}
public function getCoin()
{
return $this->hasOne(Coin::className(), ['id' => 'coin_id'])->select('name as chain');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment