diff --git a/backend/app/repo/website_dns_account.go b/backend/app/repo/website_dns_account.go index f062edf4e..f934c5cd9 100644 --- a/backend/app/repo/website_dns_account.go +++ b/backend/app/repo/website_dns_account.go @@ -16,13 +16,13 @@ func (w WebsiteDnsAccountRepo) Page(page, size int, opts ...DBOption) (int64, [] return count, accounts, err } -func (w WebsiteDnsAccountRepo) GetFirst(opts ...DBOption) (model.WebsiteDnsAccount, error) { +func (w WebsiteDnsAccountRepo) GetFirst(opts ...DBOption) (*model.WebsiteDnsAccount, error) { var account model.WebsiteDnsAccount db := getDb(opts...).Model(&model.WebsiteDnsAccount{}) if err := db.First(&account).Error; err != nil { - return account, err + return nil, err } - return account, nil + return &account, nil } func (w WebsiteDnsAccountRepo) Create(account model.WebsiteDnsAccount) error { diff --git a/backend/app/service/website_dns_account.go b/backend/app/service/website_dns_account.go index e100415c7..702feca7d 100644 --- a/backend/app/service/website_dns_account.go +++ b/backend/app/service/website_dns_account.go @@ -28,6 +28,11 @@ func (w WebsiteDnsAccountService) Page(search dto.PageInfo) (int64, []response.W } func (w WebsiteDnsAccountService) Create(create request.WebsiteDnsAccountCreate) (request.WebsiteDnsAccountCreate, error) { + exist, _ := websiteDnsRepo.GetFirst(commonRepo.WithByName(create.Name)) + if exist != nil { + return request.WebsiteDnsAccountCreate{}, buserr.New(constant.ErrNameIsExist) + } + authorization, err := json.Marshal(create.Authorization) if err != nil { return request.WebsiteDnsAccountCreate{}, err diff --git a/frontend/src/views/website/ssl/dns-account/create/index.vue b/frontend/src/views/website/ssl/dns-account/create/index.vue index 5c88efd93..9a0385781 100644 --- a/frontend/src/views/website/ssl/dns-account/create/index.vue +++ b/frontend/src/views/website/ssl/dns-account/create/index.vue @@ -11,7 +11,7 @@ - + @@ -79,14 +79,14 @@ const accountData = ref({ }); const types = [ - { - label: 'DnsPod', - value: 'DnsPod', - }, { label: i18n.global.t('website.aliyun'), value: 'AliYun', }, + { + label: 'DnsPod', + value: 'DnsPod', + }, { label: 'CloudFlare', value: 'CloudFlare', @@ -111,7 +111,7 @@ let rules = ref({ let account = ref({ id: 0, name: '', - type: 'DnsPod', + type: 'AliYun', authorization: {}, }); const em = defineEmits(['close']); diff --git a/frontend/src/views/website/ssl/dns-account/index.vue b/frontend/src/views/website/ssl/dns-account/index.vue index 67a5cfed9..df35a6429 100644 --- a/frontend/src/views/website/ssl/dns-account/index.vue +++ b/frontend/src/views/website/ssl/dns-account/index.vue @@ -16,11 +16,6 @@ {{ row.type }} - - -