mirror of
https://github.com/woodchen-ink/certimate.git
synced 2025-07-18 09:21:56 +08:00
refactor: clean code
This commit is contained in:
parent
7a2fc5e2fd
commit
b67049f9aa
@ -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"`
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -52,9 +52,6 @@ const UploadNodeConfigForm = forwardRef<UploadNodeConfigFormInstance, UploadNode
|
||||
initialValues: initialValues ?? initFormModel(),
|
||||
});
|
||||
|
||||
const fieldCertificate = Form.useWatch("certificate", formInst);
|
||||
const fieldPrivateKey = Form.useWatch("privateKey", formInst);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values as UploadNodeConfigFormFieldValues);
|
||||
};
|
||||
@ -144,12 +141,7 @@ const UploadNodeConfigForm = forwardRef<UploadNodeConfigFormInstance, UploadNode
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="certificate" label={t("workflow_node.upload.form.certificate.label")} rules={[formRule]}>
|
||||
<Input.TextArea
|
||||
readOnly
|
||||
autoSize={{ minRows: 5, maxRows: 10 }}
|
||||
placeholder={t("workflow_node.upload.form.certificate.placeholder")}
|
||||
value={fieldCertificate}
|
||||
/>
|
||||
<Input.TextArea readOnly autoSize={{ minRows: 5, maxRows: 10 }} placeholder={t("workflow_node.upload.form.certificate.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item>
|
||||
@ -159,12 +151,7 @@ const UploadNodeConfigForm = forwardRef<UploadNodeConfigFormInstance, UploadNode
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="privateKey" label={t("workflow_node.upload.form.private_key.label")} rules={[formRule]}>
|
||||
<Input.TextArea
|
||||
readOnly
|
||||
autoSize={{ minRows: 5, maxRows: 10 }}
|
||||
placeholder={t("workflow_node.upload.form.private_key.placeholder")}
|
||||
value={fieldPrivateKey}
|
||||
/>
|
||||
<Input.TextArea readOnly autoSize={{ minRows: 5, maxRows: 10 }} placeholder={t("workflow_node.upload.form.private_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user