From 716b30d169c0482046c44bb80c6b1b395ed0d09d Mon Sep 17 00:00:00 2001 From: zhengkunwang223 Date: Mon, 20 Feb 2023 17:09:40 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20dns=20=E8=B4=A6=E5=8F=B7=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=90=8D=E7=A7=B0=E6=A0=A1=E9=AA=8C=EF=BC=8C=E6=9F=A5?= =?UTF-8?q?=E7=9C=8B=E5=AF=86=E9=92=A5=E6=94=B9=E4=B8=BA=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/repo/website_dns_account.go | 6 +++--- backend/app/service/website_dns_account.go | 5 +++++ .../views/website/ssl/dns-account/create/index.vue | 12 ++++++------ .../src/views/website/ssl/dns-account/index.vue | 13 +++++++------ 4 files changed, 21 insertions(+), 15 deletions(-) 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 }} - - -