修复管理后台无法批量删除用户的问题

pull/516/head
yin 2025-11-27 10:50:23 +08:00
parent 2a5f3e97db
commit fdfca674cc
1 changed files with 21 additions and 5 deletions

View File

@ -4,6 +4,7 @@ namespace app\admin\controller\user;
use app\common\controller\Backend;
use app\common\library\Auth;
use think\Db;
/**
* 会员管理
@ -93,13 +94,28 @@ class User extends Backend
if (!$this->request->isPost()) {
$this->error(__("Invalid parameters"));
}
$ids = $ids ? $ids : $this->request->post("ids");
$row = $this->model->get($ids);
$ids = $ids ?: $this->request->post("ids");
$this->modelValidate = true;
if (!$row) {
$this->error(__('No Results were found'));
if (is_numeric($ids)) {
$res = Auth::instance()->delete($ids);
if (!$res) {
$this->error(__('No Results were found'));
}
} else {
$ids = explode(',', $ids);
if (!is_array($ids) || count($ids) == 0) {
$this->error(__('Invalid parameters'));
}
Db::startTrans();
foreach ($ids as $id) {
$res = Auth::instance()->delete($id);
if (!$res) {
Db::rollback();
$this->error($this->auth->getError());
}
}
Db::commit();
}
Auth::instance()->delete($row['id']);
$this->success();
}