mirror of
https://github.com/kuaifan/dootask.git
synced 2026-03-17 19:23:26 +00:00
feat: 新增全员群组
This commit is contained in:
parent
e5cbeb032e
commit
fb74ef4843
@ -28,7 +28,7 @@ class SystemController extends AbstractController
|
|||||||
* @apiParam {String} type
|
* @apiParam {String} type
|
||||||
* - get: 获取(默认)
|
* - get: 获取(默认)
|
||||||
* - all: 获取所有(需要管理员权限)
|
* - all: 获取所有(需要管理员权限)
|
||||||
* - save: 保存设置(参数:['reg', 'reg_invite', 'login_code', 'password_policy', 'project_invite', 'chat_nickname', 'auto_archived', 'archived_day', 'start_home', 'home_footer'])
|
* - save: 保存设置(参数:['reg', 'reg_invite', 'login_code', 'password_policy', 'project_invite', 'chat_nickname', 'auto_archived', 'archived_day', 'all_group_mute', 'start_home', 'home_footer'])
|
||||||
|
|
||||||
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
||||||
* @apiSuccess {String} msg 返回信息(错误描述)
|
* @apiSuccess {String} msg 返回信息(错误描述)
|
||||||
@ -53,6 +53,7 @@ class SystemController extends AbstractController
|
|||||||
'chat_nickname',
|
'chat_nickname',
|
||||||
'auto_archived',
|
'auto_archived',
|
||||||
'archived_day',
|
'archived_day',
|
||||||
|
'all_group_mute',
|
||||||
'start_home',
|
'start_home',
|
||||||
'home_footer'
|
'home_footer'
|
||||||
])) {
|
])) {
|
||||||
@ -86,6 +87,7 @@ class SystemController extends AbstractController
|
|||||||
$setting['chat_nickname'] = $setting['chat_nickname'] ?: 'optional';
|
$setting['chat_nickname'] = $setting['chat_nickname'] ?: 'optional';
|
||||||
$setting['auto_archived'] = $setting['auto_archived'] ?: 'close';
|
$setting['auto_archived'] = $setting['auto_archived'] ?: 'close';
|
||||||
$setting['archived_day'] = floatval($setting['archived_day']) ?: 7;
|
$setting['archived_day'] = floatval($setting['archived_day']) ?: 7;
|
||||||
|
$setting['all_group_mute'] = $setting['all_group_mute'] ?: 'open';
|
||||||
$setting['start_home'] = $setting['start_home'] ?: 'close';
|
$setting['start_home'] = $setting['start_home'] ?: 'close';
|
||||||
//
|
//
|
||||||
return Base::retSuccess('success', $setting ?: json_decode('{}'));
|
return Base::retSuccess('success', $setting ?: json_decode('{}'));
|
||||||
|
|||||||
@ -666,7 +666,7 @@ class UsersController extends AbstractController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($upArray) {
|
if ($upArray) {
|
||||||
AbstractModel::transaction(function() use ($type, $upArray, $userInfo, $transferUser) {
|
AbstractModel::transaction(function() use ($user, $type, $upArray, $userInfo, $transferUser) {
|
||||||
$userInfo->updateInstance($upArray);
|
$userInfo->updateInstance($upArray);
|
||||||
$userInfo->save();
|
$userInfo->save();
|
||||||
if ($type === 'setdisable') {
|
if ($type === 'setdisable') {
|
||||||
@ -676,6 +676,13 @@ class UsersController extends AbstractController
|
|||||||
]);
|
]);
|
||||||
$userTransfer->save();
|
$userTransfer->save();
|
||||||
$userTransfer->start();
|
$userTransfer->start();
|
||||||
|
// 离职移出全员群组
|
||||||
|
$dialog = WebSocketDialog::whereGroupType('all')->orderByDesc('id')->first();
|
||||||
|
$dialog?->exitGroup($userInfo->userid, 'remove');
|
||||||
|
} elseif ($type === 'cleardisable') {
|
||||||
|
// 取消离职重新加入全员群组
|
||||||
|
$dialog = WebSocketDialog::whereGroupType('all')->orderByDesc('id')->first();
|
||||||
|
$dialog?->joinGroup($userInfo->userid, $user->userid);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -230,7 +230,11 @@ class User extends AbstractModel
|
|||||||
$user = User::createInstance($inArray);
|
$user = User::createInstance($inArray);
|
||||||
$user->az = Base::getFirstCharter($user->nickname);
|
$user->az = Base::getFirstCharter($user->nickname);
|
||||||
$user->pinyin = Base::cn2pinyin($user->nickname);
|
$user->pinyin = Base::cn2pinyin($user->nickname);
|
||||||
$user->save();
|
if ($user->save()) {
|
||||||
|
// 加入全员群组
|
||||||
|
$dialog = WebSocketDialog::whereGroupType('all')->orderByDesc('id')->first();
|
||||||
|
$dialog?->joinGroup($user->userid, 0);
|
||||||
|
}
|
||||||
return $user->find($user->userid);
|
return $user->find($user->userid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App\Exceptions\ApiException;
|
use App\Exceptions\ApiException;
|
||||||
|
use App\Module\Base;
|
||||||
use App\Tasks\PushTask;
|
use App\Tasks\PushTask;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Hhxsv5\LaravelS\Swoole\Task\Task;
|
use Hhxsv5\LaravelS\Swoole\Task\Task;
|
||||||
@ -116,6 +117,9 @@ class WebSocketDialog extends AbstractModel
|
|||||||
$this->name = '[Delete]';
|
$this->name = '[Delete]';
|
||||||
$this->dialog_delete = 1;
|
$this->dialog_delete = 1;
|
||||||
}
|
}
|
||||||
|
} elseif ($this->group_type === 'all') {
|
||||||
|
$this->name = Base::Lang('全体成员');
|
||||||
|
$this->all_group_mute = Base::settingFind('system', 'all_group_mute');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -249,6 +253,26 @@ class WebSocketDialog extends AbstractModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查禁言
|
||||||
|
* @param $userid
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function checkMute($userid)
|
||||||
|
{
|
||||||
|
if ($this->group_type === 'all') {
|
||||||
|
$allGroupMute = Base::settingFind('system', 'all_group_mute');
|
||||||
|
switch ($allGroupMute) {
|
||||||
|
case 'all':
|
||||||
|
throw new ApiException('当前会话全员禁言');
|
||||||
|
case 'user':
|
||||||
|
if (!User::find($userid)?->isAdmin()) {
|
||||||
|
throw new ApiException('当前会话禁言');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取群组名称
|
* 获取群组名称
|
||||||
* @return mixed|string|null
|
* @return mixed|string|null
|
||||||
@ -350,7 +374,7 @@ class WebSocketDialog extends AbstractModel
|
|||||||
'name' => $name ?: '',
|
'name' => $name ?: '',
|
||||||
'group_type' => $group_type,
|
'group_type' => $group_type,
|
||||||
'owner_id' => $owner_id,
|
'owner_id' => $owner_id,
|
||||||
'last_at' => $group_type === 'user' ? Carbon::now() : null,
|
'last_at' => in_array($group_type, ['user', 'all']) ? Carbon::now() : null,
|
||||||
]);
|
]);
|
||||||
$dialog->save();
|
$dialog->save();
|
||||||
foreach (is_array($userid) ? $userid : [$userid] as $value) {
|
foreach (is_array($userid) ? $userid : [$userid] as $value) {
|
||||||
@ -358,7 +382,7 @@ class WebSocketDialog extends AbstractModel
|
|||||||
WebSocketDialogUser::createInstance([
|
WebSocketDialogUser::createInstance([
|
||||||
'dialog_id' => $dialog->id,
|
'dialog_id' => $dialog->id,
|
||||||
'userid' => $value,
|
'userid' => $value,
|
||||||
'important' => $group_type != 'user'
|
'important' => !in_array($group_type, ['user', 'all'])
|
||||||
])->save();
|
])->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -553,6 +553,7 @@ class WebSocketDialogMsg extends AbstractModel
|
|||||||
if (empty($dialog)) {
|
if (empty($dialog)) {
|
||||||
throw new ApiException('获取会话失败');
|
throw new ApiException('获取会话失败');
|
||||||
}
|
}
|
||||||
|
$dialog->checkMute($sender);
|
||||||
//
|
//
|
||||||
if ($update_id) {
|
if ($update_id) {
|
||||||
// 修改
|
// 修改
|
||||||
|
|||||||
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Models\WebSocketDialog;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class GenerateWebSocketDialogsAllGroup extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
if (!WebSocketDialog::whereGroupType('all')->exists()) {
|
||||||
|
$userids = User::whereNull('disable_at')->pluck('userid')->toArray();
|
||||||
|
WebSocketDialog::createGroup(null, $userids, 'all');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -30,7 +30,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="group-info-button">
|
<div v-if="dialogData.group_type !== 'all'" class="group-info-button">
|
||||||
<Button v-if="dialogData.owner_id == userId || dialogData.owner_id == 0" @click="openAdd" type="primary">{{ $L("添加成员") }}</Button>
|
<Button v-if="dialogData.owner_id == userId || dialogData.owner_id == 0" @click="openAdd" type="primary">{{ $L("添加成员") }}</Button>
|
||||||
<Button v-if="dialogData.owner_id == userId" @click="onDisband" type="error" ghost>{{ $L("解散群组") }}</Button>
|
<Button v-if="dialogData.owner_id == userId" @click="onDisband" type="error" ghost>{{ $L("解散群组") }}</Button>
|
||||||
<Button v-else @click="onExit" type="error" ghost>{{ $L("退出群组") }}</Button>
|
<Button v-else @click="onExit" type="error" ghost>{{ $L("退出群组") }}</Button>
|
||||||
@ -94,6 +94,7 @@ export default {
|
|||||||
if (group_type === 'project') return '项目群组'
|
if (group_type === 'project') return '项目群组'
|
||||||
if (group_type === 'task') return '任务群组'
|
if (group_type === 'task') return '任务群组'
|
||||||
if (group_type === 'user') return '个人群组'
|
if (group_type === 'user') return '个人群组'
|
||||||
|
if (group_type === 'all') return '全员群组'
|
||||||
return '未知'
|
return '未知'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@ -121,7 +121,11 @@
|
|||||||
@on-progress="chatFile('progress', $event)"
|
@on-progress="chatFile('progress', $event)"
|
||||||
@on-success="chatFile('success', $event)"
|
@on-success="chatFile('success', $event)"
|
||||||
@on-error="chatFile('error', $event)"/>
|
@on-error="chatFile('error', $event)"/>
|
||||||
|
<div v-if="isMute" class="chat-mute">
|
||||||
|
{{$L('禁言发言')}}
|
||||||
|
</div>
|
||||||
<ChatInput
|
<ChatInput
|
||||||
|
v-else
|
||||||
ref="input"
|
ref="input"
|
||||||
v-model="msgText"
|
v-model="msgText"
|
||||||
:dialog-id="dialogId"
|
:dialog-id="dialogId"
|
||||||
@ -401,6 +405,7 @@ export default {
|
|||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapState([
|
...mapState([
|
||||||
|
'userIsAdmin',
|
||||||
'taskId',
|
'taskId',
|
||||||
'dialogSearchMsgId',
|
'dialogSearchMsgId',
|
||||||
'dialogMsgs',
|
'dialogMsgs',
|
||||||
@ -553,6 +558,19 @@ export default {
|
|||||||
return dialogData.dialog_user && dialogData.dialog_user.userid == userId
|
return dialogData.dialog_user && dialogData.dialog_user.userid == userId
|
||||||
},
|
},
|
||||||
|
|
||||||
|
isMute() {
|
||||||
|
if (this.dialogData.group_type === 'all') {
|
||||||
|
if (this.dialogData.all_group_mute === 'all') {
|
||||||
|
return true
|
||||||
|
} else if (this.dialogData.all_group_mute === 'user') {
|
||||||
|
if (!this.userIsAdmin) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
},
|
||||||
|
|
||||||
replyId() {
|
replyId() {
|
||||||
return parseInt(this.msgId > 0 ? this.msgId : this.replyActiveId)
|
return parseInt(this.msgId > 0 ? this.msgId : this.replyActiveId)
|
||||||
},
|
},
|
||||||
@ -914,7 +932,7 @@ export default {
|
|||||||
|
|
||||||
inputFocus() {
|
inputFocus() {
|
||||||
this.$nextTick(_ => {
|
this.$nextTick(_ => {
|
||||||
this.$refs.input.focus()
|
this.$refs.input && this.$refs.input.focus()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@ -61,6 +61,16 @@
|
|||||||
<div slot="content">{{$L('任务完成 % 天后自动归档。', formDatum.archived_day)}}</div>
|
<div slot="content">{{$L('任务完成 % 天后自动归档。', formDatum.archived_day)}}</div>
|
||||||
</ETooltip>
|
</ETooltip>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
<FormItem :label="$L('全员群组禁言')" prop="disabledAllGroup">
|
||||||
|
<RadioGroup v-model="formDatum.all_group_mute">
|
||||||
|
<Radio label="open">{{$L('开放')}}</Radio>
|
||||||
|
<Radio label="user">{{$L('成员禁言')}}</Radio>
|
||||||
|
<Radio label="all">{{$L('全部禁言')}}</Radio>
|
||||||
|
</RadioGroup>
|
||||||
|
<div v-if="formDatum.all_group_mute == 'open'" class="form-tip">{{$L('开放:所有人都可以发言。')}}</div>
|
||||||
|
<div v-else-if="formDatum.all_group_mute == 'user'" class="form-tip">{{$L('成员禁言:仅管理员可以发言。')}}</div>
|
||||||
|
<div v-else-if="formDatum.all_group_mute == 'all'" class="form-tip">{{$L('全部禁言:所有人都禁止发言。')}}</div>
|
||||||
|
</FormItem>
|
||||||
<FormItem :label="$L('是否启动首页')" prop="startHome">
|
<FormItem :label="$L('是否启动首页')" prop="startHome">
|
||||||
<RadioGroup v-model="formDatum.start_home">
|
<RadioGroup v-model="formDatum.start_home">
|
||||||
<Radio label="open">{{$L('开启')}}</Radio>
|
<Radio label="open">{{$L('开启')}}</Radio>
|
||||||
|
|||||||
@ -982,6 +982,14 @@
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.chat-mute {
|
||||||
|
color: $primary-desc-color;
|
||||||
|
background-color: #F4F5F7;
|
||||||
|
padding: 8px 12px;
|
||||||
|
border-radius: 10px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
.chat-input-box {
|
.chat-input-box {
|
||||||
.chat-input-wrapper {
|
.chat-input-wrapper {
|
||||||
background-color: #F4F5F7;
|
background-color: #F4F5F7;
|
||||||
@ -1362,6 +1370,9 @@
|
|||||||
background-color: #f8f8f8;
|
background-color: #f8f8f8;
|
||||||
padding: 8px 10px;
|
padding: 8px 10px;
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
|
.chat-mute {
|
||||||
|
background-color: #ffffff;
|
||||||
|
}
|
||||||
.chat-input-box {
|
.chat-input-box {
|
||||||
.chat-input-wrapper {
|
.chat-input-wrapper {
|
||||||
background-color: #ffffff;
|
background-color: #ffffff;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user