refactor: clean code

This commit is contained in:
Fu Diwei
2025-01-22 22:11:04 +08:00
parent 7a2fc5e2fd
commit b67049f9aa
3 changed files with 6 additions and 22 deletions

View File

@@ -5,11 +5,6 @@ type CertificateArchiveFileReq struct {
Format string `json:"format"`
}
type CertificateArchiveFileResp struct {
Certificate string `json:"certificate"`
PrivateKey string `json:"privateKey"`
}
type CertificateValidateCertificateReq struct {
Certificate string `json:"certificate"`
}

View File

@@ -26,12 +26,12 @@ func NewCertificateHandler(router *router.RouterGroup[*core.RequestEvent], servi
}
group := router.Group("/certificates")
group.POST("/{certificateId}/archive", handler.archive)
group.POST("/{certificateId}/archive", handler.archiveFile)
group.POST("/validate/certificate", handler.validateCertificate)
group.POST("/validate/private-key", handler.validatePrivateKey)
}
func (handler *CertificateHandler) archive(e *core.RequestEvent) error {
func (handler *CertificateHandler) archiveFile(e *core.RequestEvent) error {
req := &dtos.CertificateArchiveFileReq{}
req.CertificateId = e.Request.PathValue("certificateId")
if err := e.BindBody(req); err != nil {
@@ -50,6 +50,7 @@ func (handler *CertificateHandler) validateCertificate(e *core.RequestEvent) err
if err := e.BindBody(req); err != nil {
return resp.Err(e, err)
}
if rs, err := handler.service.ValidateCertificate(e.Request.Context(), req); err != nil {
return resp.Err(e, err)
} else {
@@ -62,6 +63,7 @@ func (handler *CertificateHandler) validatePrivateKey(e *core.RequestEvent) erro
if err := e.BindBody(req); err != nil {
return resp.Err(e, err)
}
if err := handler.service.ValidatePrivateKey(e.Request.Context(), req); err != nil {
return resp.Err(e, err)
} else {