code refactor

This commit is contained in:
MaysWind
2024-08-19 00:31:32 +08:00
parent 6fcb0a2b3c
commit e86d4e05ce
73 changed files with 1404 additions and 1344 deletions
+7 -6
View File
@@ -7,6 +7,7 @@ import (
"github.com/urfave/cli/v2"
"github.com/mayswind/ezbookkeeping/pkg/core"
"github.com/mayswind/ezbookkeeping/pkg/errs"
"github.com/mayswind/ezbookkeeping/pkg/mail"
"github.com/mayswind/ezbookkeeping/pkg/requestid"
@@ -21,7 +22,7 @@ var Utilities = &cli.Command{
{
Name: "parse-default-request-id",
Usage: "Parse a request id which is generated by default request generator and show the details",
Action: parseRequestId,
Action: bindAction(parseRequestId),
Flags: []cli.Flag{
&cli.StringFlag{
Name: "id",
@@ -33,7 +34,7 @@ var Utilities = &cli.Command{
{
Name: "send-test-mail",
Usage: "Send an email to specified e-mail address",
Action: sendTestMail,
Action: bindAction(sendTestMail),
Flags: []cli.Flag{
&cli.StringFlag{
Name: "to",
@@ -45,15 +46,15 @@ var Utilities = &cli.Command{
},
}
func parseRequestId(c *cli.Context) error {
func parseRequestId(c *core.CliContext) error {
config, err := initializeSystem(c)
if err != nil {
return err
}
err = requestid.InitializeRequestIdGenerator(config)
defaultGenerator, err := requestid.NewDefaultRequestIdGenerator(config)
err = requestid.InitializeRequestIdGenerator(c, config)
defaultGenerator, err := requestid.NewDefaultRequestIdGenerator(c, config)
if err != nil {
return err
@@ -73,7 +74,7 @@ func parseRequestId(c *cli.Context) error {
return nil
}
func sendTestMail(c *cli.Context) error {
func sendTestMail(c *core.CliContext) error {
config, err := initializeSystem(c)
if err != nil {