refactor: clean code

This commit is contained in:
Fu Diwei
2025-01-19 03:34:38 +08:00
parent ce4c590b1c
commit c1f77dd92f
17 changed files with 50 additions and 43 deletions

View File

@@ -6,12 +6,12 @@ import (
"github.com/pocketbase/pocketbase/core"
"github.com/pocketbase/pocketbase/tools/router"
"github.com/usual2970/certimate/internal/domain"
"github.com/usual2970/certimate/internal/domain/dtos"
"github.com/usual2970/certimate/internal/rest/resp"
)
type certificateService interface {
ArchiveFile(ctx context.Context, req *domain.CertificateArchiveFileReq) ([]byte, error)
ArchiveFile(ctx context.Context, req *dtos.CertificateArchiveFileReq) ([]byte, error)
}
type CertificateHandler struct {
@@ -28,7 +28,7 @@ func NewCertificateHandler(router *router.RouterGroup[*core.RequestEvent], servi
}
func (handler *CertificateHandler) run(e *core.RequestEvent) error {
req := &domain.CertificateArchiveFileReq{}
req := &dtos.CertificateArchiveFileReq{}
req.CertificateId = e.Request.PathValue("id")
if err := e.BindBody(req); err != nil {
return resp.Err(e, err)

View File

@@ -6,12 +6,12 @@ import (
"github.com/pocketbase/pocketbase/core"
"github.com/pocketbase/pocketbase/tools/router"
"github.com/usual2970/certimate/internal/domain"
"github.com/usual2970/certimate/internal/domain/dtos"
"github.com/usual2970/certimate/internal/rest/resp"
)
type notifyService interface {
Test(ctx context.Context, req *domain.NotifyTestPushReq) error
Test(ctx context.Context, req *dtos.NotifyTestPushReq) error
}
type NotifyHandler struct {
@@ -28,7 +28,7 @@ func NewNotifyHandler(router *router.RouterGroup[*core.RequestEvent], service no
}
func (handler *NotifyHandler) test(e *core.RequestEvent) error {
req := &domain.NotifyTestPushReq{}
req := &dtos.NotifyTestPushReq{}
if err := e.BindBody(req); err != nil {
return resp.Err(e, err)
}

View File

@@ -6,12 +6,12 @@ import (
"github.com/pocketbase/pocketbase/core"
"github.com/pocketbase/pocketbase/tools/router"
"github.com/usual2970/certimate/internal/domain"
"github.com/usual2970/certimate/internal/domain/dtos"
"github.com/usual2970/certimate/internal/rest/resp"
)
type workflowService interface {
Run(ctx context.Context, req *domain.WorkflowRunReq) error
Run(ctx context.Context, req *dtos.WorkflowRunReq) error
Stop(ctx context.Context)
}
@@ -29,7 +29,7 @@ func NewWorkflowHandler(router *router.RouterGroup[*core.RequestEvent], service
}
func (handler *WorkflowHandler) run(e *core.RequestEvent) error {
req := &domain.WorkflowRunReq{}
req := &dtos.WorkflowRunReq{}
req.WorkflowId = e.Request.PathValue("id")
if err := e.BindBody(req); err != nil {
return resp.Err(e, err)