From efadf51a232b77da62b437553aa3e485db5e63c4 Mon Sep 17 00:00:00 2001 From: CorrectRoad Date: Mon, 4 Nov 2024 19:16:11 +0900 Subject: [PATCH] fix: fix onboarding ysk card only init once (#58) --- codegen/message_bus_api.go | 113 ++++++++++++++++++------------------ model/settings.go | 6 ++ repository/repository.go | 3 + repository/repository_db.go | 16 +++++ service/ysk.go | 17 +++++- 5 files changed, 96 insertions(+), 59 deletions(-) create mode 100644 model/settings.go diff --git a/codegen/message_bus_api.go b/codegen/message_bus_api.go index 93d2863..135eb77 100644 --- a/codegen/message_bus_api.go +++ b/codegen/message_bus_api.go @@ -707,62 +707,63 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ - "H4sIAAAAAAAC/+xcXW/bOLP+K4TOuWgB2U7TdHdrYC+aZLcb9GxT1MXpu2iCmJLGNmuJ1JJUHDXwf39B", - "Uh/Uly07TgIs9qq1Tc4Mn3k4nKFGuXd8FsWMApXCGd87MeY4Aglcf3rnS8LoRxyB+kSoM3ZiLBeO61D9", - "nfnHdTj8nRAOgTOWPAHXEf4CIqzmwB2O4lANDZmPw4GQjOM5jGPMJVHCxzPGIywd15FprMYJyQmdO+u1", - "a6kXu8hyu36OWEKVJr2QvxPgaXUlwrFNJxIirbdmWGEp5hyn2tDfboHKx4ApIGI5xkEAQStAhV7RT4jb", - "8gOHiN1q+QeHZcIS7sPFeQcqQv98Q4J9oGnBY23EgJCnLCAGk0+JFxKx0ECpzz6jMvsvjuOQ+FgxY/Rd", - "MKq+K9XiINCkweEnzmLgMhPYWHUAwuckVmOdsQNKEYrLKW65gPuaXyIWQOiMnTOe/ADuuLWfk4QEztg5", - "OTmGI3jjDd4Gr2FwMoNfBt7JT7PBW//k1cmrWQB+8HNj7i3QgHFn7EwwPSdiabmHed/Blwauqu0vvlye", - "X75sOGPtOp9hToQEbjbklzQ2WPQGs+DM/3KYOWPnf0Zl1BmZYWJ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pB224LSbWT0UvAke0+6ZTH5IirGFx+c2ls3", + "V+ur9f8DAAD//z3VnfHySgAA", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/model/settings.go b/model/settings.go new file mode 100644 index 0000000..51880fc --- /dev/null +++ b/model/settings.go @@ -0,0 +1,6 @@ +package model + +type Settings struct { + Key string `gorm:"primaryKey"` + Value string +} diff --git a/repository/repository.go b/repository/repository.go index 5c114a5..c8b02c5 100644 --- a/repository/repository.go +++ b/repository/repository.go @@ -20,5 +20,8 @@ type Repository interface { UpsertYSKCard(card ysk.YSKCard) error DeleteYSKCard(id string) error + GetSettings(key string) (*model.Settings, error) + UpsertSettings(settings model.Settings) error + Close() } diff --git a/repository/repository_db.go b/repository/repository_db.go index cd066e1..7cae7a3 100644 --- a/repository/repository_db.go +++ b/repository/repository_db.go @@ -48,6 +48,21 @@ func (r *DatabaseRepository) GetEventTypes() ([]model.EventType, error) { return eventTypes, nil } +func (r *DatabaseRepository) GetSettings(key string) (*model.Settings, error) { + var settings model.Settings + if err := r.persistDB.Where(&model.Settings{Key: key}).First(&settings).Error; err != nil { + return nil, err + } + return &settings, nil +} + +func (r *DatabaseRepository) UpsertSettings(settings model.Settings) error { + return r.persistDB.Clauses(clause.OnConflict{ + Columns: []clause.Column{{Name: "key"}}, + UpdateAll: true, + }).Create(&settings).Error +} + func (r *DatabaseRepository) RegisterEventType(eventType model.EventType) (*model.EventType, error) { // upsert if err := r.db.Clauses(clause.OnConflict{UpdateAll: true}).Create(&eventType).Error; err != nil { @@ -175,6 +190,7 @@ func NewDatabaseRepository(databaseFilePath string, persistDatabaseFilePath stri if err := persistDB.AutoMigrate( &ysk.YSKCard{}, + &model.Settings{}, ); err != nil { return nil, err } diff --git a/service/ysk.go b/service/ysk.go index 61adcb2..9316469 100644 --- a/service/ysk.go +++ b/service/ysk.go @@ -21,6 +21,8 @@ type YSKService struct { eventTypeService *EventTypeService } +const YSKOnboardingFinishedKey = "ysk_onboarding_finished" + func NewYSKService( repository *repository.Repository, ws *EventServiceWS, @@ -55,11 +57,20 @@ func (s *YSKService) DeleteYSKCard(ctx context.Context, id string) error { } func (s *YSKService) Start(init bool) { + // 判断数据库 if init { + // only run once + settings, err := (*s.repository).GetSettings(YSKOnboardingFinishedKey) - s.UpsertYSKCard(context.Background(), utils.ZimaOSDataStationNotice) - s.UpsertYSKCard(context.Background(), utils.ZimaOSFileManagementNotice) - s.UpsertYSKCard(context.Background(), utils.ZimaOSRemoteAccessNotice) + if settings == nil && err.Error() == "record not found" { + s.UpsertYSKCard(context.Background(), utils.ZimaOSDataStationNotice) + s.UpsertYSKCard(context.Background(), utils.ZimaOSFileManagementNotice) + s.UpsertYSKCard(context.Background(), utils.ZimaOSRemoteAccessNotice) + (*s.repository).UpsertSettings(model.Settings{ + Key: YSKOnboardingFinishedKey, + Value: "true", + }) + } } // register event s.eventTypeService.RegisterEventType(model.EventType{