聊天室管理权限统一为职务权限
This commit is contained in:
@@ -45,13 +45,6 @@ return new class extends Migration
|
||||
['alias' => 'jjb_per_heartbeat', 'body' => '1-3', 'guidetxt' => '💰 每次心跳金币奖励(支持固定值如"1"或范围如"1-5";0关闭)', 'created_at' => $now, 'updated_at' => $now],
|
||||
|
||||
// ── 管理操作权限等级 ──────────────────────────────────────
|
||||
['alias' => 'level_warn', 'body' => '5', 'guidetxt' => '警告所需等级', 'created_at' => $now, 'updated_at' => $now],
|
||||
['alias' => 'level_mute', 'body' => '50', 'guidetxt' => '禁言所需等级', 'created_at' => $now, 'updated_at' => $now],
|
||||
['alias' => 'level_kick', 'body' => '60', 'guidetxt' => '踢人所需等级', 'created_at' => $now, 'updated_at' => $now],
|
||||
['alias' => 'level_announcement', 'body' => '60', 'guidetxt' => '设置公告所需等级', 'created_at' => $now, 'updated_at' => $now],
|
||||
['alias' => 'level_ban', 'body' => '80', 'guidetxt' => '封号所需等级', 'created_at' => $now, 'updated_at' => $now],
|
||||
['alias' => 'level_banip', 'body' => '90', 'guidetxt' => '封IP所需等级', 'created_at' => $now, 'updated_at' => $now],
|
||||
['alias' => 'level_freeze', 'body' => '14', 'guidetxt' => '冻结账号所需等级', 'created_at' => $now, 'updated_at' => $now],
|
||||
|
||||
// ── 随机事件 ──────────────────────────────────────────────
|
||||
['alias' => 'auto_event_chance', 'body' => '10', 'guidetxt' => '随机事件触发概率(百分比,1-100)', 'created_at' => $now, 'updated_at' => $now],
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:清理已废弃的等级阈值聊天室管理权限参数
|
||||
* 统一删除 level_* 权限残留,避免继续与职务权限体系并存。
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* 方法功能:删除旧等级权限参数。
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
DB::table('sysparam')
|
||||
->whereIn('alias', [
|
||||
'level_warn',
|
||||
'level_mute',
|
||||
'level_kick',
|
||||
'level_announcement',
|
||||
'level_ban',
|
||||
'level_banip',
|
||||
'level_freeze',
|
||||
])
|
||||
->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* 方法功能:回滚时恢复旧等级权限参数默认值。
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
$now = now();
|
||||
|
||||
foreach ([
|
||||
'level_warn' => ['5', '警告所需等级'],
|
||||
'level_mute' => ['50', '禁言所需等级'],
|
||||
'level_kick' => ['60', '踢人所需等级'],
|
||||
'level_announcement' => ['60', '设置公告所需等级'],
|
||||
'level_ban' => ['80', '封号所需等级'],
|
||||
'level_banip' => ['90', '封IP所需等级'],
|
||||
'level_freeze' => ['14', '冻结账号所需等级'],
|
||||
] as $alias => [$body, $guidetxt]) {
|
||||
DB::table('sysparam')->updateOrInsert(
|
||||
['alias' => $alias],
|
||||
[
|
||||
'body' => $body,
|
||||
'guidetxt' => $guidetxt,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:将旧的冻结权限合并到封号权限
|
||||
* 确保已配置 room.user_freeze 的职务在合并后自动继承 room.user_ban。
|
||||
*/
|
||||
|
||||
use App\Models\Position;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* 方法功能:把冻结权限迁移为封号权限。
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Position::query()->each(function (Position $position): void {
|
||||
$permissions = array_values($position->permissions ?? []);
|
||||
|
||||
if (! in_array('room.user_freeze', $permissions, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$normalizedPermissions = array_values(array_unique(array_map(
|
||||
fn (string $permission): string => $permission === 'room.user_freeze' ? 'room.user_ban' : $permission,
|
||||
$permissions,
|
||||
)));
|
||||
|
||||
$position->forceFill([
|
||||
'permissions' => $normalizedPermissions,
|
||||
])->save();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 方法功能:回滚时把合并后的封号权限恢复为冻结权限。
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Position::query()->each(function (Position $position): void {
|
||||
$permissions = array_values($position->permissions ?? []);
|
||||
|
||||
if (! in_array('room.user_ban', $permissions, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$normalizedPermissions = array_values(array_unique(array_map(
|
||||
fn (string $permission): string => $permission === 'room.user_ban' ? 'room.user_freeze' : $permission,
|
||||
$permissions,
|
||||
)));
|
||||
|
||||
$position->forceFill([
|
||||
'permissions' => $normalizedPermissions,
|
||||
])->save();
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user