This commit is contained in:
wangchuxiao 2023-02-23 19:19:01 +08:00
parent be11da75ae
commit 76565cded1
3 changed files with 42 additions and 23 deletions

25
cmd/cmdutils/Makefile Normal file
View File

@ -0,0 +1,25 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_cmd_utils
BIN_DIR=../../bin/
all: gotool build
build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
run:
@go run ./
gotool:
go fmt ./
go vet ./
install:
make build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi

View File

@ -1,13 +1,13 @@
package cache package cache
import ( import (
"Open_IM/pkg/common/config" "OpenIM/pkg/common/config"
"Open_IM/pkg/common/constant" "OpenIM/pkg/common/constant"
"Open_IM/pkg/common/tracelog" "OpenIM/pkg/common/tracelog"
pbChat "Open_IM/pkg/proto/msg" pbChat "OpenIM/pkg/proto/msg"
pbRtc "Open_IM/pkg/proto/rtc" pbRtc "OpenIM/pkg/proto/rtc"
"Open_IM/pkg/proto/sdkws" "OpenIM/pkg/proto/sdkws"
"Open_IM/pkg/utils" "OpenIM/pkg/utils"
"context" "context"
"errors" "errors"
"fmt" "fmt"

View File

@ -1,21 +1,21 @@
package controller package controller
import ( import (
"Open_IM/pkg/common/constant" "OpenIM/pkg/common/constant"
"Open_IM/pkg/common/db/cache" "OpenIM/pkg/common/db/cache"
unRelationTb "Open_IM/pkg/common/db/table/unrelation" unRelationTb "OpenIM/pkg/common/db/table/unrelation"
"Open_IM/pkg/common/db/unrelation" "OpenIM/pkg/common/db/unrelation"
"Open_IM/pkg/common/log" "OpenIM/pkg/common/log"
"Open_IM/pkg/common/prome" "OpenIM/pkg/common/prome"
"Open_IM/pkg/common/tracelog" "OpenIM/pkg/common/tracelog"
"fmt" "fmt"
"github.com/gogo/protobuf/sortkeys" "github.com/gogo/protobuf/sortkeys"
"sync" "sync"
"time" "time"
pbMsg "Open_IM/pkg/proto/msg" pbMsg "OpenIM/pkg/proto/msg"
"Open_IM/pkg/proto/sdkws" "OpenIM/pkg/proto/sdkws"
"Open_IM/pkg/utils" "OpenIM/pkg/utils"
"context" "context"
"errors" "errors"
"github.com/go-redis/redis/v8" "github.com/go-redis/redis/v8"
@ -71,7 +71,6 @@ type MsgDatabaseInterface interface {
GetUserMinSeq(ctx context.Context, userID string) (int64, error) GetUserMinSeq(ctx context.Context, userID string) (int64, error)
GetGroupMaxSeq(ctx context.Context, groupID string) (int64, error) GetGroupMaxSeq(ctx context.Context, groupID string) (int64, error)
GetGroupMinSeq(ctx context.Context, groupID string) (int64, error) GetGroupMinSeq(ctx context.Context, groupID string) (int64, error)
GetMessageListBySeq(ctx context.Context, userID string, seqs []int64) ([]*sdkws.MsgData, error)
} }
func NewMsgDatabase(mgo *mongo.Client, rdb redis.UniversalClient) MsgDatabaseInterface { func NewMsgDatabase(mgo *mongo.Client, rdb redis.UniversalClient) MsgDatabaseInterface {
@ -187,11 +186,6 @@ func (db *MsgDatabase) GetGroupMinSeq(ctx context.Context, groupID string) (int6
return db.cache.GetGroupMinSeq(ctx, groupID) return db.cache.GetGroupMinSeq(ctx, groupID)
} }
func (db *MsgDatabase) GetMessageListBySeq(ctx context.Context, userID string, seqs []int64) ([]*sdkws.MsgData, error) {
seqMsg, _, err := db.cache.GetMessageListBySeq(ctx, userID, seqs)
return seqMsg, err
}
func (db *MsgDatabase) BatchInsertChat2DB(ctx context.Context, sourceID string, msgList []*pbMsg.MsgDataToMQ, currentMaxSeq int64) error { func (db *MsgDatabase) BatchInsertChat2DB(ctx context.Context, sourceID string, msgList []*pbMsg.MsgDataToMQ, currentMaxSeq int64) error {
//newTime := utils.GetCurrentTimestampByMill() //newTime := utils.GetCurrentTimestampByMill()
if int64(len(msgList)) > db.msg.GetSingleGocMsgNum() { if int64(len(msgList)) > db.msg.GetSingleGocMsgNum() {