Commit 65de149d by 杨昕

添加vendor压缩文件

parent eb8a89a9
......@@ -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);
});
......
......@@ -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;
}
......
......@@ -147,15 +147,24 @@
confirm: function () {
fetch_response('DELETE',"/web/member/"+id).then(function (res) {
$('body').toast({
position:'fixed',
content:res.msg,
duration:1000,
top:'50%'
});
setTimeout(function () {
window.location.href='/web/member';
},2000)
if (res.code==200) {
$('body').toast({
position:'fixed',
content:res.msg,
duration:1000,
top:'50%'
});
setTimeout(function () {
window.location.href='/web/member';
},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