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

修改删除用户前端问题

... ... @@ -3,6 +3,7 @@
namespace app\admin\controller\user;
use app\common\controller\Backend;
use think\Db;
/**
* 会员管理
... ... @@ -72,4 +73,44 @@ class User extends Backend
return parent::edit($ids);
}
/**
* 删除
*/
public function del($ids = "")
{
if ($ids) {
$user_id = explode(',',$ids);
Db::name('user_token')->whereIn('user_id',$user_id)->delete();
Db::name('third')->whereIn('user_id',$user_id)->delete();
$pk = $this->model->getPk();
$adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds)) {
$this->model->where($this->dataLimitField, 'in', $adminIds);
}
$list = $this->model->where($pk, 'in', $ids)->select();
$count = 0;
Db::startTrans();
try {
foreach ($list as $k => $v) {
$count += $v->delete();
}
Db::commit();
} catch (PDOException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if ($count) {
$this->success();
} else {
$this->error(__('No rows were deleted'));
}
}
$this->error(__('Parameter %s can not be empty', 'ids'));
}
}
... ...