From 4f4879759e0f8bb48aa6e02b1eb6de77ca99d92f Mon Sep 17 00:00:00 2001
From: ssongliu <73214554+ssongliu@users.noreply.github.com>
Date: Thu, 23 Mar 2023 16:26:33 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E4=B8=BB=E6=9C=BA?=
=?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=88=86=E7=BB=84=E5=90=8D=E7=A7=B0=20(#381)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
backend/app/service/group.go | 2 +-
backend/init/migration/migrations/init.go | 12 +++++++++---
.../views/host/terminal/host/change-group/index.vue | 7 +------
frontend/src/views/host/terminal/host/index.vue | 3 +--
4 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/backend/app/service/group.go b/backend/app/service/group.go
index 25921d74b..09152281f 100644
--- a/backend/app/service/group.go
+++ b/backend/app/service/group.go
@@ -38,7 +38,7 @@ func (u *GroupService) List(req dto.GroupSearch) ([]dto.GroupInfo, error) {
}
func (u *GroupService) Create(req dto.GroupCreate) error {
- group, _ := groupRepo.Get(commonRepo.WithByName(req.Name), commonRepo.WithByName(req.Name))
+ group, _ := groupRepo.Get(commonRepo.WithByName(req.Name), commonRepo.WithByType(req.Type))
if group.ID != 0 {
return constant.ErrRecordExist
}
diff --git a/backend/init/migration/migrations/init.go b/backend/init/migration/migrations/init.go
index 1b78acec8..bb8c2fd64 100644
--- a/backend/init/migration/migrations/init.go
+++ b/backend/init/migration/migrations/init.go
@@ -140,7 +140,6 @@ var AddTableSetting = &gormigrate.Migration{
return err
}
if err := tx.Create(&model.Setting{Key: "SystemStatus", Value: "Free"}).Error; err != nil {
- tx.Rollback()
return err
}
if err := tx.Create(&model.Setting{Key: "AppStoreVersion", Value: ""}).Error; err != nil {
@@ -236,8 +235,15 @@ var AddDefaultGroup = &gormigrate.Migration{
IsDefault: true,
Type: "website",
}
- tx.Create(defaultGroup)
- tx.Debug().Model(&model.Website{}).Where("1 = 1").Update("website_group_id", defaultGroup.ID)
+ if err := tx.Create(defaultGroup).Error; err != nil {
+ return err
+ }
+ if err := tx.Model(&model.Group{}).Where("name = ? AND type = ?", "default", "host").Update("name", "默认").Error; err != nil {
+ return err
+ }
+ if err := tx.Model(&model.Website{}).Where("1 = 1").Update("website_group_id", defaultGroup.ID).Error; err != nil {
+ return err
+ }
return tx.Migrator().DropTable("website_groups")
},
}
diff --git a/frontend/src/views/host/terminal/host/change-group/index.vue b/frontend/src/views/host/terminal/host/change-group/index.vue
index 0c2719ce5..308bc599f 100644
--- a/frontend/src/views/host/terminal/host/change-group/index.vue
+++ b/frontend/src/views/host/terminal/host/change-group/index.vue
@@ -10,12 +10,7 @@