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
38dcba0f
Commit
38dcba0f
authored
Nov 22, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
banner管理
parent
2a67a230
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
220 additions
and
11 deletions
+220
-11
BannerController.php
api/controllers/BannerController.php
+39
-0
BaseRequest.php
common/base/BaseRequest.php
+12
-0
LoginStatusAuthInterceptor.php
common/behaviors/LoginStatusAuthInterceptor.php
+2
-0
UserAuthInterceptor.php
common/behaviors/UserAuthInterceptor.php
+2
-0
CoinBannerItem.php
common/models/psources/CoinBannerItem.php
+21
-4
BannerController.php
wallet/controllers/BannerController.php
+142
-0
WalletController.php
wallet/controllers/WalletController.php
+2
-7
No files found.
api/controllers/BannerController.php
0 → 100644
View file @
38dcba0f
<?php
namespace
api\controllers
;
use
Yii
;
use
api\base\BaseController
;
use
common\models\psources\ExploreApp
;
use
common\models\psources\CoinBannerItem
;
use
common\models\psources\ExploreAppCategory
;
class
BannerController
extends
BaseController
{
public
function
actionIndex
()
{
$header
=
Yii
::
$app
->
request
->
headers
;
$type
=
Yii
::
$app
->
request
->
get
(
'type'
,
0
);
$platform_id
=
$header
[
'FZM-PLATFORM-ID'
]
??
null
;
$data
=
null
;
if
(
false
==
$platform_id
||
false
==
$type
)
{
$msg
=
'参数错误'
;
$code
=
-
1
;
goto
doEnd
;
}
$model
=
CoinBannerItem
::
find
()
->
where
([
'platform_id'
=>
$platform_id
,
'type'
=>
$type
,
'status'
=>
CoinBannerItem
::
STATUS_ON
])
->
orderBy
(
'sort'
)
->
asArray
()
->
all
();
$data
=
$model
;
$msg
=
'success'
;
$code
=
0
;
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
}
\ No newline at end of file
common/base/BaseRequest.php
View file @
38dcba0f
...
@@ -14,6 +14,7 @@ class BaseRequest extends Request
...
@@ -14,6 +14,7 @@ class BaseRequest extends Request
{
{
private
$user_id
=
0
;
private
$user_id
=
0
;
private
$platform_id
=
0
;
private
$platform_id
=
0
;
private
$group
=
''
;
public
function
getUserId
()
public
function
getUserId
()
{
{
...
@@ -34,4 +35,14 @@ class BaseRequest extends Request
...
@@ -34,4 +35,14 @@ class BaseRequest extends Request
{
{
$this
->
platform_id
=
$value
;
$this
->
platform_id
=
$value
;
}
}
public
function
getGroup
()
{
return
$this
->
group
;
}
public
function
setGroup
(
$value
)
{
$this
->
group
=
$value
;
}
}
}
\ No newline at end of file
common/behaviors/LoginStatusAuthInterceptor.php
View file @
38dcba0f
...
@@ -36,8 +36,10 @@ class LoginStatusAuthInterceptor extends ActionFilter
...
@@ -36,8 +36,10 @@ class LoginStatusAuthInterceptor extends ActionFilter
$code
=
'40002'
;
$code
=
'40002'
;
goto
doEnd
;
goto
doEnd
;
}
}
$group
=
$user
->
group
;
$user_id
=
$user
->
uid
;
$user_id
=
$user
->
uid
;
$platform_id
=
$user
->
platform_id
;
$platform_id
=
$user
->
platform_id
;
Yii
::
$app
->
request
->
setGroup
(
$group
);
Yii
::
$app
->
request
->
setUserId
(
$user_id
);
Yii
::
$app
->
request
->
setUserId
(
$user_id
);
Yii
::
$app
->
request
->
setPlatformId
(
$platform_id
);
Yii
::
$app
->
request
->
setPlatformId
(
$platform_id
);
return
true
;
return
true
;
...
...
common/behaviors/UserAuthInterceptor.php
View file @
38dcba0f
...
@@ -34,8 +34,10 @@ class UserAuthInterceptor extends ActionFilter
...
@@ -34,8 +34,10 @@ class UserAuthInterceptor extends ActionFilter
$msg
=
'user auth error'
;
$msg
=
'user auth error'
;
goto
doEnd
;
goto
doEnd
;
}
}
$group
=
$user
->
group
;
$user_id
=
$user
->
uid
;
$user_id
=
$user
->
uid
;
$platform_id
=
$user
->
platform_id
;
$platform_id
=
$user
->
platform_id
;
Yii
::
$app
->
request
->
setGroup
(
$group
);
Yii
::
$app
->
request
->
setUserId
(
$user_id
);
Yii
::
$app
->
request
->
setUserId
(
$user_id
);
Yii
::
$app
->
request
->
setPlatformId
(
$platform_id
);
Yii
::
$app
->
request
->
setPlatformId
(
$platform_id
);
$user_auth
=
Yii
::
$app
->
params
[
'user_auth'
][
'user_auth'
];
$user_auth
=
Yii
::
$app
->
params
[
'user_auth'
][
'user_auth'
];
...
...
common/models/psources/CoinBannerItem.php
View file @
38dcba0f
...
@@ -13,6 +13,9 @@ use Yii;
...
@@ -13,6 +13,9 @@ use Yii;
class
CoinBannerItem
extends
BaseActiveRecord
class
CoinBannerItem
extends
BaseActiveRecord
{
{
const
STATUS_ON
=
1
;
//激活
const
STATUS_OFF
=
0
;
//未激活
//定义场景
//定义场景
const
SCENARIOS_CREATE
=
'create'
;
const
SCENARIOS_CREATE
=
'create'
;
const
SCENARIOS_UPDATE
=
'update'
;
const
SCENARIOS_UPDATE
=
'update'
;
...
@@ -30,18 +33,32 @@ class CoinBannerItem extends BaseActiveRecord
...
@@ -30,18 +33,32 @@ class CoinBannerItem extends BaseActiveRecord
public
function
rules
()
public
function
rules
()
{
{
return
[
return
[
[[
'image_url'
,
'platform_id'
],
'required'
],
[[
'image_url'
,
'platform_id'
,
'sort'
,
'status'
,
'type'
],
'required'
],
[[
'platform_id'
,
'sort'
,
'type'
,
'status'
,
'type'
],
'integer'
],
[
'banner_url'
,
'default'
,
'value'
=>
'#'
],
[
'banner_url'
,
'default'
,
'value'
=>
'#'
],
[[
'banner_url'
,
'title'
],
'safe'
],
[[
'banner_url'
,
'title'
],
'safe'
],
[[
'image_url'
],
'url'
]
[[
'image_url'
],
'url'
],
];
}
public
function
attributeLabels
()
{
return
[
'banner_url'
=>
'banner跳转链接'
,
'image_url'
=>
'banner图片链接'
,
'title'
=>
'banner标题'
,
'platform_id'
=>
'所属平台'
,
'sort'
=>
'banner排序'
,
'status'
=>
'banner状态'
,
'type'
=>
'banner类型'
];
];
}
}
public
function
scenarios
()
public
function
scenarios
()
{
{
$scenarios
=
[
$scenarios
=
[
self
::
SCENARIOS_CREATE
=>
[
'
image_url'
,
'banner_url'
,
'title'
,
'platform_id
'
],
self
::
SCENARIOS_CREATE
=>
[
'
banner_url'
,
'image_url'
,
'title'
,
'platform_id'
,
'sort'
,
'status'
,
'type
'
],
self
::
SCENARIOS_UPDATE
=>
[
'id'
,
'
image_url'
,
'banner_url'
,
'title'
,
'platform_id
'
],
self
::
SCENARIOS_UPDATE
=>
[
'id'
,
'
banner_url'
,
'image_url'
,
'title'
,
'platform_id'
,
'sort'
,
'status'
,
'type
'
],
];
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
}
...
...
wallet/controllers/BannerController.php
0 → 100644
View file @
38dcba0f
<?php
namespace
wallet\controllers
;
use
Yii
;
use
yii\data\Pagination
;
use
wallet\base\BaseController
;
use
common\models\psources\CoinBannerItem
;
class
BannerController
extends
BaseController
{
public
function
actionType
()
{
$data
=
array_unique
(
Yii
::
$app
->
params
[
'banner_type'
]);
return
[
'code'
=>
0
,
'msg'
=>
'success'
,
'data'
=>
$data
];
}
public
function
actionIndex
()
{
$msg
=
'ok'
;
$code
=
0
;
$data
=
null
;
if
(
Yii
::
$app
->
request
->
isGet
)
{
$type
=
Yii
::
$app
->
request
->
get
(
'type'
,
0
);
$page
=
Yii
::
$app
->
request
->
get
(
'page'
,
1
);
$size
=
Yii
::
$app
->
request
->
get
(
'size'
,
10
);
$platform_id
=
Yii
::
$app
->
request
->
get
(
'platform_id'
,
0
);
if
(
false
==
$platform_id
)
{
$msg
=
'参数错误'
;
$code
=
-
1
;
goto
doEnd
;
}
$query
=
CoinBannerItem
::
find
()
->
where
([
'platform_id'
=>
$platform_id
])
->
orderBy
(
'sort'
);
if
(
false
!=
$type
)
{
$query
->
andWhere
([
'type'
=>
$type
]);
}
$countQuery
=
clone
$query
;
$pages
=
new
Pagination
([
'totalCount'
=>
$countQuery
->
count
(),
'pageSize'
=>
$size
]);
$models
=
$query
->
offset
(
$pages
->
offset
)
->
limit
(
$pages
->
limit
)
->
all
();
$data
=
[
'list'
=>
$models
,
'page'
=>
[
'pageCount'
=>
$pages
->
pageCount
,
'pageSize'
=>
$size
,
'currentPage'
=>
(
int
)
$page
,
]
];
}
if
(
Yii
::
$app
->
request
->
isPost
)
{
$model
=
new
CoinBannerItem
();
$model
->
setScenario
(
CoinBannerItem
::
SCENARIOS_CREATE
);
$model
->
load
(
Yii
::
$app
->
request
->
post
(),
''
);
if
(
!
$model
->
validate
())
{
$msg
=
$model
->
errors
;
$code
=
-
1
;
goto
doEnd
;
}
$model
->
save
();
}
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
public
function
actionUpdate
()
{
$msg
=
'ok'
;
$code
=
0
;
$data
=
null
;
$group
=
Yii
::
$app
->
request
->
getGroup
();
$platform_id
=
Yii
::
$app
->
request
->
getPlatformId
();
if
(
Yii
::
$app
->
request
->
isGet
)
{
$id
=
Yii
::
$app
->
request
->
get
(
'id'
);
if
(
'administrator'
==
$group
)
{
$data
=
CoinBannerItem
::
find
()
->
where
([
'id'
=>
$id
])
->
asArray
()
->
one
();
}
else
{
$data
=
CoinBannerItem
::
find
()
->
where
([
'platform_id'
=>
$platform_id
,
'id'
=>
$id
])
->
asArray
()
->
one
();
}
goto
doEnd
;
}
if
(
Yii
::
$app
->
request
->
isPut
)
{
$params
=
Yii
::
$app
->
request
->
post
();
$id
=
isset
(
$params
[
'id'
])
?
$params
[
'id'
]
:
null
;
if
(
false
==
$id
)
{
$msg
=
'参数错误'
;
$code
=
-
1
;
goto
doEnd
;
}
$model
=
CoinBannerItem
::
findOne
(
$id
);
if
(
'administrator'
!=
$group
&&
$model
->
platform_id
!=
$platform_id
)
{
$msg
=
'无权修改'
;
$code
=
-
1
;
goto
doEnd
;
}
$model
->
setScenario
(
CoinBannerItem
::
SCENARIOS_UPDATE
);
$model
->
load
(
array_merge
(
Yii
::
$app
->
request
->
post
(),
[
'platform_id'
=>
$model
->
platform_id
]),
''
);
if
(
!
$model
->
validate
())
{
$msg
=
$model
->
errors
;
$code
=
-
1
;
goto
doEnd
;
}
$model
->
save
();
}
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
public
function
actionRemove
()
{
$msg
=
'ok'
;
$code
=
0
;
$data
=
null
;
$group
=
Yii
::
$app
->
request
->
getGroup
();
$platform_id
=
Yii
::
$app
->
request
->
getPlatformId
();
$id
=
Yii
::
$app
->
request
->
get
(
'id'
);
if
(
false
==
$id
)
{
$msg
=
'参数错误'
;
$code
=
-
1
;
goto
doEnd
;
}
if
(
Yii
::
$app
->
request
->
isDelete
)
{
$model
=
CoinBannerItem
::
findOne
(
$id
);
if
(
'administrator'
!=
$group
&&
$model
->
platform_id
!=
$platform_id
)
{
$msg
=
'无权删除'
;
$code
=
-
1
;
goto
doEnd
;
}
$model
->
delete
();
}
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
}
\ No newline at end of file
wallet/controllers/WalletController.php
View file @
38dcba0f
...
@@ -10,16 +10,11 @@ use common\models\psources\CoinPlatform;
...
@@ -10,16 +10,11 @@ use common\models\psources\CoinPlatform;
class
WalletController
extends
BaseController
class
WalletController
extends
BaseController
{
{
/**
* landing
* @return array
* @throws \yii\base\Exception
* @throws \yii\base\InvalidConfigException
*/
public
function
actionList
()
public
function
actionList
()
{
{
$group
=
Yii
::
$app
->
request
->
getGroup
();
$platform_id
=
Yii
::
$app
->
request
->
getPlatformId
();
$platform_id
=
Yii
::
$app
->
request
->
getPlatformId
();
if
(
1
===
$platform_id
)
{
if
(
'administrator'
==
$group
)
{
$platforms
=
CoinPlatform
::
find
()
->
select
(
'id, name'
)
->
asArray
()
->
all
();
$platforms
=
CoinPlatform
::
find
()
->
select
(
'id, name'
)
->
asArray
()
->
all
();
}
else
{
}
else
{
$platforms
=
CoinPlatform
::
find
()
->
select
(
'id, name'
)
->
where
([
'id'
=>
$platform_id
])
->
asArray
()
->
all
();
$platforms
=
CoinPlatform
::
find
()
->
select
(
'id, name'
)
->
where
([
'id'
=>
$platform_id
])
->
asArray
()
->
all
();
...
...
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