diff --git a/cmd/api/admin-api/main.go b/cmd/api/admin-api/main.go index 088365c09..281023e19 100644 --- a/cmd/api/admin-api/main.go +++ b/cmd/api/admin-api/main.go @@ -16,14 +16,15 @@ package main import ( "flag" - "github.com/OpenIMSDK/chat/pkg/discovery_register" - "github.com/OpenIMSDK/chat/tools/component" - "github.com/OpenIMSDK/tools/discoveryregistry" "math/rand" "net" "strconv" "time" + "github.com/OpenIMSDK/chat/pkg/discovery_register" + "github.com/OpenIMSDK/chat/tools/component" + "github.com/OpenIMSDK/tools/discoveryregistry" + mw2 "github.com/OpenIMSDK/chat/pkg/common/mw" "github.com/OpenIMSDK/chat/internal/api" diff --git a/cmd/api/chat-api/main.go b/cmd/api/chat-api/main.go index 7b50a1203..865fb77fb 100644 --- a/cmd/api/chat-api/main.go +++ b/cmd/api/chat-api/main.go @@ -25,6 +25,8 @@ import ( "strconv" "time" + "github.com/OpenIMSDK/chat/tools/component" + mw2 "github.com/OpenIMSDK/chat/pkg/common/mw" "github.com/OpenIMSDK/chat/internal/api" diff --git a/cmd/rpc/admin-rpc/main.go b/cmd/rpc/admin-rpc/main.go index 495282e31..cb8e36ea3 100644 --- a/cmd/rpc/admin-rpc/main.go +++ b/cmd/rpc/admin-rpc/main.go @@ -16,11 +16,12 @@ package main import ( "flag" + "math/rand" + "time" + "github.com/OpenIMSDK/chat/pkg/common/chatrpcstart" "github.com/OpenIMSDK/chat/tools/component" "github.com/OpenIMSDK/tools/log" - "math/rand" - "time" "github.com/OpenIMSDK/chat/internal/rpc/admin" "github.com/OpenIMSDK/chat/pkg/common/config" diff --git a/cmd/rpc/chat-rpc/main.go b/cmd/rpc/chat-rpc/main.go index f1422b137..baf036ccd 100644 --- a/cmd/rpc/chat-rpc/main.go +++ b/cmd/rpc/chat-rpc/main.go @@ -16,11 +16,12 @@ package main import ( "flag" + "math/rand" + "time" + "github.com/OpenIMSDK/chat/pkg/common/chatrpcstart" "github.com/OpenIMSDK/chat/tools/component" "github.com/OpenIMSDK/tools/log" - "math/rand" - "time" "github.com/OpenIMSDK/chat/internal/rpc/chat" "github.com/OpenIMSDK/chat/pkg/common/config" diff --git a/internal/rpc/admin/ip_forbidden.go b/internal/rpc/admin/ip_forbidden.go index 83d1ebf05..b663f458c 100644 --- a/internal/rpc/admin/ip_forbidden.go +++ b/internal/rpc/admin/ip_forbidden.go @@ -17,8 +17,6 @@ package admin import ( "context" "time" - - "github.com/OpenIMSDK/tools/log" admin2 "github.com/OpenIMSDK/chat/pkg/common/db/table/admin" diff --git a/internal/rpc/admin/register_add_group.go b/internal/rpc/admin/register_add_group.go index ce998d997..1c724b0e9 100644 --- a/internal/rpc/admin/register_add_group.go +++ b/internal/rpc/admin/register_add_group.go @@ -20,8 +20,6 @@ import ( "time" "github.com/OpenIMSDK/tools/log" - - "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/utils" diff --git a/internal/rpc/admin/user.go b/internal/rpc/admin/user.go index 3c6d06a92..a83339f51 100644 --- a/internal/rpc/admin/user.go +++ b/internal/rpc/admin/user.go @@ -18,8 +18,6 @@ import ( "context" "strings" "time" - - "github.com/OpenIMSDK/chat/pkg/common/constant" "github.com/OpenIMSDK/tools/log" diff --git a/internal/rpc/admin/user_ip_limit_login.go b/internal/rpc/admin/user_ip_limit_login.go index f51ac9962..b40bfdd4b 100644 --- a/internal/rpc/admin/user_ip_limit_login.go +++ b/internal/rpc/admin/user_ip_limit_login.go @@ -17,8 +17,6 @@ package admin import ( "context" "time" - - "github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/errs" diff --git a/internal/rpc/chat/log.go b/internal/rpc/chat/log.go index e48135d7c..34d476cd6 100644 --- a/internal/rpc/chat/log.go +++ b/internal/rpc/chat/log.go @@ -3,6 +3,9 @@ package chat import ( "context" "fmt" + "math/rand" + "time" + "github.com/OpenIMSDK/chat/pkg/common/constant" table "github.com/OpenIMSDK/chat/pkg/common/db/table/chat" "github.com/OpenIMSDK/chat/pkg/common/mctx" @@ -11,8 +14,6 @@ import ( "github.com/OpenIMSDK/tools/mw/specialerror" utils2 "github.com/OpenIMSDK/tools/utils" "gorm.io/gorm/utils" - "math/rand" - "time" ) func (o *chatSvr) genLogID() string { diff --git a/internal/rpc/chat/login.go b/internal/rpc/chat/login.go index a70c125d0..2937c047f 100644 --- a/internal/rpc/chat/login.go +++ b/internal/rpc/chat/login.go @@ -16,12 +16,13 @@ package chat import ( "context" - "github.com/OpenIMSDK/chat/pkg/common/mctx" "math/rand" "strconv" "strings" "time" + "github.com/OpenIMSDK/chat/pkg/common/mctx" + constant2 "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/tools/errs" diff --git a/internal/rpc/chat/statistic.go b/internal/rpc/chat/statistic.go index 74b979bbb..9651ef041 100644 --- a/internal/rpc/chat/statistic.go +++ b/internal/rpc/chat/statistic.go @@ -16,9 +16,10 @@ package chat import ( "context" + "time" + "github.com/OpenIMSDK/chat/pkg/proto/chat" "github.com/OpenIMSDK/tools/errs" - "time" ) func (o *chatSvr) UserLoginCount(ctx context.Context, req *chat.UserLoginCountReq) (*chat.UserLoginCountResp, error) { diff --git a/pkg/common/db/model/admin/admin.go b/pkg/common/db/model/admin/admin.go index f4e8d04a6..e5447b653 100644 --- a/pkg/common/db/model/admin/admin.go +++ b/pkg/common/db/model/admin/admin.go @@ -18,8 +18,8 @@ import ( "context" "crypto/md5" "encoding/hex" - "github.com/OpenIMSDK/tools/log" "time" + "github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/chat/pkg/common/config" "github.com/OpenIMSDK/chat/pkg/common/db/table/admin" diff --git a/pkg/common/db/model/chat/log.go b/pkg/common/db/model/chat/log.go index 5cb15119e..df138f5f8 100644 --- a/pkg/common/db/model/chat/log.go +++ b/pkg/common/db/model/chat/log.go @@ -2,11 +2,12 @@ package chat import ( "context" + "time" + "github.com/OpenIMSDK/chat/pkg/common/db/table/chat" "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/ormutil" "gorm.io/gorm" - "time" ) type Logs struct { @@ -39,6 +40,7 @@ func (l *Logs) Get(ctx context.Context, logIDs []string, userID string) ([]*chat } return logs, errs.Wrap(l.db.WithContext(ctx).Where("log_id in ? and user_id=?", logIDs, userID).Find(&logs).Error) } + func NewLogs(db *gorm.DB) chat.LogInterface { return &Logs{db: db} } diff --git a/pkg/common/db/model/chat/user_login_record.go b/pkg/common/db/model/chat/user_login_record.go index 54fe1756f..85f234fc0 100644 --- a/pkg/common/db/model/chat/user_login_record.go +++ b/pkg/common/db/model/chat/user_login_record.go @@ -16,9 +16,8 @@ package chat import ( "context" - - "github.com/OpenIMSDK/tools/errs" "time" + "github.com/OpenIMSDK/tools/errs" "gorm.io/gorm" diff --git a/pkg/proto/chat/chat.go b/pkg/proto/chat/chat.go index 61cc24b1d..d6e8cd056 100644 --- a/pkg/proto/chat/chat.go +++ b/pkg/proto/chat/chat.go @@ -15,10 +15,11 @@ package chat import ( - "github.com/OpenIMSDK/tools/utils" "regexp" "strconv" + "github.com/OpenIMSDK/tools/utils" + "github.com/OpenIMSDK/chat/pkg/common/constant" constant2 "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/tools/errs" @@ -221,6 +222,7 @@ func (x *UploadLogsReq) Check() error { } return nil } + func (x *SearchLogsReq) Check() error { if x.Pagination == nil { return errs.ErrArgs.Wrap("Pagination is empty") diff --git a/pkg/sms/sms.go b/pkg/sms/sms.go index 7a6f4a3e8..05e468c78 100644 --- a/pkg/sms/sms.go +++ b/pkg/sms/sms.go @@ -17,9 +17,8 @@ package sms import ( "context" "fmt" - "github.com/OpenIMSDK/chat/pkg/common/config" "strings" - + "github.com/OpenIMSDK/chat/pkg/common/config" ) func New() (SMS, error) { diff --git a/tools/component/component.go b/tools/component/component.go index 420f566d7..084db8b40 100644 --- a/tools/component/component.go +++ b/tools/component/component.go @@ -2,6 +2,9 @@ package component import ( "fmt" + "os" + "time" + "github.com/OpenIMSDK/chat/pkg/common/config" "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/tools/errs" @@ -9,8 +12,6 @@ import ( "github.com/go-zookeeper/zk" "github.com/pkg/errors" "gopkg.in/yaml.v3" - "os" - "time" ) func initCfg(cfgPath string) error {