作者 郭盛
1 个管道 的构建 通过 耗费 4 秒

修改删除用户前端问题

@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 namespace app\admin\controller\user; 3 namespace app\admin\controller\user;
4 4
5 use app\common\controller\Backend; 5 use app\common\controller\Backend;
  6 +use think\Db;
6 7
7 /** 8 /**
8 * 会员管理 9 * 会员管理
@@ -72,4 +73,44 @@ class User extends Backend @@ -72,4 +73,44 @@ class User extends Backend
72 return parent::edit($ids); 73 return parent::edit($ids);
73 } 74 }
74 75
  76 + /**
  77 + * 删除
  78 + */
  79 + public function del($ids = "")
  80 + {
  81 + if ($ids) {
  82 +
  83 + $user_id = explode(',',$ids);
  84 + Db::name('user_token')->whereIn('user_id',$user_id)->delete();
  85 + Db::name('third')->whereIn('user_id',$user_id)->delete();
  86 + $pk = $this->model->getPk();
  87 + $adminIds = $this->getDataLimitAdminIds();
  88 + if (is_array($adminIds)) {
  89 + $this->model->where($this->dataLimitField, 'in', $adminIds);
  90 + }
  91 + $list = $this->model->where($pk, 'in', $ids)->select();
  92 +
  93 + $count = 0;
  94 + Db::startTrans();
  95 + try {
  96 + foreach ($list as $k => $v) {
  97 + $count += $v->delete();
  98 + }
  99 + Db::commit();
  100 + } catch (PDOException $e) {
  101 + Db::rollback();
  102 + $this->error($e->getMessage());
  103 + } catch (Exception $e) {
  104 + Db::rollback();
  105 + $this->error($e->getMessage());
  106 + }
  107 + if ($count) {
  108 + $this->success();
  109 + } else {
  110 + $this->error(__('No rows were deleted'));
  111 + }
  112 + }
  113 + $this->error(__('Parameter %s can not be empty', 'ids'));
  114 + }
  115 +
75 } 116 }