mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-04-06 03:58:00 +08:00
modified 再删除组的时候,将自动删除组内全部成员
This commit is contained in:
parent
5d10d7ac78
commit
6619202a6d
@ -172,6 +172,9 @@ class Auth extends Base {
|
|||||||
/**
|
/**
|
||||||
* 删除组
|
* 删除组
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @throws \think\exception\DbException
|
||||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||||
*/
|
*/
|
||||||
public function del() {
|
public function del() {
|
||||||
@ -179,6 +182,20 @@ class Auth extends Base {
|
|||||||
if (!$id) {
|
if (!$id) {
|
||||||
return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数');
|
return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$listInfo = (new ApiAuthGroupAccess())->where(['groupId' => ['like', "%{$id}%"]])->select();
|
||||||
|
if ($listInfo) {
|
||||||
|
foreach ($listInfo as $value) {
|
||||||
|
$valueArr = $value->toArray();
|
||||||
|
$oldGroupArr = explode(',', $valueArr['groupId']);
|
||||||
|
$key = array_search($id, $oldGroupArr);
|
||||||
|
unset($oldGroupArr[$key]);
|
||||||
|
$newData = implode(',', $oldGroupArr);
|
||||||
|
$value->groupId = $newData;
|
||||||
|
$value->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ApiAuthGroup::destroy($id);
|
ApiAuthGroup::destroy($id);
|
||||||
ApiAuthRule::destroy(['groupId' => $id]);
|
ApiAuthRule::destroy(['groupId' => $id]);
|
||||||
|
|
||||||
@ -205,7 +222,7 @@ class Auth extends Base {
|
|||||||
$newData = implode(',', $oldGroupArr);
|
$newData = implode(',', $oldGroupArr);
|
||||||
$res = ApiAuthGroupAccess::update([
|
$res = ApiAuthGroupAccess::update([
|
||||||
'groupId' => $newData
|
'groupId' => $newData
|
||||||
],[
|
], [
|
||||||
'uid' => $uid
|
'uid' => $uid
|
||||||
]);
|
]);
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user