add rescide
All checks were successful
Deploy on Master Change / deploy (push) Successful in 1m43s

This commit is contained in:
2026-07-29 12:32:01 +07:00
parent 3b80550c76
commit 42172db9f4
6 changed files with 445 additions and 2 deletions

View File

@@ -80,9 +80,61 @@ func AutoMigrate(db *gorm.DB) error {
if err := purgeLegacyWifiWithoutBSSID(db); err != nil {
return err
}
if err := seedRescideAppDownloads(db); err != nil {
log.Printf("Warning: seed RESCIDE app downloads: %v", err)
}
return migrateLegacyDiscoveredApps(db)
}
// seedRescideAppDownloads thêm link tải RESCIDE nếu chưa có (quản lý tiếp tại tab Ứng dụng — super-admin).
func seedRescideAppDownloads(db *gorm.DB) error {
type seedItem struct {
Name string
Description string
DownloadURL string
Platform string
}
items := []seedItem{
{
Name: "RESCIDE (macOS Intel)",
Description: "IDE thi thực hành — macOS chip Intel",
DownloadURL: "https://save.rikkeiraia.org/RESCIDE_intel-installer.dmg",
Platform: "macOS",
},
{
Name: "RESCIDE (macOS Apple Silicon)",
Description: "IDE thi thực hành — macOS chip Apple ARM",
DownloadURL: "https://save.rikkeiraia.org/RESCIDE_arm-installer.dmg",
Platform: "macOS",
},
{
Name: "RESCIDE (Windows)",
Description: "IDE thi thực hành — Windows 10+",
DownloadURL: "https://save.rikkeiraia.org/RESCIDE-1.73.100-win.zip",
Platform: "Windows",
},
}
for _, item := range items {
var count int64
if err := db.Model(&models.AppDownload{}).Where("download_url = ?", item.DownloadURL).Count(&count).Error; err != nil {
return err
}
if count > 0 {
continue
}
if err := db.Create(&models.AppDownload{
Name: item.Name,
Description: item.Description,
DownloadURL: item.DownloadURL,
Platform: item.Platform,
}).Error; err != nil {
return err
}
log.Printf("Seeded app download: %s", item.Name)
}
return nil
}
// Bảng WiFi cũ dùng ssid_key làm PK; schema mới cần id + bssid_key — GORM không tự đổi PK.
func migrateLegacyWifiTables(db *gorm.DB) error {
if db.Migrator().HasTable("accepted_wifis") {