mirror of
https://gitee.com/fit2cloud-feizhiyun/1Panel.git
synced 2024-12-02 20:08:03 +08:00
feat: 证书列表增加设置自动续签功能 (#337)
This commit is contained in:
parent
f516333682
commit
72237596f3
@ -449,7 +449,7 @@ func (b *BaseApi) Download(c *gin.Context) {
|
||||
// @Summary Download file with path
|
||||
// @Description 下载指定文件
|
||||
// @Accept json
|
||||
// @Param request body request.FilePath true "request"
|
||||
// @Param request body dto.FilePath true "request"
|
||||
// @Success 200
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /files/download/bypath [post]
|
||||
|
@ -176,3 +176,25 @@ func (b *BaseApi) GetWebsiteSSLById(c *gin.Context) {
|
||||
}
|
||||
helper.SuccessWithData(c, websiteSSL)
|
||||
}
|
||||
|
||||
// @Tags Website SSL
|
||||
// @Summary Update ssl
|
||||
// @Description 更新 ssl
|
||||
// @Accept json
|
||||
// @Param request body request.WebsiteSSLUpdate true "request"
|
||||
// @Success 200
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /websites/ssl/update [post]
|
||||
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFuntions":[{"input_colume":"id","input_value":"id","isList":false,"db":"website_ssls","output_colume":"primary_domain","output_value":"domain"}],"formatZH":"更新证书设置 [domain]","formatEN":"Update ssl config [domain]"}
|
||||
func (b *BaseApi) UpdateWebsiteSSL(c *gin.Context) {
|
||||
var req request.WebsiteSSLUpdate
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
||||
return
|
||||
}
|
||||
if err := websiteSSLService.Update(req); err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||
return
|
||||
}
|
||||
helper.SuccessWithData(c, nil)
|
||||
}
|
||||
|
@ -44,3 +44,8 @@ type WebsiteDnsAccountUpdate struct {
|
||||
type WebsiteResourceReq struct {
|
||||
ID uint `json:"id" validate:"required"`
|
||||
}
|
||||
|
||||
type WebsiteSSLUpdate struct {
|
||||
ID uint `json:"id" validate:"required"`
|
||||
AutoRenew bool `json:"autoRenew" validate:"required"`
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ type IWebsiteSSLService interface {
|
||||
GetDNSResolve(req request.WebsiteDNSReq) ([]response.WebsiteDNSRes, error)
|
||||
GetWebsiteSSL(websiteId uint) (response.WebsiteSSLDTO, error)
|
||||
Delete(id uint) error
|
||||
Update(update request.WebsiteSSLUpdate) error
|
||||
}
|
||||
|
||||
func NewIWebsiteSSLService() IWebsiteSSLService {
|
||||
@ -132,6 +133,7 @@ func (w WebsiteSSLService) Create(create request.WebsiteSSLCreate) (request.Webs
|
||||
websiteSSL.StartDate = cert.NotBefore
|
||||
websiteSSL.Type = cert.Issuer.CommonName
|
||||
websiteSSL.Organization = cert.Issuer.Organization[0]
|
||||
websiteSSL.AutoRenew = create.AutoRenew
|
||||
|
||||
if err := websiteSSLRepo.Create(context.TODO(), &websiteSSL); err != nil {
|
||||
return res, err
|
||||
@ -258,3 +260,12 @@ func (w WebsiteSSLService) Delete(id uint) error {
|
||||
}
|
||||
return websiteSSLRepo.DeleteBy(commonRepo.WithByID(id))
|
||||
}
|
||||
|
||||
func (w WebsiteSSLService) Update(update request.WebsiteSSLUpdate) error {
|
||||
websiteSSL, err := websiteSSLRepo.GetFirst(commonRepo.WithByID(update.ID))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
websiteSSL.AutoRenew = update.AutoRenew
|
||||
return websiteSSLRepo.Save(websiteSSL)
|
||||
}
|
||||
|
@ -22,5 +22,6 @@ func (a *WebsiteSSLRouter) InitWebsiteSSLRouter(Router *gin.RouterGroup) {
|
||||
groupRouter.POST("/del", baseApi.DeleteWebsiteSSL)
|
||||
groupRouter.GET("/website/:websiteId", baseApi.GetWebsiteSSLByWebsiteId)
|
||||
groupRouter.GET("/:id", baseApi.GetWebsiteSSLById)
|
||||
groupRouter.POST("/update", baseApi.UpdateWebsiteSSL)
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -160,6 +160,7 @@ export namespace Website {
|
||||
startDate: string;
|
||||
provider: string;
|
||||
websites?: Website.Website[];
|
||||
autoRenew: boolean;
|
||||
}
|
||||
|
||||
export interface SSLCreate {
|
||||
@ -179,6 +180,11 @@ export namespace Website {
|
||||
SSLId: number;
|
||||
}
|
||||
|
||||
export interface SSLUpdate {
|
||||
id: number;
|
||||
autoRenew: boolean;
|
||||
}
|
||||
|
||||
export interface AcmeAccount extends CommonModel {
|
||||
email: string;
|
||||
url: string;
|
||||
|
@ -139,6 +139,10 @@ export const RenewSSL = (req: Website.SSLRenew) => {
|
||||
return http.post<any>(`/websites/ssl/renew`, req);
|
||||
};
|
||||
|
||||
export const UpdateSSL = (req: Website.SSLUpdate) => {
|
||||
return http.post<any>(`/websites/ssl/update`, req);
|
||||
};
|
||||
|
||||
export const GetDnsResolve = (req: Website.DNSResolveReq) => {
|
||||
return http.post<Website.DNSResolve[]>(`/websites/ssl/resolve`, req);
|
||||
};
|
||||
|
@ -50,6 +50,15 @@
|
||||
show-overflow-tooltip
|
||||
prop="type"
|
||||
></el-table-column>
|
||||
<el-table-column :label="$t('ssl.autoRenew')" fix>
|
||||
<template #default="{ row }">
|
||||
<el-switch
|
||||
:disabled="row.provider === 'dnsManual' || row.provider === 'manual'"
|
||||
v-model="row.autoRenew"
|
||||
@change="updateConfig(row)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="expireDate"
|
||||
:label="$t('website.expireDate')"
|
||||
@ -79,7 +88,7 @@ import LayoutContent from '@/layout/layout-content.vue';
|
||||
import RouterButton from '@/components/router-button/index.vue';
|
||||
import ComplexTable from '@/components/complex-table/index.vue';
|
||||
import { onMounted, reactive, ref } from 'vue';
|
||||
import { DeleteSSL, SearchSSL } from '@/api/modules/website';
|
||||
import { DeleteSSL, SearchSSL, UpdateSSL } from '@/api/modules/website';
|
||||
import DnsAccount from './dns-account/index.vue';
|
||||
import AcmeAccount from './acme-account/index.vue';
|
||||
import Renew from './renew/index.vue';
|
||||
@ -89,6 +98,7 @@ import { dateFormat, getProvider } from '@/utils/util';
|
||||
import i18n from '@/lang';
|
||||
import { Website } from '@/api/interface/website';
|
||||
import { useDeleteData } from '@/hooks/use-delete-data';
|
||||
import { MsgSuccess } from '@/utils/message';
|
||||
|
||||
const paginationConfig = reactive({
|
||||
currentPage: 1,
|
||||
@ -150,6 +160,17 @@ const search = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const updateConfig = (row: Website.SSL) => {
|
||||
loading.value = true;
|
||||
UpdateSSL({ id: row.id, autoRenew: row.autoRenew })
|
||||
.then(() => {
|
||||
MsgSuccess(i18n.global.t('commons.msg.updateSuccess'));
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
};
|
||||
|
||||
const openAcmeAccount = () => {
|
||||
acmeAccountRef.value.acceptParams();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user