Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
media-resource
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
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
杨昕
media-resource
Commits
65de149d
Commit
65de149d
authored
Jul 01, 2020
by
杨昕
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加vendor压缩文件
parent
eb8a89a9
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
18 deletions
+50
-18
MemberController.php
app/Http/Controllers/Web/MemberController.php
+7
-6
UserModel.php
app/Model/UserModel.php
+34
-12
member_list.blade.php
resources/views/admin/member/member_list.blade.php
+9
-0
vendor.zip
vendor.zip
+0
-0
No files found.
app/Http/Controllers/Web/MemberController.php
View file @
65de149d
...
...
@@ -167,14 +167,14 @@ class MemberController extends Controller
* @throws ControllerException
* @throws \App\Exceptions\FormException
*/
public
function
disable
(
Request
$request
)
public
function
disable
(
Request
$request
,
$id
)
{
if
(
!
$this
->
checkOwnHandle
(
$
request
->
id
))
{
if
(
!
$this
->
checkOwnHandle
(
$id
))
{
throw
new
\App\Exceptions\FormException
(
'你不能操作别人的'
);
}
if
(
$
request
->
id
==
getAdmin
()
->
_id
)
{
if
(
$id
==
getAdmin
()
->
_id
)
{
throw
new
\App\Exceptions\FormException
(
'你不能操作你自己'
);
}
UserModel
::
updateUserStatus
(
$request
);
...
...
@@ -236,10 +236,11 @@ class MemberController extends Controller
{
handler_drive
(
function
()
use
(
$id
)
{
if
(
!
$this
->
checkOwnHandle
(
$id
))
{
throw
new
\App\Exceptions\FormException
(
'你
没有权限删除
别人的'
);
throw
new
\App\Exceptions\FormException
(
'你
不能操作
别人的'
);
}
if
(
$id
==
$this
->
user
[
'id'
])
{
throw
new
\App\Exceptions\FormException
(
'你不能删除你自己'
);
if
(
$id
==
getAdmin
()
->
_id
)
{
throw
new
\App\Exceptions\FormException
(
'你不能操作你自己'
);
}
UserModel
::
deleteUserById
(
$id
);
});
...
...
app/Model/UserModel.php
View file @
65de149d
...
...
@@ -59,22 +59,23 @@ class UserModel extends Eloquent
return
$users
;
}
/**
* 更新用户状态
* @param $request
* @return mixed
* @throws DatabaseException
*/
public
static
function
updateUserStatus
(
$request
){
$id
=
$request
->
id
;
try
{
$user
=
UserModel
::
find
(
$id
);
if
(
empty
(
$user
)){
throw
new
\Exception
(
'用户不存在'
);
}
$isshow
=
$user
->
status
==
1
?
0
:
1
;
$flag
=
UserModel
::
where
(
'_id'
,
$id
)
->
update
([
'status'
=>
$isshow
]);
if
(
!
$flag
){
throw
new
\Exception
(
"更新失败"
);
}
...
...
@@ -82,9 +83,7 @@ class UserModel extends Eloquent
}
catch
(
\Exception
$exception
){
throw
new
DatabaseException
(
$exception
->
getMessage
());
}
return
$flag
;
}
/**
...
...
@@ -94,7 +93,6 @@ class UserModel extends Eloquent
* @throws DatabaseException
*/
public
static
function
getUserInfoById
(
$id
){
try
{
$user
=
DB
::
connection
(
"mongodb"
)
->
collection
(
"users"
)
->
find
(
$id
);
...
...
@@ -104,19 +102,22 @@ class UserModel extends Eloquent
return
$user
;
}
/**
* 更新用户信息
* @param $request
* @return mixed
* @throws DatabaseException
*/
public
static
function
createOrUpdateUser
(
$request
){
$id
=
$request
->
id
;
try
{
$user
=
UserModel
::
find
(
$id
);
if
(
empty
(
$user
)){
throw
new
\Exception
(
'用户不存在'
);
}
$flag
=
UserModel
::
where
(
'_id'
,
$id
)
->
update
(
array_merge
([
'status'
=>
$request
->
status
?
1
:
0
,
],
$request
->
all
()));
...
...
@@ -127,9 +128,30 @@ class UserModel extends Eloquent
}
catch
(
\Exception
$exception
){
throw
new
DatabaseException
(
$exception
->
getMessage
());
}
return
$flag
;
}
/**
* 根据id删除用户
* @param $id
* @return mixed
* @throws \Exception
*/
public
static
function
deleteUserById
(
$id
){
echo
444
;
die
;
try
{
$user
=
UserModel
::
find
(
$id
);
var_dump
(
"sdfsdf"
);
die
;
if
(
empty
(
$user
)){
throw
new
\Exception
(
'用户不存在'
);
}
$flag
=
UserModel
::
where
(
'_id'
,
$id
)
->
delete
();
}
catch
(
\Exception
$exception
){
throw
new
\Exception
(
$exception
->
getMessage
());
}
return
$flag
;
}
...
...
resources/views/admin/member/member_list.blade.php
View file @
65de149d
...
...
@@ -147,6 +147,7 @@
confirm
:
function
()
{
fetch_response
(
'DELETE'
,
"/web/member/"
+
id
).
then
(
function
(
res
)
{
if
(
res
.
code
==
200
)
{
$
(
'body'
).
toast
({
position
:
'fixed'
,
content
:
res
.
msg
,
...
...
@@ -156,6 +157,14 @@
setTimeout
(
function
()
{
window
.
location
.
href
=
'/web/member'
;
},
2000
)
}
else
{
$
(
'body'
).
toast
({
position
:
'fixed'
,
content
:
res
.
msg
,
duration
:
1000
,
top
:
'50%'
});
}
})
},
...
...
vendor.zip
0 → 100644
View file @
65de149d
File added
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