updateauth

This commit is contained in:
Kerwin
2025-07-10 15:07:29 +08:00
parent ab1074a2c6
commit 1133563182
17 changed files with 1431 additions and 135 deletions

View File

@@ -76,6 +76,7 @@ func autoMigrate() error {
&entity.Resource{},
&entity.ResourceTag{},
&entity.ReadyResource{},
&entity.User{},
)
}
@@ -97,5 +98,18 @@ func insertDefaultData() error {
}
}
// 插入默认管理员用户
defaultAdmin := entity.User{
Username: "admin",
Password: "$2a$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi", // password
Email: "admin@example.com",
Role: "admin",
IsActive: true,
}
if err := DB.Where("username = ?", defaultAdmin.Username).FirstOrCreate(&defaultAdmin).Error; err != nil {
return err
}
return nil
}