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
fb592e4c
Commit
fb592e4c
authored
Aug 08, 2018
by
rlgy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
1689a706
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
2 deletions
+34
-2
AdminController.php
backend/controllers/AdminController.php
+2
-0
CoinController.php
backend/controllers/CoinController.php
+12
-1
Coin.php
common/models/pwallet/Coin.php
+12
-0
Admin.php
common/modelsgii/Admin.php
+8
-1
No files found.
backend/controllers/AdminController.php
View file @
fb592e4c
...
...
@@ -62,6 +62,7 @@ class AdminController extends BaseController
$model
->
generateAuthKey
();
$model
->
setPassword
(
$data
[
'password'
]);
$model
->
group
=
$role
;
/* 保存用户数据到数据库 */
if
(
$model
->
save
())
{
$auth
=
Yii
::
$app
->
authManager
;
...
...
@@ -142,6 +143,7 @@ class AdminController extends BaseController
$model
->
generateAuthKey
();
$model
->
setPassword
(
$data
[
'password'
]);
$model
->
group
=
$role
;
/* 保存用户数据到数据库 */
if
(
$model
->
save
())
{
$auth
=
Yii
::
$app
->
authManager
;
...
...
backend/controllers/CoinController.php
View file @
fb592e4c
...
...
@@ -42,6 +42,9 @@ class CoinController extends BaseController
$recommend
=
$recommend
?
1
:
0
;
$condition
[]
=
[
'recommend'
=>
$recommend
];
}
if
(
Yii
::
$app
->
user
->
identity
->
group
!=
'administrator'
)
{
$condition
[]
=
[
'group'
=>
Yii
::
$app
->
user
->
identity
->
group
];
}
$data
=
CoinBusiness
::
getList
(
$page
,
$limit
,
$condition
);
$data
[
'code'
]
=
0
;
//ajax return
...
...
@@ -63,7 +66,9 @@ class CoinController extends BaseController
* @var $coin \common\models\pwallet\Coin
*/
$coin
=
Yii
::
createObject
(
Coin
::
className
());
$result
=
$coin
->
addOne
(
$request
->
post
());
$data
=
array_merge
(
$request
->
post
(),
[
'group'
=>
Yii
::
$app
->
user
->
identity
->
group
]);
unset
(
$data
[
'id'
]);
$result
=
$coin
->
addOne
(
$data
);
if
(
$result
===
true
)
{
$this
->
success
(
'添加成功'
,
'/admin/coin/index'
);
}
...
...
@@ -91,12 +96,18 @@ class CoinController extends BaseController
$req
=
Yii
::
$app
->
request
;
Yii
::
$app
->
response
->
format
=
'json'
;
if
(
$model
->
load
(
$req
->
post
())
&&
$model
->
validate
())
{
$role
=
Yii
::
$app
->
user
->
identity
->
group
;
if
(
'administrator'
!=
$role
)
{
$coin
=
Coin
::
find
()
->
select
([
'group'
])
->
where
([
'id'
=>
$req
->
post
(
'id'
)])
->
one
();
if
(
$role
==
$coin
->
group
)
{
$coin
=
Yii
::
createObject
(
Coin
::
className
());
$result
=
$coin
->
updateOne
(
$req
->
post
());
if
(
$result
===
true
)
{
return
[
'code'
=>
0
,
'msg'
=>
'succeed'
];
}
}
}
}
$errors
=
$model
->
errors
;
if
(
$errors
)
{
foreach
(
$errors
as
$key
=>
$item
)
{
...
...
common/models/pwallet/Coin.php
View file @
fb592e4c
...
...
@@ -78,6 +78,12 @@ class Coin extends BaseActiveRecord
*/
public
function
addOne
(
$params
)
{
$params
=
array_filter
(
$params
,
function
(
$value
)
{
if
(
null
==
$value
)
{
return
false
;
}
return
true
;
});
$this
->
setAttributes
(
$params
,
false
);
try
{
return
(
bool
)
$this
->
save
();
...
...
@@ -91,6 +97,12 @@ class Coin extends BaseActiveRecord
*/
public
function
updateOne
(
$params
)
{
$params
=
array_filter
(
$params
,
function
(
$value
)
{
if
(
null
==
$value
)
{
return
false
;
}
return
true
;
});
if
(
isset
(
$params
[
'id'
])
&&
!
empty
(
$params
[
'id'
]))
{
$coin
=
self
::
findOne
([
'id'
=>
$params
[
'id'
]]);
if
(
$coin
===
null
)
{
...
...
common/modelsgii/Admin.php
View file @
fb592e4c
...
...
@@ -35,7 +35,13 @@ class Admin extends \common\core\BaseActiveRecord
{
return
[
[[
'username'
,
'password'
,
'salt'
],
'required'
],
[[
'username'
,
'password'
],
'filter'
,
'filter'
=>
function
(
$str
){
return
HtmlPurifier
::
process
(
$str
);
}],
[
[
'username'
,
'password'
],
'filter'
,
'filter'
=>
function
(
$str
)
{
return
HtmlPurifier
::
process
(
$str
);
}
],
[[
'bind_uid'
,
'reg_time'
,
'reg_ip'
,
'last_login_time'
,
'last_login_ip'
,
'update_time'
,
'status'
],
'integer'
],
[[
'username'
],
'string'
,
'max'
=>
32
],
[[
'password'
],
'string'
,
'min'
=>
6
,
'max'
=>
60
],
...
...
@@ -61,6 +67,7 @@ class Admin extends \common\core\BaseActiveRecord
'last_login_ip'
=>
'Last Login Ip'
,
'update_time'
=>
'Update Time'
,
'status'
=>
'Status'
,
'group'
=>
'group'
];
}
}
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