mirror of
https://github.com/kuaifan/dootask.git
synced 2026-03-17 19:23:26 +00:00
fix: 无法操作离职的问题
This commit is contained in:
parent
d23bff5a48
commit
8f42e2924d
@ -711,7 +711,7 @@ class UsersController extends AbstractController
|
|||||||
$userTransfer->start();
|
$userTransfer->start();
|
||||||
// 离职移出全员群组
|
// 离职移出全员群组
|
||||||
$dialog = WebSocketDialog::whereGroupType('all')->orderByDesc('id')->first();
|
$dialog = WebSocketDialog::whereGroupType('all')->orderByDesc('id')->first();
|
||||||
$dialog?->exitGroup($userInfo->userid, 'remove');
|
$dialog?->exitGroup($userInfo->userid, 'remove', false);
|
||||||
} elseif ($type === 'cleardisable') {
|
} elseif ($type === 'cleardisable') {
|
||||||
// 取消离职重新加入全员群组
|
// 取消离职重新加入全员群组
|
||||||
$dialog = WebSocketDialog::whereGroupType('all')->orderByDesc('id')->first();
|
$dialog = WebSocketDialog::whereGroupType('all')->orderByDesc('id')->first();
|
||||||
|
|||||||
@ -131,7 +131,7 @@ class WebSocketDialog extends AbstractModel
|
|||||||
}
|
}
|
||||||
if ($hasData === true) {
|
if ($hasData === true) {
|
||||||
$msgBuilder = WebSocketDialogMsg::whereDialogId($this->id);
|
$msgBuilder = WebSocketDialogMsg::whereDialogId($this->id);
|
||||||
$this->has_tag = $msgBuilder->clone()->whereMtype('tag')->exists();
|
$this->has_tag = $msgBuilder->clone()->where('tag', '>', 0)->exists();
|
||||||
$this->has_image = $msgBuilder->clone()->whereMtype('image')->exists();
|
$this->has_image = $msgBuilder->clone()->whereMtype('image')->exists();
|
||||||
$this->has_file = $msgBuilder->clone()->whereMtype('file')->exists();
|
$this->has_file = $msgBuilder->clone()->whereMtype('file')->exists();
|
||||||
$this->has_link = $msgBuilder->clone()->whereLink(1)->exists();
|
$this->has_link = $msgBuilder->clone()->whereLink(1)->exists();
|
||||||
@ -172,21 +172,23 @@ class WebSocketDialog extends AbstractModel
|
|||||||
/**
|
/**
|
||||||
* 退出聊天室
|
* 退出聊天室
|
||||||
* @param int|array $userid 退出的会员ID或会员ID组
|
* @param int|array $userid 退出的会员ID或会员ID组
|
||||||
* @param $type
|
* @param string $type exit|remove
|
||||||
|
* @param bool $checkDelete 是否检查删除
|
||||||
*/
|
*/
|
||||||
public function exitGroup($userid, $type = 'exit')
|
public function exitGroup($userid, $type = 'exit', $checkDelete = true)
|
||||||
{
|
{
|
||||||
$typeDesc = $type === 'remove' ? '移出' : '退出';
|
$typeDesc = $type === 'remove' ? '移出' : '退出';
|
||||||
AbstractModel::transaction(function () use ($typeDesc, $type, $userid) {
|
AbstractModel::transaction(function () use ($checkDelete, $typeDesc, $type, $userid) {
|
||||||
$builder = WebSocketDialogUser::whereDialogId($this->id);
|
$builder = WebSocketDialogUser::whereDialogId($this->id);
|
||||||
if (is_array($userid)) {
|
if (is_array($userid)) {
|
||||||
$builder->whereIn('userid', $userid);
|
$builder->whereIn('userid', $userid);
|
||||||
} else {
|
} else {
|
||||||
$builder->whereUserid($userid);
|
$builder->whereUserid($userid);
|
||||||
}
|
}
|
||||||
$builder->chunkById(100, function($list) use ($typeDesc, $type) {
|
$builder->chunkById(100, function($list) use ($checkDelete, $typeDesc, $type) {
|
||||||
/** @var WebSocketDialogUser $item */
|
/** @var WebSocketDialogUser $item */
|
||||||
foreach ($list as $item) {
|
foreach ($list as $item) {
|
||||||
|
if ($checkDelete) {
|
||||||
if ($type === 'remove' && !in_array(User::userid(), [$this->owner_id, $item->inviter])) {
|
if ($type === 'remove' && !in_array(User::userid(), [$this->owner_id, $item->inviter])) {
|
||||||
throw new ApiException('只有群主或邀请人可以移出成员');
|
throw new ApiException('只有群主或邀请人可以移出成员');
|
||||||
}
|
}
|
||||||
@ -196,6 +198,8 @@ class WebSocketDialog extends AbstractModel
|
|||||||
if ($item->important) {
|
if ($item->important) {
|
||||||
throw new ApiException('项目人员或任务人员不可' . $typeDesc);
|
throw new ApiException('项目人员或任务人员不可' . $typeDesc);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
$item->delete();
|
$item->delete();
|
||||||
//
|
//
|
||||||
if ($type === 'remove') {
|
if ($type === 'remove') {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user