优化:微信群内管理员上线播报仅针对拥有职务的用户,并前置显示部门及职务名称

This commit is contained in:
2026-04-03 14:05:04 +08:00
parent 3488ad0605
commit db26820544

View File

@@ -70,14 +70,18 @@ class WechatNotificationService
return;
}
// 判断是否真的是管理员(这里假设大于等于某等级,比如 15
$adminLevel = (int) Sysparam::getValue('level_kick', '15');
if ($user->user_level < $adminLevel) {
// 只播报有职务的管理员
$activePosition = $user->activePosition;
if (! $activePosition) {
return;
}
$departmentName = $activePosition->position->department->name ?? '';
$positionName = $activePosition->position->name ?? '';
$title = trim("{$departmentName}{$positionName}") ?: '技术员';
$message = "👑 【管理员上线】\n"
."管理员 [{$user->username}] 刚刚登录了系统。";
."{$title} [{$user->username}] 刚刚登录了系统。";
SendWechatBotMessage::dispatch($groupWxid, $message);
}