提交 c4783e62 authored 作者: mooncake9527's avatar mooncake9527

change dir

上级 b9c4159d
package application
import (
"context"
"time"
"gitlab.wanzhuangkj.com/tush/xpkg/database"
"gitlab.wanzhuangkj.com/tush/xpkg/config"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/app"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/tracer"
)
func Close(servers []app.IServer) []app.Close {
var closes []app.Close
for _, s := range servers {
closes = append(closes, s.Stop)
}
closes = append(closes, func() error {
return database.CloseDB()
})
cacheType := ""
config.Read(func(c *config.Config) {
cacheType = c.App.CacheType
})
if cacheType == "redis" {
closes = append(closes, func() error {
return database.CloseRedis()
})
}
enableTrace := false
config.Read(func(c *config.Config) {
enableTrace = c.App.Middleware.Trace.Enable
})
if enableTrace {
closes = append(closes, func() error {
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) //nolint
defer cancel()
return tracer.Close(ctx)
})
}
closes = append(closes, func() error {
return logger.Sync()
})
return closes
}
package application
import (
"net/http"
"strconv"
"gitlab.wanzhuangkj.com/tush/xpkg/config"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/app"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/server"
)
func CreateServices(handler http.Handler) []app.IServer {
port := 8080
config.Read(func(c *config.Config) {
port = c.HTTP.Port
})
var servers []app.IServer
httpAddr := ":" + strconv.Itoa(port)
httpServer := server.NewHTTPServer(httpAddr, handler)
servers = append(servers, httpServer)
return servers
}
package xpkg
package application
import (
"context"
"fmt"
"os"
"runtime"
"strconv"
"github.com/gin-gonic/gin"
"github.com/jinzhu/copier"
"gitlab.wanzhuangkj.com/tush/xpkg/config"
"gitlab.wanzhuangkj.com/tush/xpkg/database"
"gitlab.wanzhuangkj.com/tush/xpkg/eventbus"
"gitlab.wanzhuangkj.com/tush/xpkg/global"
"gitlab.wanzhuangkj.com/tush/xpkg/ips"
"gitlab.wanzhuangkj.com/tush/xpkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/eventbus"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/ips"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/stat"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/tracer"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/rd/nacos"
"gitlab.wanzhuangkj.com/tush/xpkg/stat"
"gitlab.wanzhuangkj.com/tush/xpkg/tracer"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/dxsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/app"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
)
func init() {
func parseInit() {
if confType, ok := os.LookupEnv("CONF_TYPE"); (ok && sliceUtils.NotContains([]string{"local", "nacos", "consul"}, confType)) || !ok {
return
}
if err := config.Parse(); err != nil {
logger.Fatal(err.Error())
if err := config.ParseConf(); err != nil {
fmt.Println(err.Error())
}
logger.Info("[conf] parse conf finish.")
if err := xsf.Init(); err != nil {
logger.Fatal(err.Error())
}
logger.Info("[xsf] initialized.")
if err := dxsf.Init(); err != nil {
logger.Fatal(err.Error())
}
if err := Init(); err != nil {
logger.Info("[dxsf] initialized.")
if err := initOthers(); err != nil {
logger.Fatal(err.Error())
}
}
func Init() (err error) {
type Application struct {
app *app.App
h func() *gin.Engine
}
func (x *Application) Run() {
defer Recover()
parseInit()
services := CreateServices(x.h())
closes := Close(services)
x.app = app.New(services, closes)
x.app.Run()
}
func Recover() {
if r := recover(); r != nil {
pc, file, line, _ := runtime.Caller(3)
logger.Fatalf("recovered panic at %s[%s:%d]: %v\n", runtime.FuncForPC(pc).Name(), file, line, r)
}
}
func New(h func() *gin.Engine) *Application {
return &Application{
h: h,
}
}
// init logger,trace,stat,database,cache,rd...
func initOthers() (err error) {
conf := config.Cfg
if err := initLogger(conf); err != nil {
return err
......@@ -73,13 +108,14 @@ func Init() (err error) {
database.InitCache(conf.App.CacheType)
eventbus.Eb.Publish(ctx, eventbus.TopicCacheInitFinish)
if conf.App.CacheType != "" {
logger.Info(fmt.Sprintf("[%s] initialized", conf.App.CacheType))
logger.Info(fmt.Sprintf("[cache-%s] initialized", conf.App.CacheType))
}
rdt := conf.App.RegistryDiscoveryType
if rdt == "nacos" {
if err := nacosRegisterInstance(); err != nil {
return err
}
logger.Info("[rd] initialized.")
}
eventbus.Eb.Publish(ctx, eventbus.TopicCoreInitFinish)
return nil
......
......@@ -6,7 +6,7 @@ import (
"time"
"github.com/jinzhu/copier"
"gitlab.wanzhuangkj.com/tush/xpkg/third/oss"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/oss"
)
var Cfg = &Config{
......
......@@ -7,9 +7,9 @@ import (
"github.com/hashicorp/consul/api"
"github.com/spf13/viper"
"gitlab.wanzhuangkj.com/tush/xpkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/hashUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
)
type ConsulConfFetcher struct {
......
......@@ -8,8 +8,8 @@ import (
"github.com/spf13/cast"
"github.com/spf13/viper"
"gitlab.wanzhuangkj.com/tush/xpkg/eventbus"
"gitlab.wanzhuangkj.com/tush/xpkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/eventbus"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
)
var (
......@@ -21,7 +21,7 @@ type IExtend interface {
Unlock()
}
func Parse() (err error) {
func ParseConf() (err error) {
if hostname := os.Getenv("HOSTNAME"); hostname != "" {
Cfg.App.PodName = hostname
}
......
......@@ -11,7 +11,7 @@ import (
"path/filepath"
"strings"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"github.com/fsnotify/fsnotify"
"github.com/spf13/viper"
......
......@@ -7,8 +7,8 @@ import (
"github.com/nacos-group/nacos-sdk-go/clients/config_client"
"github.com/nacos-group/nacos-sdk-go/common/constant"
"github.com/nacos-group/nacos-sdk-go/vo"
"gitlab.wanzhuangkj.com/tush/xpkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"go.uber.org/zap"
)
......
......@@ -5,8 +5,8 @@ import (
"strings"
"gitlab.wanzhuangkj.com/tush/xpkg/config"
"gitlab.wanzhuangkj.com/tush/xpkg/sgorm"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
)
var (
......
......@@ -6,9 +6,9 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/config"
"gitlab.wanzhuangkj.com/tush/xpkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/sgorm"
"gitlab.wanzhuangkj.com/tush/xpkg/sgorm/mysql"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/mysql"
"gitlab.wanzhuangkj.com/tush/xpkg/utils"
)
......
......@@ -7,9 +7,9 @@ import (
"github.com/dgraph-io/ristretto"
"github.com/jinzhu/copier"
"gitlab.wanzhuangkj.com/tush/xpkg/config"
"gitlab.wanzhuangkj.com/tush/xpkg/goredis"
"gitlab.wanzhuangkj.com/tush/xpkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/tracer"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/goredis"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/tracer"
)
var (
......
......@@ -9,7 +9,7 @@ import (
"github.com/gin-gonic/gin"
"gitlab.wanzhuangkj.com/tush/xpkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/utils"
)
......
......@@ -3,10 +3,10 @@ package middleware
import (
"github.com/gin-gonic/gin"
"gitlab.wanzhuangkj.com/tush/xpkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/response"
"gitlab.wanzhuangkj.com/tush/xpkg/jwt"
"gitlab.wanzhuangkj.com/tush/xpkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/jwt"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
)
......@@ -110,6 +110,17 @@ func Auth(opts ...JwtOption) gin.HandlerFunc {
}
}
func JwtFields() gin.HandlerFunc {
return func(c *gin.Context) {
params := c.Request.URL.Query()
for key, values := range params {
if len(values) > 0 {
c.Set(key, values[0])
}
}
}
}
// -------------------------------------------------------------------------------------------
// VerifyCustomFn verify custom function, tokenTail10 is the last 10 characters of the token.
......
......@@ -5,9 +5,9 @@ import (
"github.com/gin-gonic/gin"
"gitlab.wanzhuangkj.com/tush/xpkg/container/group"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/response"
"gitlab.wanzhuangkj.com/tush/xpkg/shield/circuitbreaker"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/container/group"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/shield/circuitbreaker"
)
// ErrNotAllowed error not allowed.
......
......@@ -11,10 +11,10 @@ import (
"github.com/gin-gonic/gin"
"gitlab.wanzhuangkj.com/tush/xpkg/container/group"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/response"
"gitlab.wanzhuangkj.com/tush/xpkg/httpcli"
"gitlab.wanzhuangkj.com/tush/xpkg/shield/circuitbreaker"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/container/group"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/httpcli"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/shield/circuitbreaker"
"gitlab.wanzhuangkj.com/tush/xpkg/utils"
)
......
......@@ -2,13 +2,14 @@ package middleware
import (
"bytes"
"gitlab.wanzhuangkj.com/tush/xpkg/httpcli/entity"
"io"
"net/http"
"strings"
"time"
"gitlab.wanzhuangkj.com/tush/xpkg/ips"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/httpcli/entity"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/ips"
ctxUtils "gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
"github.com/gin-gonic/gin"
......
......@@ -8,8 +8,8 @@ import (
"github.com/gin-gonic/gin"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/response"
"gitlab.wanzhuangkj.com/tush/xpkg/httpcli"
"gitlab.wanzhuangkj.com/tush/xpkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/httpcli"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/utils"
ctxUtil "gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
)
......
package middleware
import (
"net/http"
"time"
"github.com/gin-gonic/gin"
"github.com/redis/go-redis/v9"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/middleware/ratelimiter"
srl "gitlab.wanzhuangkj.com/tush/xpkg/gin/middleware/sync_ratelimiter"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/response"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/ips"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
)
func IPRateLimiter(windowSize time.Duration, maxRequests int) func(c *gin.Context) {
rl := ratelimiter.NewIPRateLimiter(windowSize, maxRequests)
return func(c *gin.Context) {
clientIP := ips.GetClientIP(c)
if rl.Allow(clientIP) {
c.Next()
} else {
Fail(c, errcode.TooManyRequests.Code(), errcode.TooManyRequests.Msg())
}
}
}
func SyncIPRateLimiter(windowSize time.Duration, maxRequests int64, cli redis.Cmdable) func(c *gin.Context) {
rl := srl.NewIPRateLimiter(
srl.WithWindowSize(windowSize),
srl.WithMaxRequests(maxRequests),
srl.WithLogger(logger.Get()),
srl.WithRedisCli(cli),
)
return func(c *gin.Context) {
clientIP := ips.GetClientIP(c)
ctx := ctxUtils.WrapCtx(c)
if rl.Allow(ctx, clientIP) {
c.Next()
} else {
Fail(c, errcode.TooManyRequests.Code(), errcode.TooManyRequests.Msg())
}
}
}
func Fail(c *gin.Context, code int, msg string, data ...any) {
c.AbortWithStatusJSON(http.StatusOK, response.Result{Code: code, Msg: msg, Data: nil, TimeStamp: time.Now().Unix(), TraceID: ctxUtils.GetGinCtxTid(c)})
}
......@@ -8,7 +8,7 @@ import (
"github.com/gin-gonic/gin"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/response"
rl "gitlab.wanzhuangkj.com/tush/xpkg/shield/ratelimit"
rl "gitlab.wanzhuangkj.com/tush/xpkg/pkg/shield/ratelimit"
)
// ErrLimitExceed is returned when the rate limiter is
......
......@@ -12,7 +12,7 @@ import (
"github.com/gin-gonic/gin"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/response"
"gitlab.wanzhuangkj.com/tush/xpkg/httpcli"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/httpcli"
"gitlab.wanzhuangkj.com/tush/xpkg/utils"
)
......
......@@ -6,7 +6,7 @@ import (
"time"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/response"
"gitlab.wanzhuangkj.com/tush/xpkg/httpcli"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/httpcli"
"gitlab.wanzhuangkj.com/tush/xpkg/utils"
"github.com/gin-gonic/gin"
......
......@@ -8,14 +8,14 @@ import (
"strconv"
"time"
"gitlab.wanzhuangkj.com/tush/xpkg/httpcli/entity"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/httpcli/entity"
"github.com/gin-gonic/gin"
"gitlab.wanzhuangkj.com/tush/xpkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
ctxUtils "gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
)
const CustomErrorCode = 0
......
......@@ -10,8 +10,8 @@ import (
"github.com/gin-gonic/gin"
"github.com/stretchr/testify/assert"
"gitlab.wanzhuangkj.com/tush/xpkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/httpcli"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/httpcli"
"gitlab.wanzhuangkj.com/tush/xpkg/utils"
)
......
......@@ -11,7 +11,7 @@ import (
ginSwagger "github.com/swaggo/gin-swagger"
"github.com/swaggo/swag"
"gitlab.wanzhuangkj.com/tush/xpkg/gofile"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/gofile"
)
// DefaultRouter default swagger router, request url is http://<ip:port>/swagger/index.html
......
......@@ -12,16 +12,16 @@ import (
ginSwagger "github.com/swaggo/gin-swagger"
"gitlab.wanzhuangkj.com/tush/xpkg/config"
"gitlab.wanzhuangkj.com/tush/xpkg/consts"
"gitlab.wanzhuangkj.com/tush/xpkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/handlerfunc"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/middleware"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/middleware/metrics"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/prof"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/validator"
"gitlab.wanzhuangkj.com/tush/xpkg/ips"
"gitlab.wanzhuangkj.com/tush/xpkg/jwt"
"gitlab.wanzhuangkj.com/tush/xpkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/text"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/ips"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/jwt"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/text"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/webLogUtils"
xvalidator "gitlab.wanzhuangkj.com/tush/xpkg/xcommon/validator"
)
......
......@@ -10,9 +10,9 @@ import (
"golang.org/x/sync/errgroup"
"gitlab.wanzhuangkj.com/tush/xpkg/prof"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/prof"
xlogger "gitlab.wanzhuangkj.com/tush/xpkg/logger"
xlogger "gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
)
// IServer server interface
......
......@@ -6,8 +6,8 @@ import (
"github.com/stretchr/testify/assert"
"gitlab.wanzhuangkj.com/tush/xpkg/encoding"
"gitlab.wanzhuangkj.com/tush/xpkg/gotest"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/encoding"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/gotest"
"gitlab.wanzhuangkj.com/tush/xpkg/utils"
)
......
......@@ -10,11 +10,11 @@ import (
"github.com/dgraph-io/ristretto"
"github.com/spf13/cast"
"gitlab.wanzhuangkj.com/tush/xpkg/encoding"
"gitlab.wanzhuangkj.com/tush/xpkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/encoding"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
ctxUtil "gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
xslice "gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
)
type memoryCache struct {
......
......@@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/assert"
"gitlab.wanzhuangkj.com/tush/xpkg/gotest"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/gotest"
"gitlab.wanzhuangkj.com/tush/xpkg/utils"
)
......
......@@ -10,8 +10,8 @@ import (
"github.com/redis/go-redis/v9"
"gitlab.wanzhuangkj.com/tush/xpkg/encoding"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/encoding"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
)
// CacheNotFound no hit cache
......
......@@ -6,8 +6,8 @@ import (
"github.com/stretchr/testify/assert"
"gitlab.wanzhuangkj.com/tush/xpkg/encoding"
"gitlab.wanzhuangkj.com/tush/xpkg/gotest"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/encoding"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/gotest"
"gitlab.wanzhuangkj.com/tush/xpkg/utils"
)
......
......@@ -7,7 +7,7 @@ import (
"github.com/mojocn/base64Captcha"
"github.com/redis/go-redis/v9"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
)
const (
......
......@@ -4,9 +4,10 @@ import (
"crypto/rand"
"crypto/tls"
"fmt"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
"math/big"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gopkg.in/gomail.v2"
)
......
......@@ -8,7 +8,7 @@ import (
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
"gitlab.wanzhuangkj.com/tush/xpkg/encoding"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/encoding"
)
// Name is the name registered for the json codec.
......
......@@ -6,7 +6,7 @@ import (
"google.golang.org/protobuf/proto"
"gitlab.wanzhuangkj.com/tush/xpkg/encoding"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/encoding"
)
// Name is the name registered for the proto compressor.
......
......@@ -3,6 +3,7 @@ package eventbus
var Eb = New()
const (
TopicParseConfStart string = "event:application:conf:init:start" // 配置文件解析开始
TopicParseConfFinish string = "event:application:conf:init:finish" // 配置文件解析完毕
TopicDBInitFinish string = "event:application:database:init:finish" // 数据库连接初始化完成
TopicCacheInitFinish string = "event:application:cache:init:finish" // cache初始化完成
......
......@@ -7,7 +7,7 @@ import (
"runtime"
"time"
"gitlab.wanzhuangkj.com/tush/xpkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
ctxUtil "gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
"github.com/redis/go-redis/v9"
......
......@@ -9,7 +9,7 @@ import (
"github.com/DATA-DOG/go-sqlmock"
"gorm.io/gorm"
"gitlab.wanzhuangkj.com/tush/xpkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
)
func TestNewDao(t *testing.T) {
......
......@@ -13,12 +13,12 @@ import (
"strings"
"time"
"gitlab.wanzhuangkj.com/tush/xpkg/httpcli/entity"
"gitlab.wanzhuangkj.com/tush/xpkg/httpcli/httpContentType"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/httpcli/entity"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/httpcli/httpContentType"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"github.com/duke-git/lancet/v2/retry"
"gitlab.wanzhuangkj.com/tush/xpkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
)
......
......@@ -76,10 +76,10 @@ func Init(opts ...Option) (*zap.Logger, error) {
if err != nil {
panic(err)
}
str = fmt.Sprintf("[log]initialize logger finish, config is output to 'terminal', format=%s, level=%s", encoding, levelName)
str = fmt.Sprintf("[logger] config is output to 'terminal', format=%s, level=%s", encoding, levelName)
} else {
zapLog = log2File(encoding, levelName, o.fileConfig)
str = fmt.Sprintf("[log]initialize logger finish, config is output to 'file', format=%s, level=%s, file=%s", encoding, levelName, o.fileConfig.filename)
str = fmt.Sprintf("[logger] config is output to 'file', format=%s, level=%s, file=%s", encoding, levelName, o.fileConfig.filename)
}
if len(o.hooks) > 0 {
......
......@@ -4,8 +4,8 @@ import (
"io"
"mime/multipart"
"gitlab.wanzhuangkj.com/tush/xpkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"github.com/aliyun/aliyun-oss-go-sdk/oss"
)
......
package server
import (
"context"
"fmt"
"net/http"
"time"
"github.com/gin-gonic/gin"
"gitlab.wanzhuangkj.com/tush/xpkg/config"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/app"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/text"
)
var _ app.IServer = (*httpServer)(nil)
type httpServer struct {
addr string
server *http.Server
}
func (s *httpServer) Start() error {
if err := s.server.ListenAndServe(); err != nil && err != http.ErrServerClosed {
return fmt.Errorf("listen server error: %v", err)
}
return nil
}
func (s *httpServer) Stop() error {
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) //nolint
defer cancel()
return s.server.Shutdown(ctx)
}
func (s *httpServer) String() string {
var host, name string
var port int
config.Read(func(c *config.Config) {
name = c.App.Name
host = c.App.Host
port = c.HTTP.Port
})
addr := fmt.Sprintf("%s:%d", host, port)
return text.Green(fmt.Sprintf("server[%s] started, listen on: ", name)) + text.Red("[ "+addr+" ]")
}
func NewHTTPServer(addr string, handler http.Handler, opts ...HTTPOption) app.IServer {
o := defaultHTTPOptions()
o.apply(opts...)
if o.isProd {
gin.SetMode(gin.ReleaseMode)
} else {
gin.SetMode(gin.DebugMode)
}
// router := routers.NewRouter()
server := &http.Server{
Addr: addr,
Handler: handler,
MaxHeaderBytes: 1 << 20,
}
return &httpServer{
addr: addr,
server: server,
}
}
package server
// HTTPOption setting up http
type HTTPOption func(*httpOptions)
type httpOptions struct {
isProd bool
}
func defaultHTTPOptions() *httpOptions {
return &httpOptions{
isProd: false,
}
}
func (o *httpOptions) apply(opts ...HTTPOption) {
for _, opt := range opts {
opt(o)
}
}
func WithHTTPIsProd(isProd bool) HTTPOption {
return func(o *httpOptions) {
o.isProd = isProd
}
}
......@@ -8,7 +8,7 @@ import (
"github.com/huandu/xstrings"
"gorm.io/gorm"
"gitlab.wanzhuangkj.com/tush/xpkg/sgorm/dbclose"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/dbclose"
)
type DB = gorm.DB
......
......@@ -13,9 +13,9 @@ import (
"gorm.io/gorm/schema"
"gorm.io/plugin/dbresolver"
"gitlab.wanzhuangkj.com/tush/xpkg/sgorm/dbclose"
"gitlab.wanzhuangkj.com/tush/xpkg/sgorm/glog"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/dbclose"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/glog"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
)
// Init mysql
......
......@@ -12,8 +12,8 @@ import (
"gorm.io/gorm/logger"
"gorm.io/gorm/schema"
"gitlab.wanzhuangkj.com/tush/xpkg/sgorm/dbclose"
"gitlab.wanzhuangkj.com/tush/xpkg/sgorm/glog"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/dbclose"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/glog"
)
// Init postgresql
......
......@@ -5,8 +5,8 @@ import (
"fmt"
"strings"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
)
const (
......
......@@ -12,8 +12,8 @@ import (
"gorm.io/gorm/logger"
"gorm.io/gorm/schema"
"gitlab.wanzhuangkj.com/tush/xpkg/sgorm/dbclose"
"gitlab.wanzhuangkj.com/tush/xpkg/sgorm/glog"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/dbclose"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/glog"
)
// Init sqlite
......
......@@ -9,7 +9,7 @@ Circuit Breaker for web middleware and rpc interceptor.
**gin circuit breaker middleware**
```go
import "gitlab.wanzhuangkj.com/tush/xpkg/shield/circuitbreaker"
import "gitlab.wanzhuangkj.com/tush/xpkg/pkg/shield/circuitbreaker"
// CircuitBreaker a circuit breaker middleware
func CircuitBreaker(opts ...CircuitBreakerOption) gin.HandlerFunc {
......@@ -45,7 +45,7 @@ func CircuitBreaker(opts ...CircuitBreakerOption) gin.HandlerFunc {
**rpc server circuit breaker interceptor**
```go
import "gitlab.wanzhuangkj.com/tush/xpkg/shield/circuitbreaker"
import "gitlab.wanzhuangkj.com/tush/xpkg/pkg/shield/circuitbreaker"
// UnaryServerCircuitBreaker server-side unary circuit breaker interceptor
func UnaryServerCircuitBreaker(opts ...CircuitBreakerOption) grpc.UnaryServerInterceptor {
......
......@@ -3,7 +3,7 @@ package circuitbreaker_test
import (
"testing"
"gitlab.wanzhuangkj.com/tush/xpkg/shield/circuitbreaker"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/shield/circuitbreaker"
)
// This is an example of using a circuit breaker Do() when return nil.
......
......@@ -7,7 +7,7 @@ import (
"sync/atomic"
"time"
"gitlab.wanzhuangkj.com/tush/xpkg/shield/window"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/shield/window"
)
// Option is sre breaker option function.
......
......@@ -8,7 +8,7 @@ import (
"github.com/stretchr/testify/assert"
"gitlab.wanzhuangkj.com/tush/xpkg/shield/window"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/shield/window"
)
func getSREBreaker() *Breaker {
......
......@@ -7,8 +7,8 @@ import (
"sync/atomic"
"time"
"gitlab.wanzhuangkj.com/tush/xpkg/shield/cpu"
"gitlab.wanzhuangkj.com/tush/xpkg/shield/window"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/shield/cpu"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/shield/window"
)
var (
......
......@@ -9,7 +9,7 @@ import (
"github.com/stretchr/testify/assert"
"gitlab.wanzhuangkj.com/tush/xpkg/shield/window"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/shield/window"
)
var (
......
......@@ -8,8 +8,8 @@ import (
"go.uber.org/zap"
"gitlab.wanzhuangkj.com/tush/xpkg/stat/cpu"
"gitlab.wanzhuangkj.com/tush/xpkg/stat/mem"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/stat/cpu"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/stat/mem"
)
var (
......
......@@ -7,10 +7,10 @@ import (
"sync"
"time"
"gitlab.wanzhuangkj.com/tush/xpkg/jwt"
"gitlab.wanzhuangkj.com/tush/xpkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/jwt"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
"github.com/gin-gonic/gin"
"github.com/gorilla/websocket"
......
......@@ -3,7 +3,7 @@ package xerror
import (
"fmt"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xcode"
)
// New 用于创建一个自定义文本错误信息的 error 对象,并包含堆栈信息。
......
......@@ -2,8 +2,9 @@ package xerror
import (
"fmt"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xcode"
"strings"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xcode"
)
// NewCode 用于创建一个自定义错误信息的 error 对象,并包含堆栈信息,并增加错误码对象的输入。
......
package xerror
import "gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xcode"
import "gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xcode"
// Code 获取错误码。
// 如果没有错误代码,则返回 `xcode.CodeDefault`。
......
package xerror_test
import (
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
"testing"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"github.com/pkg/errors"
)
......
......@@ -2,8 +2,9 @@ package xerror_test
import (
"fmt"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xcode"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"github.com/pkg/errors"
)
......
......@@ -3,12 +3,13 @@ package xerror_test
import (
"encoding/json"
"fmt"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xcode"
"testing"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xcode"
"github.com/pkg/errors"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gorm.io/gorm"
......
......@@ -7,7 +7,7 @@ import (
"github.com/nacos-group/nacos-sdk-go/model"
"github.com/nacos-group/nacos-sdk-go/vo"
"gitlab.wanzhuangkj.com/tush/xpkg/config"
"gitlab.wanzhuangkj.com/tush/xpkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
)
type NacosServiceClient struct {
......
package sms
type SmsMessage struct {
Phone string
Title string
Content string
}
type SmsConfig struct {
}
type SmsSender struct{}
// Send 发送短消息
func (m *SmsSender) Send(msg *SmsMessage, config *SmsConfig) error {
if msg == nil {
return nil
}
return m.Sends(append([]*SmsMessage{}, msg), config)
}
func (m *SmsSender) Sends(msgs []*SmsMessage, config *SmsConfig) error {
if len(msgs) == 0 {
return nil
}
return nil
}
......@@ -8,8 +8,8 @@ import (
"time"
"gitlab.wanzhuangkj.com/tush/xpkg/config"
"gitlab.wanzhuangkj.com/tush/xpkg/httpcli"
"gitlab.wanzhuangkj.com/tush/xpkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/httpcli"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
)
......
......@@ -4,7 +4,7 @@ import (
"context"
"time"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"golang.org/x/sync/errgroup"
)
......
......@@ -5,7 +5,7 @@ import (
"encoding/json"
"errors"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
)
func ToJsonString(v any) string {
......
......@@ -7,9 +7,9 @@ import (
"github.com/go-redsync/redsync/v4"
"github.com/go-redsync/redsync/v4/redis/goredis/v9"
"github.com/redis/go-redis/v9"
"gitlab.wanzhuangkj.com/tush/xpkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
)
var (
......
package setUtils
import (
"gitlab.wanzhuangkj.com/tush/xpkg/xtype"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xtype"
)
type Set[T xtype.Key] struct {
......
......@@ -4,13 +4,13 @@ import (
"fmt"
"strings"
"gitlab.wanzhuangkj.com/tush/xpkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xtype"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/setUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/xtype"
"github.com/jinzhu/copier"
"github.com/spf13/cast"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
)
// connector 连接符
......
......@@ -14,9 +14,9 @@ import (
"github.com/gin-gonic/gin"
"github.com/jinzhu/copier"
"github.com/spf13/cast"
"gitlab.wanzhuangkj.com/tush/xpkg/httpcli/entity"
"gitlab.wanzhuangkj.com/tush/xpkg/logger"
merge "gitlab.wanzhuangkj.com/tush/xpkg/merger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/httpcli/entity"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
merge "gitlab.wanzhuangkj.com/tush/xpkg/pkg/merger"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/json_utils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/retryUtils"
......
......@@ -2,10 +2,11 @@ package wg
import (
"context"
"gitlab.wanzhuangkj.com/tush/xpkg/logger"
ctxUtil "gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
"sync"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
ctxUtil "gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
)
func Go(ctx context.Context, n int, fn func() error) error {
......
......@@ -10,7 +10,7 @@ import (
"github.com/bwmarrin/snowflake"
"gitlab.wanzhuangkj.com/tush/xpkg/config"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
)
var (
......
......@@ -4,7 +4,7 @@ import "github.com/swaggo/swag"
var xapi *swag.Spec
func Init(apiDoc *swag.Spec) (err error) {
func Spec(apiDoc *swag.Spec) (err error) {
xapi = apiDoc
return initApiM(xapi)
}
......@@ -4,7 +4,7 @@ import (
"context"
"database/sql"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gorm.io/gorm"
)
......
......@@ -7,7 +7,7 @@ import (
"strings"
"unicode"
"gitlab.wanzhuangkj.com/tush/xpkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
)
/*
......
package xcommon
import (
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xtype"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xtype"
)
type IConverter[ID xtype.Key, T, B any] interface {
......
......@@ -9,7 +9,7 @@ import (
"github.com/gin-gonic/gin"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/response"
"gitlab.wanzhuangkj.com/tush/xpkg/httpcli"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/httpcli"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/map_utils"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/validator"
)
......
......@@ -6,7 +6,7 @@ import (
)
func Init(apiSpec *swag.Spec) (err error) {
if err := api.Init(apiSpec); err != nil {
if err := api.Spec(apiSpec); err != nil {
return err
}
return nil
......
......@@ -8,11 +8,11 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/database"
"gitlab.wanzhuangkj.com/tush/xpkg/cache"
"gitlab.wanzhuangkj.com/tush/xpkg/encoding"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/cache"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/encoding"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/utils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
)
const (
......
......@@ -7,16 +7,16 @@ import (
"strings"
"gitlab.wanzhuangkj.com/tush/xpkg/database"
"gitlab.wanzhuangkj.com/tush/xpkg/goredis"
"gitlab.wanzhuangkj.com/tush/xpkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/sgorm"
"gitlab.wanzhuangkj.com/tush/xpkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/goredis"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/utils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/setUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/ocache"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
"golang.org/x/sync/singleflight"
"gorm.io/gorm"
olog "gorm.io/gorm/logger"
......
......@@ -7,8 +7,8 @@ import (
"github.com/gin-gonic/gin"
ut "github.com/go-playground/universal-translator"
"github.com/go-playground/validator/v10"
"gitlab.wanzhuangkj.com/tush/xpkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
)
var (
......
......@@ -9,10 +9,10 @@ import (
"github.com/gin-gonic/gin"
"github.com/go-redsync/redsync/v4"
"gitlab.wanzhuangkj.com/tush/xpkg/config"
"gitlab.wanzhuangkj.com/tush/xpkg/eventbus"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/response"
"gitlab.wanzhuangkj.com/tush/xpkg/gocron"
"gitlab.wanzhuangkj.com/tush/xpkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/eventbus"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/gocron"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/redSyncUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
......
......@@ -7,8 +7,8 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
"golang.org/x/sync/singleflight"
"gorm.io/gorm"
glogger "gorm.io/gorm/logger"
......
......@@ -5,7 +5,7 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/config"
"gitlab.wanzhuangkj.com/tush/xpkg/database"
"gitlab.wanzhuangkj.com/tush/xpkg/eventbus"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/eventbus"
)
func init() {
......
......@@ -4,7 +4,7 @@ import (
"context"
"gitlab.wanzhuangkj.com/tush/xpkg/database"
"gitlab.wanzhuangkj.com/tush/xpkg/eventbus"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/eventbus"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/cache"
)
......
package ecode
import "gitlab.wanzhuangkj.com/tush/xpkg/errcode"
import "gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
var (
ErrCronJobNotFound = errcode.NewError(12001, "未查询到任务")
......
......@@ -14,8 +14,8 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/types"
"github.com/jinzhu/copier"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
)
type cronJobService struct {
......
package types
import (
"gitlab.wanzhuangkj.com/tush/xpkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/biz"
......
package types
import (
"gitlab.wanzhuangkj.com/tush/xpkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/biz"
......
package types
import (
"gitlab.wanzhuangkj.com/tush/xpkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/biz"
......
......@@ -4,10 +4,10 @@ package types
import (
"math"
"gitlab.wanzhuangkj.com/tush/xpkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/response"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
)
var (
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论