mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-04-28 22:39:18 +08:00
all back-office api (#533)
* fix conflict Signed-off-by: ‘hanzhixiao’ <‘709674996@qq.com’> * all Back-office management api Signed-off-by: ‘hanzhixiao’ <‘709674996@qq.com’> --------- Signed-off-by: ‘hanzhixiao’ <‘709674996@qq.com’> Co-authored-by: ‘hanzhixiao’ <‘709674996@qq.com’>
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
relation2 "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/relation"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
@@ -102,6 +105,7 @@ type CommonMsgDatabase interface {
|
||||
) (minSeqMongo, maxSeqMongo, minSeqCache, maxSeqCache int64, err error)
|
||||
SetSendMsgStatus(ctx context.Context, id string, status int32) error
|
||||
GetSendMsgStatus(ctx context.Context, id string) (int32, error)
|
||||
SearchMessage(ctx context.Context, req *pbMsg.SearchMessageReq) (msgData []*sdkws.MsgData, err error)
|
||||
|
||||
// to mq
|
||||
MsgToMQ(ctx context.Context, key string, msg2mq *sdkws.MsgData) error
|
||||
@@ -128,8 +132,9 @@ type CommonMsgDatabase interface {
|
||||
) (msgCount int64, userCount int64, groups []*unRelationTb.GroupCount, dateCount map[string]int64, err error)
|
||||
}
|
||||
|
||||
func NewCommonMsgDatabase(msgDocModel unRelationTb.MsgDocModelInterface, cacheModel cache.MsgModel) CommonMsgDatabase {
|
||||
func NewCommonMsgDatabase(msgDocModel unRelationTb.MsgDocModelInterface, cacheModel cache.MsgModel, msgMyqModel relation.ChatLogModelInterface) CommonMsgDatabase {
|
||||
return &commonMsgDatabase{
|
||||
msgMyq: msgMyqModel,
|
||||
msgDocDatabase: msgDocModel,
|
||||
cache: cacheModel,
|
||||
producer: kafka.NewKafkaProducer(config.Config.Kafka.Addr, config.Config.Kafka.LatestMsgToRedis.Topic),
|
||||
@@ -138,16 +143,18 @@ func NewCommonMsgDatabase(msgDocModel unRelationTb.MsgDocModelInterface, cacheMo
|
||||
}
|
||||
}
|
||||
|
||||
func InitCommonMsgDatabase(rdb redis.UniversalClient, database *mongo.Database) CommonMsgDatabase {
|
||||
func InitCommonMsgDatabase(rdb redis.UniversalClient, database *mongo.Database, dbGrom *gorm.DB) CommonMsgDatabase {
|
||||
cacheModel := cache.NewMsgCacheModel(rdb)
|
||||
msgDocModel := unrelation.NewMsgMongoDriver(database)
|
||||
CommonMsgDatabase := NewCommonMsgDatabase(msgDocModel, cacheModel)
|
||||
msgMyqModel := relation2.NewChatLogGorm(dbGrom)
|
||||
CommonMsgDatabase := NewCommonMsgDatabase(msgDocModel, cacheModel, msgMyqModel)
|
||||
return CommonMsgDatabase
|
||||
}
|
||||
|
||||
type commonMsgDatabase struct {
|
||||
msgDocDatabase unRelationTb.MsgDocModelInterface
|
||||
msg unRelationTb.MsgDocModel
|
||||
msgMyq relation.ChatLogModelInterface
|
||||
cache cache.MsgModel
|
||||
producer *kafka.Producer
|
||||
producerToMongo *kafka.Producer
|
||||
@@ -1163,3 +1170,15 @@ func (db *commonMsgDatabase) RangeGroupSendCount(
|
||||
) (msgCount int64, userCount int64, groups []*unRelationTb.GroupCount, dateCount map[string]int64, err error) {
|
||||
return db.msgDocDatabase.RangeGroupSendCount(ctx, start, end, ase, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
func (db *commonMsgDatabase) SearchMessage(ctx context.Context, req *pbMsg.SearchMessageReq) (msgData []*sdkws.MsgData, err error) {
|
||||
var totalMsgs []*sdkws.MsgData
|
||||
msgs, err := db.msgDocDatabase.SearchMessage(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, msg := range msgs {
|
||||
totalMsgs = append(totalMsgs, convert.MsgDB2Pb(msg.Msg))
|
||||
}
|
||||
return totalMsgs, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user