完善角色权限与数据隔离

This commit is contained in:
yml2213
2026-07-26 14:00:50 +08:00
parent b483cbc26d
commit 16d9ab0e5e
38 changed files with 2847 additions and 292 deletions
+7 -1
View File
@@ -19,10 +19,11 @@ func main() {
}
func seed() {
// 默认后台管理员:kefu_admin / kefu_admin123(其它种子账号同密码)
hash, _ := bcrypt.GenerateFromPassword([]byte("kefu_admin123"), bcrypt.DefaultCost)
pwd := string(hash)
model.EnsurePermissions()
// Plans
plans := []model.Plan{
{Name: "基础版", PriceMonthly: 299, Seats: 2, StorageDays: 30, KBLimit: 50, Status: "active", Features: `{"stats":"basic","api":false,"channels":["web"],"brand":false}`},
@@ -42,6 +43,11 @@ func seed() {
}
model.DB.Create(&tenants)
// 为每个租户创建内置角色及默认权限
for _, t := range tenants {
model.EnsureBuiltinRoles(t.ID)
}
// Platform admin
model.DB.Create(&model.User{
TenantID: 0, Role: "platform_admin", Username: "platform_admin", PasswordHash: pwd, Nickname: "平台管理员", Status: "online",