Browse Source

fix: 修改主机默认分组名称 (#381)

pull/385/head
ssongliu 2 years ago committed by GitHub
parent
commit
4f4879759e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      backend/app/service/group.go
  2. 12
      backend/init/migration/migrations/init.go
  3. 7
      frontend/src/views/host/terminal/host/change-group/index.vue
  4. 3
      frontend/src/views/host/terminal/host/index.vue

2
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
}

12
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")
},
}

7
frontend/src/views/host/terminal/host/change-group/index.vue

@ -10,12 +10,7 @@
<el-form-item :label="$t('commons.table.group')" prop="group">
<el-select filterable v-model="dialogData.groupID" clearable style="width: 100%">
<div v-for="item in groupList" :key="item.id">
<el-option
v-if="item.name === 'default'"
:label="$t('website.default')"
:value="item.id"
/>
<el-option v-else :label="item.name" :value="item.id" />
<el-option :label="item.name" :value="item.id" />
</div>
</el-select>
</el-form-item>

3
frontend/src/views/host/terminal/host/index.vue

@ -34,8 +34,7 @@
<template #prefix>{{ $t('terminal.group') }}</template>
<el-option :label="$t('commons.table.all')" value=""></el-option>
<div v-for="item in groupList" :key="item.name">
<el-option v-if="item.name === 'default'" :label="$t('website.default')" :value="item.id" />
<el-option v-else :value="item.id" :label="item.name" />
<el-option :value="item.id" :label="item.name" />
</div>
</el-select>
</template>

Loading…
Cancel
Save