Commit 65de149d by 杨昕

添加vendor压缩文件

parent eb8a89a9
...@@ -167,14 +167,14 @@ class MemberController extends Controller ...@@ -167,14 +167,14 @@ class MemberController extends Controller
* @throws ControllerException * @throws ControllerException
* @throws \App\Exceptions\FormException * @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('你不能操作别人的'); throw new \App\Exceptions\FormException('你不能操作别人的');
} }
if ($request->id == getAdmin()->_id) { if ($id == getAdmin()->_id) {
throw new \App\Exceptions\FormException('你不能操作你自己'); throw new \App\Exceptions\FormException('你不能操作你自己');
} }
UserModel::updateUserStatus($request); UserModel::updateUserStatus($request);
...@@ -236,10 +236,11 @@ class MemberController extends Controller ...@@ -236,10 +236,11 @@ class MemberController extends Controller
{ {
handler_drive(function () use ($id) { handler_drive(function () use ($id) {
if (!$this->checkOwnHandle($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); UserModel::deleteUserById($id);
}); });
......
...@@ -59,22 +59,23 @@ class UserModel extends Eloquent ...@@ -59,22 +59,23 @@ class UserModel extends Eloquent
return $users; return $users;
} }
/**
* 更新用户状态
* @param $request
* @return mixed
* @throws DatabaseException
*/
public static function updateUserStatus($request){ public static function updateUserStatus($request){
$id = $request->id; $id = $request->id;
try{ try{
$user = UserModel::find($id); $user = UserModel::find($id);
if (empty($user)){ if (empty($user)){
throw new \Exception('用户不存在'); throw new \Exception('用户不存在');
} }
$isshow=$user->status==1?0:1; $isshow=$user->status==1?0:1;
$flag = UserModel::where('_id',$id)->update(['status'=>$isshow]); $flag = UserModel::where('_id',$id)->update(['status'=>$isshow]);
if (!$flag){ if (!$flag){
throw new \Exception("更新失败"); throw new \Exception("更新失败");
} }
...@@ -82,9 +83,7 @@ class UserModel extends Eloquent ...@@ -82,9 +83,7 @@ class UserModel extends Eloquent
}catch (\Exception $exception){ }catch (\Exception $exception){
throw new DatabaseException($exception->getMessage()); throw new DatabaseException($exception->getMessage());
} }
return $flag; return $flag;
} }
/** /**
...@@ -94,7 +93,6 @@ class UserModel extends Eloquent ...@@ -94,7 +93,6 @@ class UserModel extends Eloquent
* @throws DatabaseException * @throws DatabaseException
*/ */
public static function getUserInfoById($id){ public static function getUserInfoById($id){
try{ try{
$user = DB::connection("mongodb")->collection("users")->find($id); $user = DB::connection("mongodb")->collection("users")->find($id);
...@@ -104,19 +102,22 @@ class UserModel extends Eloquent ...@@ -104,19 +102,22 @@ class UserModel extends Eloquent
return $user; return $user;
} }
/**
* 更新用户信息
* @param $request
* @return mixed
* @throws DatabaseException
*/
public static function createOrUpdateUser($request){ public static function createOrUpdateUser($request){
$id = $request->id; $id = $request->id;
try{ try{
$user = UserModel::find($id); $user = UserModel::find($id);
if (empty($user)){ if (empty($user)){
throw new \Exception('用户不存在'); throw new \Exception('用户不存在');
} }
$flag = UserModel::where('_id',$id)->update(array_merge([ $flag = UserModel::where('_id',$id)->update(array_merge([
'status' => $request->status? 1 :0, 'status' => $request->status? 1 :0,
],$request->all())); ],$request->all()));
...@@ -127,9 +128,30 @@ class UserModel extends Eloquent ...@@ -127,9 +128,30 @@ class UserModel extends Eloquent
}catch (\Exception $exception){ }catch (\Exception $exception){
throw new DatabaseException($exception->getMessage()); throw new DatabaseException($exception->getMessage());
} }
return $flag; 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;
} }
......
...@@ -147,6 +147,7 @@ ...@@ -147,6 +147,7 @@
confirm: function () { confirm: function () {
fetch_response('DELETE',"/web/member/"+id).then(function (res) { fetch_response('DELETE',"/web/member/"+id).then(function (res) {
if (res.code==200) {
$('body').toast({ $('body').toast({
position:'fixed', position:'fixed',
content:res.msg, content:res.msg,
...@@ -156,6 +157,14 @@ ...@@ -156,6 +157,14 @@
setTimeout(function () { setTimeout(function () {
window.location.href='/web/member'; window.location.href='/web/member';
},2000) },2000)
}else{
$('body').toast({
position:'fixed',
content:res.msg,
duration:1000,
top:'50%'
});
}
}) })
}, },
......
File added
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