-
Notifications
You must be signed in to change notification settings - Fork 2.9k
feat: Complete the node initialization logic #7571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,8 @@ type ILauncherRepo interface { | |
| Create(launcher *model.AppLauncher) error | ||
| Save(launcher *model.AppLauncher) error | ||
| Delete(opts ...DBOption) error | ||
|
|
||
| SyncAll(data []model.AppLauncher) error | ||
| } | ||
|
|
||
| func NewILauncherRepo() ILauncherRepo { | ||
|
|
@@ -53,3 +55,17 @@ func (u *LauncherRepo) Delete(opts ...DBOption) error { | |
| } | ||
| return db.Delete(&model.AppLauncher{}).Error | ||
| } | ||
|
|
||
| func (u *LauncherRepo) SyncAll(data []model.AppLauncher) error { | ||
| tx := global.DB.Begin() | ||
| if err := tx.Where("1 = 1").Delete(&model.AppLauncher{}).Error; err != nil { | ||
| tx.Rollback() | ||
| return err | ||
| } | ||
| if err := tx.Model(model.AppLauncher{}).Save(&data).Error; err != nil { | ||
| tx.Rollback() | ||
| return err | ||
| } | ||
| tx.Commit() | ||
| return nil | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a Go code snippet for an interface-based interface
There are no known errors or inconsistencies based on context provided. No optimization suggestions needed here considering it appears not used directly in the actual application logic but serves an informational purpose. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,8 @@ type IBackupRepo interface { | |
| WithByFileName(fileName string) DBOption | ||
| WithByCronID(cronjobID uint) DBOption | ||
| WithFileNameStartWith(filePrefix string) DBOption | ||
|
|
||
| SyncAll(data []model.BackupAccount) error | ||
| } | ||
|
|
||
| func NewIBackupRepo() IBackupRepo { | ||
|
|
@@ -153,3 +155,17 @@ func (u *BackupRepo) GetRecord(opts ...DBOption) (*model.BackupRecord, error) { | |
| err := db.Find(record).Error | ||
| return record, err | ||
| } | ||
|
|
||
| func (u *BackupRepo) SyncAll(data []model.BackupAccount) error { | ||
| tx := global.DB.Begin() | ||
| if err := tx.Where("1 = 1").Delete(&model.BackupAccount{}).Error; err != nil { | ||
| tx.Rollback() | ||
| return err | ||
| } | ||
| if err := tx.Model(model.BackupAccount{}).Save(&data).Error; err != nil { | ||
| tx.Rollback() | ||
| return err | ||
| } | ||
| tx.Commit() | ||
| return nil | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code seems to be correctly formatted in both Go version and Java version. There doesn't appear to be any obvious errors or oddities that need adjustments. One minor suggestion is for the function
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm sorry but the text you've provided is too short to be analyzed for specific code differences, issues or optimizations. For detailed examination of an entire file content it would be helpful if you specify what aspects exactly need examining like syntax mistakes, missing types etc. For example, some key checks could include:
etc. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -107,13 +107,14 @@ func (u *BackupService) GetLocalDir() (string, error) { | |
| } | ||
|
|
||
| func (u *BackupService) SearchWithPage(req dto.SearchPageWithType) (int64, interface{}, error) { | ||
| count, accounts, err := backupRepo.Page( | ||
| req.Page, | ||
| req.PageSize, | ||
| repo.WithByType(req.Type), | ||
| repo.WithByName(req.Info), | ||
| repo.WithOrderBy("created_at desc"), | ||
| ) | ||
| options := []global.DBOption{repo.WithOrderBy("created_at desc")} | ||
| if len(req.Type) != 0 { | ||
| options = append(options, repo.WithByType(req.Type)) | ||
| } | ||
| if len(req.Info) != 0 { | ||
| options = append(options, repo.WithByType(req.Info)) | ||
| } | ||
| count, accounts, err := backupRepo.Page(req.Page, req.PageSize, options...) | ||
| if err != nil { | ||
| return 0, nil, err | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no need to optimize the given code as it seems correct and efficient already. The functions named getLocalDir() can also be renamed to avoid conflicts with other function names, such as The comments at lines 50 and 107 seem redundant because they repeat information within those lines; however, these redundancies do not cause errors in the existing code but serve a stylistic purpose rather than improving efficiency. If you find them overly verbose and wish to reduce redundancy without altering functionality, consider updating the variable name, comment header text slightly, or commenting out the additional line entirely:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are no apparent inconsistencies between the original code snippet provided and the current version of it. This is good practice to keep files up-to-date with the latest changes. It ensures that new features or fixes do not get lost in older versions when looking at different parts of the same codebase. |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The most notable difference I found is a small typo in the code:
This should be corrected to ensure correct function names.
Regarding optimization suggestions or potential issues:
If you want more detailed suggestions, please include additional context about how this repo functions in the application pipeline, or what other features it has/dependencies.