Commit 3d72d072 authored by shajiaiming's avatar shajiaiming

Merge branch 'feature/optimize' into 'master'

Feature/optimize See merge request !254
parents 1b737475 492173a0
...@@ -50,6 +50,9 @@ class NoticeController extends BaseController ...@@ -50,6 +50,9 @@ class NoticeController extends BaseController
if (false != $type) { if (false != $type) {
$query->andWhere(['type' => (int)$type]); $query->andWhere(['type' => (int)$type]);
if (Notice::TOP_TRUE == (int)$type) {
$size = 1;
}
} }
$countQuery = clone $query; $countQuery = clone $query;
......
...@@ -28,9 +28,10 @@ class SupportedChainController extends BaseController ...@@ -28,9 +28,10 @@ class SupportedChainController extends BaseController
} }
$data = []; $data = [];
foreach ($supported_chain_model as $key => &$val) { foreach ($supported_chain_model as $key => &$val) {
$data[] = !empty($val->coin) ? $val->coin : ''; $data[$key]['chain'] = isset($val->coin->chain) ? $val->coin->chain : '';
} $data[$key]['icon'] = isset($val->coin->icon) ? $val->coin->icon : '';
}
$msg = 'success'; $msg = 'success';
$code = 0; $code = 0;
doEnd : doEnd :
......
...@@ -26,6 +26,8 @@ class User extends ActiveRecord implements IdentityInterface ...@@ -26,6 +26,8 @@ class User extends ActiveRecord implements IdentityInterface
const STATUS_DELETED = 0; const STATUS_DELETED = 0;
const STATUS_ACTIVE = 10; const STATUS_ACTIVE = 10;
const AUTH_SUPER = 'administrator';
/** /**
* @inheritdoc * @inheritdoc
......
...@@ -41,11 +41,11 @@ class CoinSupportedChain extends BaseActiveRecord ...@@ -41,11 +41,11 @@ class CoinSupportedChain extends BaseActiveRecord
public function attributes() public function attributes()
{ {
return array_merge(parent::attributes(), ['coins']); return array_merge(parent::attributes(), ['chain', 'icon']);
} }
public function getCoin() public function getCoin()
{ {
return $this->hasOne(Coin::className(), ['id' => 'coin_id'])->select('name as chain'); return $this->hasOne(Coin::className(), ['id' => 'coin_id'])->select('name as chain, icon');
} }
} }
...@@ -19,6 +19,8 @@ class Notice extends BaseActiveRecord ...@@ -19,6 +19,8 @@ class Notice extends BaseActiveRecord
const TYPE_ROLL = 1; //滚动 const TYPE_ROLL = 1; //滚动
const TYPE_POP = 0; //弹窗 const TYPE_POP = 0; //弹窗
const TOP_TRUE = 1; //置顶公告
//定义场景 //定义场景
const SCENARIOS_CREATE = 'create'; const SCENARIOS_CREATE = 'create';
const SCENARIOS_UPDATE = 'update'; const SCENARIOS_UPDATE = 'update';
...@@ -33,15 +35,15 @@ class Notice extends BaseActiveRecord ...@@ -33,15 +35,15 @@ class Notice extends BaseActiveRecord
return [ return [
[['title', 'content', 'type', 'status', 'platform_id', 'author'], 'required'], [['title', 'content', 'type', 'status', 'platform_id', 'author'], 'required'],
[['status', 'type', 'platform_id', 'is_top'], 'integer'], [['status', 'type', 'platform_id', 'is_top'], 'integer'],
['is_top', 'verfiyIsTop'], //['is_top', 'verfiyIsTop'],
['type', 'verfiyType'], //['type', 'verfiyType'],
[['is_top'], 'safe'] //[['is_top'], 'safe']
]; ];
} }
public function verfiyIsTop($attribute, $params) public function verfiyIsTop($attribute, $params)
{ {
$count = self::find()->where(['platform_id' => $this->platform_id, 'is_top' => $this->is_top])->count(); $count = self::find()->where(['platform_id' => $this->platform_id, 'is_top' => Notice::TOP_TRUE])->count();
if ($count >= 1) { if ($count >= 1) {
$this->addError($attribute, '置顶公告只能1条'); $this->addError($attribute, '置顶公告只能1条');
return false; return false;
...@@ -50,22 +52,39 @@ class Notice extends BaseActiveRecord ...@@ -50,22 +52,39 @@ class Notice extends BaseActiveRecord
public function verfiyType($attribute, $params) public function verfiyType($attribute, $params)
{ {
if ('create' == self::getScenario()) { $count = self::find()->where(['platform_id' => $this->platform_id, 'type' => $this->type])->count();
$count = self::find()->where(['platform_id' => $this->platform_id, 'type' => $this->type])->count(); if (Notice::TYPE_ROLL == $this->type) {
if (Notice::TYPE_ROLL == $this->type) { if ('create' == self::getScenario()) {
if ($count >= 3) { if ($count == 3) {
$this->addError($attribute, '滚动公告最多只能3条');
return false;
}
}
if ('update' == self::getScenario()) {
if ($count > 3) {
$this->addError($attribute, '滚动公告最多只能3条'); $this->addError($attribute, '滚动公告最多只能3条');
return false; return false;
} }
} }
if (Notice::TYPE_POP == $this->type) { }
if ($count >= 1) {
$this->addError($attribute, '弹窗公告最多只能3条'); if (Notice::TYPE_POP == $this->type) {
if ('create' == self::getScenario()) {
if ($count == 1) {
$this->addError($attribute, '弹窗公告最多只能1条');
return false;
}
}
if ('update' == self::getScenario()) {
if ($count > 1) {
$this->addError($attribute, '弹窗公告最多只能1条');
return false; return false;
} }
} }
} }
} }
public function scenarios() public function scenarios()
......
...@@ -71,6 +71,48 @@ class TrusteeShipService ...@@ -71,6 +71,48 @@ class TrusteeShipService
return $this->send("GET", $uri, $params); return $this->send("GET", $uri, $params);
} }
public function getFlashListConfig($params = [])
{
$uri = 'backend/flash/flash-list-config';
return $this->send("GET", $uri, $params);
}
public function getFlashDefaultConfig($params = [])
{
$uri = 'backend/flash/flash-default-config';
return $this->send("GET", $uri, $params);
}
public function flashAddConfig($params = [])
{
$uri = 'backend/flash/flash-add-config';
return $this->send("POST", $uri, $params);
}
public function flashUpdateConfig($params = [])
{
$uri = 'backend/flash/flash-update-config';
return $this->send("POST", $uri, $params);
}
public function flashDeleteConfig($params = [])
{
$uri = 'backend/flash/flash-delete-config';
return $this->send("POST", $uri, $params);
}
public function flashCloneConfig($params = [])
{
$uri = 'backend/flash/flash-clone-config';
return $this->send("POST", $uri, $params);
}
public function getUserAsset($params = []) public function getUserAsset($params = [])
{ {
$uri = 'backend/user/asset'; $uri = 'backend/user/asset';
......
This diff is collapsed.
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace wallet\controllers; namespace wallet\controllers;
use common\models\pwallet\Notice; use common\models\pwallet\Notice;
use common\models\User;
use Yii; use Yii;
use yii\data\Pagination; use yii\data\Pagination;
use wallet\base\BaseController; use wallet\base\BaseController;
...@@ -18,13 +19,14 @@ class NoticeController extends BaseController ...@@ -18,13 +19,14 @@ class NoticeController extends BaseController
$page = Yii::$app->request->get('page', 1); $page = Yii::$app->request->get('page', 1);
$size = Yii::$app->request->get('size', 10); $size = Yii::$app->request->get('size', 10);
$group = Yii::$app->request->getGroup(); $group = Yii::$app->request->getGroup();
if ('administrator' == $group) {
$platform_id = Yii::$app->request->get('platform_id', Yii::$app->request->getPlatformId());
} else {
$platform_id = Yii::$app->request->getPlatformId();
}
if (Yii::$app->request->isPost) { if (Yii::$app->request->isPost) {
if (User::AUTH_SUPER == $group) {
$platform_id = Yii::$app->request->post('platform_id', Yii::$app->request->getPlatformId());
} else {
$platform_id = Yii::$app->request->getPlatformId();
}
$model = new Notice(); $model = new Notice();
$model->setScenario(Notice::SCENARIOS_CREATE); $model->setScenario(Notice::SCENARIOS_CREATE);
$params = Yii::$app->request->post(); $params = Yii::$app->request->post();
...@@ -40,9 +42,14 @@ class NoticeController extends BaseController ...@@ -40,9 +42,14 @@ class NoticeController extends BaseController
} }
if (Yii::$app->request->isGet) { if (Yii::$app->request->isGet) {
if (User::AUTH_SUPER == $group) {
$platform_id = Yii::$app->request->get('platform_id', Yii::$app->request->getPlatformId());
} else {
$platform_id = Yii::$app->request->getPlatformId();
}
$status = Yii::$app->request->get('status', 0); $status = Yii::$app->request->get('status', 0);
$type = Yii::$app->request->get('type', 0); $type = Yii::$app->request->get('type', 0);
$query = Notice::find()->select('id, title, type, create_time')->where(['platform_id' => $platform_id])->asArray(); $query = Notice::find()->where(['platform_id' => $platform_id]);
if (false != $status) { if (false != $status) {
$query->andWhere(['status' => (int)$status]); $query->andWhere(['status' => (int)$status]);
...@@ -50,7 +57,7 @@ class NoticeController extends BaseController ...@@ -50,7 +57,7 @@ class NoticeController extends BaseController
if (false != $type) { if (false != $type) {
$query->andWhere(['type' => (int)$type]); $query->andWhere(['type' => (int)$type]);
} }
$model = $query->offset(($page - 1) * $size)->orderBy('create_time')->limit($size)->asArray()->all(); $model = $query->offset(($page - 1) * $size)->orderBy('create_time desc')->limit($size)->asArray()->all();
$countQuery = clone $query; $countQuery = clone $query;
$pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => $size]); $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => $size]);
...@@ -74,11 +81,7 @@ class NoticeController extends BaseController ...@@ -74,11 +81,7 @@ class NoticeController extends BaseController
$code = 0; $code = 0;
$data = null; $data = null;
$group = Yii::$app->request->getGroup(); $group = Yii::$app->request->getGroup();
if ('administrator' == $group) { $platform_id = Yii::$app->request->getPlatformId();
$platform_id = Yii::$app->request->get('platform_id', Yii::$app->request->getPlatformId());
} else {
$platform_id = Yii::$app->request->getPlatformId();
}
if (Yii::$app->request->isGet) { if (Yii::$app->request->isGet) {
$id = Yii::$app->request->get('id'); $id = Yii::$app->request->get('id');
...@@ -100,7 +103,7 @@ class NoticeController extends BaseController ...@@ -100,7 +103,7 @@ class NoticeController extends BaseController
$code = -1; $code = -1;
goto doEnd; goto doEnd;
} }
if ('administrator' != $group && $platform_id != $model->platform_id){ if (User::AUTH_SUPER != $group && $platform_id != $model->platform_id){
$msg = '无权操作'; $msg = '无权操作';
$code = -1; $code = -1;
goto doEnd; goto doEnd;
...@@ -134,7 +137,7 @@ class NoticeController extends BaseController ...@@ -134,7 +137,7 @@ class NoticeController extends BaseController
} }
if (Yii::$app->request->isDelete) { if (Yii::$app->request->isDelete) {
$model = Notice::findOne($id); $model = Notice::findOne($id);
if ('administrator' != $group && $platform_id != $model->platform_id){ if (User::AUTH_SUPER != $group && $platform_id != $model->platform_id){
$msg = '无权删除'; $msg = '无权删除';
$code = -1; $code = -1;
goto doEnd; goto doEnd;
......
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