mirror of
https://github.com/usual2970/certimate.git
synced 2025-06-08 21:49:52 +00:00
refactor: clean code
This commit is contained in:
parent
d7bff599b7
commit
d509445519
@ -14,7 +14,7 @@ var scheduler *cron.Cron
|
|||||||
func GetScheduler() *cron.Cron {
|
func GetScheduler() *cron.Cron {
|
||||||
schedulerOnce.Do(func() {
|
schedulerOnce.Do(func() {
|
||||||
scheduler = cron.New()
|
scheduler = cron.New()
|
||||||
location, err := time.LoadLocation("Asia/Shanghai")
|
location, err := time.LoadLocation("Local")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
scheduler.SetTimezone(location)
|
scheduler.SetTimezone(location)
|
||||||
}
|
}
|
@ -12,11 +12,6 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/usual2970/certimate/internal/domain"
|
|
||||||
"github.com/usual2970/certimate/internal/pkg/utils/x509"
|
|
||||||
"github.com/usual2970/certimate/internal/repository"
|
|
||||||
"github.com/usual2970/certimate/internal/utils/app"
|
|
||||||
|
|
||||||
"github.com/go-acme/lego/v4/certcrypto"
|
"github.com/go-acme/lego/v4/certcrypto"
|
||||||
"github.com/go-acme/lego/v4/certificate"
|
"github.com/go-acme/lego/v4/certificate"
|
||||||
"github.com/go-acme/lego/v4/challenge"
|
"github.com/go-acme/lego/v4/challenge"
|
||||||
@ -24,6 +19,11 @@ import (
|
|||||||
"github.com/go-acme/lego/v4/lego"
|
"github.com/go-acme/lego/v4/lego"
|
||||||
"github.com/go-acme/lego/v4/registration"
|
"github.com/go-acme/lego/v4/registration"
|
||||||
"github.com/pocketbase/pocketbase/models"
|
"github.com/pocketbase/pocketbase/models"
|
||||||
|
|
||||||
|
"github.com/usual2970/certimate/internal/app"
|
||||||
|
"github.com/usual2970/certimate/internal/domain"
|
||||||
|
"github.com/usual2970/certimate/internal/pkg/utils/x509"
|
||||||
|
"github.com/usual2970/certimate/internal/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -6,10 +6,10 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/usual2970/certimate/internal/app"
|
||||||
"github.com/usual2970/certimate/internal/domain"
|
"github.com/usual2970/certimate/internal/domain"
|
||||||
"github.com/usual2970/certimate/internal/notify"
|
"github.com/usual2970/certimate/internal/notify"
|
||||||
"github.com/usual2970/certimate/internal/repository"
|
"github.com/usual2970/certimate/internal/repository"
|
||||||
"github.com/usual2970/certimate/internal/utils/app"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -6,9 +6,9 @@ import (
|
|||||||
|
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
|
|
||||||
|
"github.com/usual2970/certimate/internal/app"
|
||||||
"github.com/usual2970/certimate/internal/pkg/core/notifier"
|
"github.com/usual2970/certimate/internal/pkg/core/notifier"
|
||||||
"github.com/usual2970/certimate/internal/pkg/utils/maps"
|
"github.com/usual2970/certimate/internal/pkg/utils/maps"
|
||||||
"github.com/usual2970/certimate/internal/utils/app"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func SendToAllChannels(subject, message string) error {
|
func SendToAllChannels(subject, message string) error {
|
||||||
|
@ -5,8 +5,8 @@ import (
|
|||||||
"database/sql"
|
"database/sql"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
|
"github.com/usual2970/certimate/internal/app"
|
||||||
"github.com/usual2970/certimate/internal/domain"
|
"github.com/usual2970/certimate/internal/domain"
|
||||||
"github.com/usual2970/certimate/internal/utils/app"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type AccessRepository struct{}
|
type AccessRepository struct{}
|
||||||
|
@ -6,9 +6,10 @@ import (
|
|||||||
"github.com/go-acme/lego/v4/registration"
|
"github.com/go-acme/lego/v4/registration"
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/dbx"
|
||||||
"github.com/pocketbase/pocketbase/models"
|
"github.com/pocketbase/pocketbase/models"
|
||||||
"github.com/usual2970/certimate/internal/domain"
|
|
||||||
"github.com/usual2970/certimate/internal/utils/app"
|
|
||||||
"golang.org/x/sync/singleflight"
|
"golang.org/x/sync/singleflight"
|
||||||
|
|
||||||
|
"github.com/usual2970/certimate/internal/app"
|
||||||
|
"github.com/usual2970/certimate/internal/domain"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AcmeAccountRepository struct{}
|
type AcmeAccountRepository struct{}
|
||||||
|
@ -3,8 +3,8 @@ package repository
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"github.com/usual2970/certimate/internal/app"
|
||||||
"github.com/usual2970/certimate/internal/domain"
|
"github.com/usual2970/certimate/internal/domain"
|
||||||
"github.com/usual2970/certimate/internal/utils/app"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type CertificateRepository struct{}
|
type CertificateRepository struct{}
|
||||||
|
@ -3,8 +3,8 @@ package repository
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"github.com/usual2970/certimate/internal/app"
|
||||||
"github.com/usual2970/certimate/internal/domain"
|
"github.com/usual2970/certimate/internal/domain"
|
||||||
"github.com/usual2970/certimate/internal/utils/app"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type SettingRepository struct{}
|
type SettingRepository struct{}
|
||||||
|
@ -3,8 +3,8 @@ package repository
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"github.com/usual2970/certimate/internal/app"
|
||||||
"github.com/usual2970/certimate/internal/domain"
|
"github.com/usual2970/certimate/internal/domain"
|
||||||
"github.com/usual2970/certimate/internal/utils/app"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type StatisticsRepository struct{}
|
type StatisticsRepository struct{}
|
||||||
|
@ -7,8 +7,8 @@ import (
|
|||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/dbx"
|
||||||
"github.com/pocketbase/pocketbase/models"
|
"github.com/pocketbase/pocketbase/models"
|
||||||
|
"github.com/usual2970/certimate/internal/app"
|
||||||
"github.com/usual2970/certimate/internal/domain"
|
"github.com/usual2970/certimate/internal/domain"
|
||||||
"github.com/usual2970/certimate/internal/utils/app"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type WorkflowRepository struct{}
|
type WorkflowRepository struct{}
|
||||||
|
@ -7,8 +7,8 @@ import (
|
|||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/dbx"
|
||||||
"github.com/pocketbase/pocketbase/models"
|
"github.com/pocketbase/pocketbase/models"
|
||||||
|
"github.com/usual2970/certimate/internal/app"
|
||||||
"github.com/usual2970/certimate/internal/domain"
|
"github.com/usual2970/certimate/internal/domain"
|
||||||
"github.com/usual2970/certimate/internal/utils/app"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type WorkflowOutputRepository struct{}
|
type WorkflowOutputRepository struct{}
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/usual2970/certimate/internal/domain"
|
"github.com/usual2970/certimate/internal/domain"
|
||||||
"github.com/usual2970/certimate/internal/utils/resp"
|
"github.com/usual2970/certimate/internal/rest/resp"
|
||||||
|
|
||||||
"github.com/labstack/echo/v5"
|
"github.com/labstack/echo/v5"
|
||||||
)
|
)
|
||||||
|
@ -3,9 +3,9 @@ package resp
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/usual2970/certimate/internal/domain"
|
|
||||||
|
|
||||||
"github.com/labstack/echo/v5"
|
"github.com/labstack/echo/v5"
|
||||||
|
|
||||||
|
"github.com/usual2970/certimate/internal/domain"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Response struct {
|
type Response struct {
|
@ -5,7 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/labstack/echo/v5"
|
"github.com/labstack/echo/v5"
|
||||||
"github.com/usual2970/certimate/internal/domain"
|
"github.com/usual2970/certimate/internal/domain"
|
||||||
"github.com/usual2970/certimate/internal/utils/resp"
|
"github.com/usual2970/certimate/internal/rest/resp"
|
||||||
)
|
)
|
||||||
|
|
||||||
type StatisticsService interface {
|
type StatisticsService interface {
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/labstack/echo/v5"
|
"github.com/labstack/echo/v5"
|
||||||
"github.com/usual2970/certimate/internal/domain"
|
"github.com/usual2970/certimate/internal/domain"
|
||||||
"github.com/usual2970/certimate/internal/utils/resp"
|
"github.com/usual2970/certimate/internal/rest/resp"
|
||||||
)
|
)
|
||||||
|
|
||||||
type WorkflowService interface {
|
type WorkflowService interface {
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
package xtime
|
|
||||||
|
|
||||||
import (
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
func BeijingTimeStr() string {
|
|
||||||
location, _ := time.LoadLocation("Asia/Shanghai")
|
|
||||||
|
|
||||||
// 获取当前时间
|
|
||||||
now := time.Now().In(location)
|
|
||||||
|
|
||||||
// 格式化为字符串
|
|
||||||
return now.Format("2006-01-02 15:04:05")
|
|
||||||
}
|
|
@ -7,9 +7,9 @@ import (
|
|||||||
"github.com/pocketbase/pocketbase/core"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/models"
|
"github.com/pocketbase/pocketbase/models"
|
||||||
|
|
||||||
|
"github.com/usual2970/certimate/internal/app"
|
||||||
"github.com/usual2970/certimate/internal/domain"
|
"github.com/usual2970/certimate/internal/domain"
|
||||||
"github.com/usual2970/certimate/internal/repository"
|
"github.com/usual2970/certimate/internal/repository"
|
||||||
"github.com/usual2970/certimate/internal/utils/app"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const tableName = "workflow"
|
const tableName = "workflow"
|
||||||
|
@ -3,9 +3,9 @@ package nodeprocessor
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/usual2970/certimate/internal/domain"
|
"github.com/usual2970/certimate/internal/domain"
|
||||||
"github.com/usual2970/certimate/internal/utils/xtime"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type NodeProcessor interface {
|
type NodeProcessor interface {
|
||||||
@ -33,7 +33,7 @@ func (l *Logger) Log(ctx context.Context) *domain.RunLog {
|
|||||||
|
|
||||||
func (l *Logger) AddOutput(ctx context.Context, title, content string, err ...string) {
|
func (l *Logger) AddOutput(ctx context.Context, title, content string, err ...string) {
|
||||||
output := domain.RunLogOutput{
|
output := domain.RunLogOutput{
|
||||||
Time: xtime.BeijingTimeStr(),
|
Time: time.Now().UTC().Format(time.RFC3339),
|
||||||
Title: title,
|
Title: title,
|
||||||
Content: content,
|
Content: content,
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/usual2970/certimate/internal/app"
|
||||||
"github.com/usual2970/certimate/internal/domain"
|
"github.com/usual2970/certimate/internal/domain"
|
||||||
"github.com/usual2970/certimate/internal/utils/app"
|
|
||||||
nodeprocessor "github.com/usual2970/certimate/internal/workflow/node-processor"
|
nodeprocessor "github.com/usual2970/certimate/internal/workflow/node-processor"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
8
main.go
8
main.go
@ -6,20 +6,20 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
_ "time/tzdata"
|
||||||
|
|
||||||
"github.com/labstack/echo/v5"
|
"github.com/labstack/echo/v5"
|
||||||
"github.com/labstack/echo/v5/middleware"
|
"github.com/labstack/echo/v5/middleware"
|
||||||
"github.com/pocketbase/pocketbase/core"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/plugins/migratecmd"
|
"github.com/pocketbase/pocketbase/plugins/migratecmd"
|
||||||
|
|
||||||
_ "github.com/usual2970/certimate/migrations"
|
"github.com/usual2970/certimate/internal/app"
|
||||||
|
|
||||||
"github.com/usual2970/certimate/internal/routes"
|
"github.com/usual2970/certimate/internal/routes"
|
||||||
"github.com/usual2970/certimate/internal/scheduler"
|
"github.com/usual2970/certimate/internal/scheduler"
|
||||||
"github.com/usual2970/certimate/internal/utils/app"
|
|
||||||
"github.com/usual2970/certimate/internal/workflow"
|
"github.com/usual2970/certimate/internal/workflow"
|
||||||
"github.com/usual2970/certimate/ui"
|
"github.com/usual2970/certimate/ui"
|
||||||
|
|
||||||
_ "time/tzdata"
|
_ "github.com/usual2970/certimate/migrations"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user