From a4e6ca01a7096271e862a6a8bba2a39e35238246 Mon Sep 17 00:00:00 2001 From: zhengkunwang223 Date: Thu, 29 Dec 2022 14:55:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AF=81=E4=B9=A6=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/api/v1/website_ssl.go | 16 ++++- backend/app/service/website_ssl.go | 10 +++ backend/router/ro_website_ssl.go | 3 +- frontend/src/api/modules/website.ts | 6 +- frontend/src/lang/modules/zh.ts | 6 ++ .../src/views/website/ssl/create/index.vue | 1 + .../src/views/website/ssl/detail/index.vue | 66 +++++++++++++++++++ frontend/src/views/website/ssl/index.vue | 18 ++++- .../website/config/basic/https/index.vue | 3 +- 9 files changed, 121 insertions(+), 8 deletions(-) create mode 100644 frontend/src/views/website/ssl/detail/index.vue diff --git a/backend/app/api/v1/website_ssl.go b/backend/app/api/v1/website_ssl.go index 152fd0c52..67be17d4f 100644 --- a/backend/app/api/v1/website_ssl.go +++ b/backend/app/api/v1/website_ssl.go @@ -89,7 +89,7 @@ func (b *BaseApi) DeleteWebsiteSSL(c *gin.Context) { helper.SuccessWithData(c, nil) } -func (b *BaseApi) GetWebsiteSSL(c *gin.Context) { +func (b *BaseApi) GetWebsiteSSLByWebsiteId(c *gin.Context) { websiteId, err := helper.GetIntParamByKey(c, "websiteId") if err != nil { helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err) @@ -102,3 +102,17 @@ func (b *BaseApi) GetWebsiteSSL(c *gin.Context) { } helper.SuccessWithData(c, websiteSSL) } + +func (b *BaseApi) GetWebsiteSSLById(c *gin.Context) { + id, err := helper.GetParamID(c) + if err != nil { + helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err) + return + } + websiteSSL, err := websiteSSLService.GetSSL(id) + if err != nil { + helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) + return + } + helper.SuccessWithData(c, websiteSSL) +} diff --git a/backend/app/service/website_ssl.go b/backend/app/service/website_ssl.go index 444a137e1..26262bdfd 100644 --- a/backend/app/service/website_ssl.go +++ b/backend/app/service/website_ssl.go @@ -31,6 +31,16 @@ func (w WebsiteSSLService) Page(search request.WebsiteSSLSearch) (int64, []respo return total, sslDTOs, err } +func (w WebsiteSSLService) GetSSL(id uint) (*response.WebsiteSSLDTO, error) { + var res response.WebsiteSSLDTO + websiteSSL, err := websiteSSLRepo.GetFirst(commonRepo.WithByID(id)) + if err != nil { + return nil, err + } + res.WebsiteSSL = websiteSSL + return &res, nil +} + func (w WebsiteSSLService) Search() ([]response.WebsiteSSLDTO, error) { sslList, err := websiteSSLRepo.List() if err != nil { diff --git a/backend/router/ro_website_ssl.go b/backend/router/ro_website_ssl.go index 2305d052d..b13626af2 100644 --- a/backend/router/ro_website_ssl.go +++ b/backend/router/ro_website_ssl.go @@ -20,6 +20,7 @@ func (a *WebsiteSSLRouter) InitWebsiteSSLRouter(Router *gin.RouterGroup) { groupRouter.POST("", baseApi.CreateWebsiteSSL) groupRouter.POST("/resolve", baseApi.GetDNSResolve) groupRouter.POST("/del", baseApi.DeleteWebsiteSSL) - groupRouter.GET("/:websiteId", baseApi.GetWebsiteSSL) + groupRouter.GET("/website/:websiteId", baseApi.GetWebsiteSSLByWebsiteId) + groupRouter.GET("/:id", baseApi.GetWebsiteSSLById) } } diff --git a/frontend/src/api/modules/website.ts b/frontend/src/api/modules/website.ts index 7a8218d09..501c514aa 100644 --- a/frontend/src/api/modules/website.ts +++ b/frontend/src/api/modules/website.ts @@ -128,7 +128,11 @@ export const DeleteSSL = (req: Website.DelReq) => { }; export const GetWebsiteSSL = (websiteId: number) => { - return http.get(`/websites/ssl/${websiteId}`); + return http.get(`/websites/ssl/website/${websiteId}`); +}; + +export const GetSSL = (id: number) => { + return http.get(`/websites/ssl/${id}`); }; export const ApplySSL = (req: Website.SSLApply) => { diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 7568787bf..8895060d2 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -971,6 +971,12 @@ export default { err: '错误', value: '记录值', type: '类型', + dnsResolveHelper: '请到DNS解析服务商处添加以下解析记录:', + detail: '详情', + msg: '证书信息', + ssl: '证书', + key: '私钥', + startDate: '生效时间', }, firewall: { ccDeny: 'CC 防护', diff --git a/frontend/src/views/website/ssl/create/index.vue b/frontend/src/views/website/ssl/create/index.vue index 57ecaec20..1e8c697e8 100644 --- a/frontend/src/views/website/ssl/create/index.vue +++ b/frontend/src/views/website/ssl/create/index.vue @@ -49,6 +49,7 @@ + {{ $t('ssl.dnsResolveHelper') }}
{{ re.domain }} diff --git a/frontend/src/views/website/ssl/detail/index.vue b/frontend/src/views/website/ssl/detail/index.vue new file mode 100644 index 000000000..b589ac0f6 --- /dev/null +++ b/frontend/src/views/website/ssl/detail/index.vue @@ -0,0 +1,66 @@ + + diff --git a/frontend/src/views/website/ssl/index.vue b/frontend/src/views/website/ssl/index.vue index 9af266181..19d9f6e51 100644 --- a/frontend/src/views/website/ssl/index.vue +++ b/frontend/src/views/website/ssl/index.vue @@ -48,7 +48,7 @@ show-overflow-tooltip /> + @@ -72,6 +73,7 @@ import DnsAccount from './dns-account/index.vue'; import AcmeAccount from './acme-account/index.vue'; import Renew from './renew/index.vue'; import Create from './create/index.vue'; +import Detail from './detail/index.vue'; import { dateFromat } from '@/utils/util'; import i18n from '@/lang'; import { Website } from '@/api/interface/website'; @@ -86,19 +88,26 @@ const acmeAccountRef = ref(); const dnsAccountRef = ref(); const sslCreateRef = ref(); const renewRef = ref(); +const detailRef = ref(); let data = ref(); let loading = ref(false); const buttons = [ + { + label: i18n.global.t('ssl.detail'), + click: function (row: Website.SSL) { + openDetail(row.id); + }, + }, { label: i18n.global.t('website.renewSSL'), - click: function (row: Website.Website) { + click: function (row: Website.SSL) { openRenewSSL(row.id); }, }, { label: i18n.global.t('app.delete'), - click: function (row: Website.Website) { + click: function (row: Website.SSL) { deleteSSL(row.id); }, }, @@ -132,6 +141,9 @@ const openSSL = () => { const openRenewSSL = (id: number) => { renewRef.value.acceptParams(id); }; +const openDetail = (id: number) => { + detailRef.value.acceptParams(id); +}; const deleteSSL = async (id: number) => { loading.value = true; diff --git a/frontend/src/views/website/website/config/basic/https/index.vue b/frontend/src/views/website/website/config/basic/https/index.vue index f8d506145..851289ea2 100644 --- a/frontend/src/views/website/website/config/basic/https/index.vue +++ b/frontend/src/views/website/website/config/basic/https/index.vue @@ -1,6 +1,6 @@