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

pull/385/head
ssongliu 2 years ago committed by GitHub
parent 92a410fcea
commit 4f4879759e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -38,7 +38,7 @@ func (u *GroupService) List(req dto.GroupSearch) ([]dto.GroupInfo, error) {
} }
func (u *GroupService) Create(req dto.GroupCreate) 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 { if group.ID != 0 {
return constant.ErrRecordExist return constant.ErrRecordExist
} }

@ -140,7 +140,6 @@ var AddTableSetting = &gormigrate.Migration{
return err return err
} }
if err := tx.Create(&model.Setting{Key: "SystemStatus", Value: "Free"}).Error; err != nil { if err := tx.Create(&model.Setting{Key: "SystemStatus", Value: "Free"}).Error; err != nil {
tx.Rollback()
return err return err
} }
if err := tx.Create(&model.Setting{Key: "AppStoreVersion", Value: ""}).Error; err != nil { if err := tx.Create(&model.Setting{Key: "AppStoreVersion", Value: ""}).Error; err != nil {
@ -236,8 +235,15 @@ var AddDefaultGroup = &gormigrate.Migration{
IsDefault: true, IsDefault: true,
Type: "website", Type: "website",
} }
tx.Create(defaultGroup) if err := tx.Create(defaultGroup).Error; err != nil {
tx.Debug().Model(&model.Website{}).Where("1 = 1").Update("website_group_id", defaultGroup.ID) 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") return tx.Migrator().DropTable("website_groups")
}, },
} }

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

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

Loading…
Cancel
Save