From 22358e161f239339ad8b5d35022a2f2f4797824c Mon Sep 17 00:00:00 2001 From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com> Date: Wed, 29 Nov 2023 10:48:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AF=81=E4=B9=A6=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=A4=87=E6=B3=A8=20(#3092)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/dto/request/website_ssl.go | 5 ++--- backend/app/service/website_ssl.go | 11 +++++++++- frontend/src/api/interface/website.ts | 4 ++++ .../src/views/website/ssl/create/index.vue | 9 ++++++-- frontend/src/views/website/ssl/index.vue | 22 +++++++++++++++++-- 5 files changed, 43 insertions(+), 8 deletions(-) diff --git a/backend/app/dto/request/website_ssl.go b/backend/app/dto/request/website_ssl.go index d9f9fdbf1..9ec8fc6a9 100644 --- a/backend/app/dto/request/website_ssl.go +++ b/backend/app/dto/request/website_ssl.go @@ -18,6 +18,8 @@ type WebsiteSSLCreate struct { Apply bool `json:"apply"` PushDir bool `json:"pushDir"` Dir string `json:"dir"` + ID uint `json:"id"` + Description string `json:"description"` } type WebsiteDNSReq struct { @@ -66,9 +68,6 @@ type WebsiteSSLUpdate struct { ID uint `json:"id" validate:"required"` AutoRenew bool `json:"autoRenew"` Description string `json:"description"` - PrivateKey string `json:"privateKey"` - Certificate string `json:"certificate"` - Type string `json:"type" validate:"required,oneof=autoRenew description certificate privateKey"` } type WebsiteSSLUpload struct { diff --git a/backend/app/service/website_ssl.go b/backend/app/service/website_ssl.go index 3c38b35aa..9b66ccd39 100644 --- a/backend/app/service/website_ssl.go +++ b/backend/app/service/website_ssl.go @@ -115,6 +115,7 @@ func (w WebsiteSSLService) Create(create request.WebsiteSSLCreate) (request.Webs ExpireDate: time.Now(), KeyType: create.KeyType, PushDir: create.PushDir, + Description: create.Description, } if create.PushDir { if !files.NewFileOp().Stat(create.Dir) { @@ -150,7 +151,14 @@ func (w WebsiteSSLService) Create(create request.WebsiteSSLCreate) (request.Webs if err := websiteSSLRepo.Create(context.TODO(), &websiteSSL); err != nil { return res, err } - + create.ID = websiteSSL.ID + go func() { + if err = w.ObtainSSL(request.WebsiteSSLApply{ + ID: websiteSSL.ID, + }); err != nil { + global.LOG.Errorf("obtain ssl failed, err: %v", err) + } + }() return create, nil } @@ -343,6 +351,7 @@ func (w WebsiteSSLService) Update(update request.WebsiteSSLUpdate) error { return err } websiteSSL.AutoRenew = update.AutoRenew + websiteSSL.Description = update.Description return websiteSSLRepo.Save(websiteSSL) } diff --git a/frontend/src/api/interface/website.ts b/frontend/src/api/interface/website.ts index 493f6ae34..badf3e902 100644 --- a/frontend/src/api/interface/website.ts +++ b/frontend/src/api/interface/website.ts @@ -166,6 +166,7 @@ export namespace Website { acmeAccountId?: number; status: string; domains: string; + description: string; } export interface SSLDTO extends SSL { @@ -178,6 +179,8 @@ export namespace Website { provider: string; acmeAccountId: number; dnsAccountId: number; + id?: number; + description: string; } export interface SSLApply { @@ -192,6 +195,7 @@ export namespace Website { export interface SSLUpdate { id: number; autoRenew: boolean; + description: string; } export interface AcmeAccount extends CommonModel { diff --git a/frontend/src/views/website/ssl/create/index.vue b/frontend/src/views/website/ssl/create/index.vue index f96fc1816..42692f1cb 100644 --- a/frontend/src/views/website/ssl/create/index.vue +++ b/frontend/src/views/website/ssl/create/index.vue @@ -16,6 +16,9 @@ v-model="ssl.otherDomains" > + + + ({ keyType: 'P256', pushDir: false, dir: '', + description: '', }); const ssl = ref(initData()); const dnsResolve = ref([]); -const em = defineEmits(['close']); +const em = defineEmits(['close', 'submit']); const handleClose = () => { resetForm(); open.value = false; @@ -211,8 +215,9 @@ const submit = async (formEl: FormInstance | undefined) => { } loading.value = true; CreateSSL(ssl.value) - .then(() => { + .then((res: any) => { handleClose(); + em('submit', res.data.id); MsgSuccess(i18n.global.t('commons.msg.createSuccess')); }) .finally(() => { diff --git a/frontend/src/views/website/ssl/index.vue b/frontend/src/views/website/ssl/index.vue index cf71c26b8..0688e207a 100644 --- a/frontend/src/views/website/ssl/index.vue +++ b/frontend/src/views/website/ssl/index.vue @@ -109,6 +109,18 @@ show-overflow-tooltip prop="organization" > + + +