Files
open-im-server/pkg/common/db/controller/extend_msg.go
T

59 lines
3.6 KiB
Go
Raw Normal View History

2023-02-15 15:52:32 +08:00
package controller
import (
"context"
2023-03-23 19:02:20 +08:00
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
2023-03-16 10:46:06 +08:00
unRelationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
2023-03-23 19:02:20 +08:00
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/tx"
2023-02-15 15:52:32 +08:00
)
2023-03-08 16:35:18 +08:00
// for mongoDB
2023-03-01 15:32:26 +08:00
type ExtendMsgDatabase interface {
2023-02-15 15:52:32 +08:00
CreateExtendMsgSet(ctx context.Context, set *unRelationTb.ExtendMsgSetModel) error
GetAllExtendMsgSet(ctx context.Context, ID string, opts *unRelationTb.GetAllExtendMsgSetOpts) (sets []*unRelationTb.ExtendMsgSetModel, err error)
2023-05-04 15:06:23 +08:00
GetExtendMsgSet(ctx context.Context, conversationID string, sessionType int32, maxMsgUpdateTime int64) (*unRelationTb.ExtendMsgSetModel, error)
InsertExtendMsg(ctx context.Context, conversationID string, sessionType int32, msg *unRelationTb.ExtendMsgModel) error
InsertOrUpdateReactionExtendMsgSet(ctx context.Context, conversationID string, sessionType int32, clientMsgID string, msgFirstModifyTime int64, reactionExtensionList map[string]*unRelationTb.KeyValueModel) error
DeleteReactionExtendMsgSet(ctx context.Context, conversationID string, sessionType int32, clientMsgID string, msgFirstModifyTime int64, reactionExtensionList map[string]*unRelationTb.KeyValueModel) error
GetExtendMsg(ctx context.Context, conversationID string, sessionType int32, clientMsgID string, maxMsgUpdateTime int64) (extendMsg *unRelationTb.ExtendMsgModel, err error)
2023-02-15 15:52:32 +08:00
}
2023-03-01 15:32:26 +08:00
type extendMsgDatabase struct {
2023-03-03 17:42:26 +08:00
database unRelationTb.ExtendMsgSetModelInterface
2023-03-23 19:02:20 +08:00
cache cache.ExtendMsgSetCache
ctxTx tx.CtxTx
2023-02-15 15:52:32 +08:00
}
2023-03-23 19:02:20 +08:00
func NewExtendMsgDatabase(extendMsgModel unRelationTb.ExtendMsgSetModelInterface, cache cache.ExtendMsgSetCache, ctxTx tx.CtxTx) ExtendMsgDatabase {
return &extendMsgDatabase{database: extendMsgModel, cache: cache, ctxTx: ctxTx}
2023-02-15 15:52:32 +08:00
}
2023-03-01 15:32:26 +08:00
func (e *extendMsgDatabase) CreateExtendMsgSet(ctx context.Context, set *unRelationTb.ExtendMsgSetModel) error {
2023-03-03 17:42:26 +08:00
return e.database.CreateExtendMsgSet(ctx, set)
2023-02-15 15:52:32 +08:00
}
2023-05-04 15:06:23 +08:00
func (e *extendMsgDatabase) GetAllExtendMsgSet(ctx context.Context, conversationID string, opts *unRelationTb.GetAllExtendMsgSetOpts) (sets []*unRelationTb.ExtendMsgSetModel, err error) {
return e.database.GetAllExtendMsgSet(ctx, conversationID, opts)
2023-02-15 15:52:32 +08:00
}
2023-05-04 15:06:23 +08:00
func (e *extendMsgDatabase) GetExtendMsgSet(ctx context.Context, conversationID string, sessionType int32, maxMsgUpdateTime int64) (*unRelationTb.ExtendMsgSetModel, error) {
return e.database.GetExtendMsgSet(ctx, conversationID, sessionType, maxMsgUpdateTime)
2023-02-15 15:52:32 +08:00
}
2023-05-04 15:06:23 +08:00
func (e *extendMsgDatabase) InsertExtendMsg(ctx context.Context, conversationID string, sessionType int32, msg *unRelationTb.ExtendMsgModel) error {
return e.database.InsertExtendMsg(ctx, conversationID, sessionType, msg)
2023-02-15 15:52:32 +08:00
}
2023-05-04 15:06:23 +08:00
func (e *extendMsgDatabase) InsertOrUpdateReactionExtendMsgSet(ctx context.Context, conversationID string, sessionType int32, clientMsgID string, msgFirstModifyTime int64, reactionExtensionList map[string]*unRelationTb.KeyValueModel) error {
return e.database.InsertOrUpdateReactionExtendMsgSet(ctx, conversationID, sessionType, clientMsgID, msgFirstModifyTime, reactionExtensionList)
2023-02-15 15:52:32 +08:00
}
2023-03-23 19:02:20 +08:00
2023-05-04 15:06:23 +08:00
func (e *extendMsgDatabase) DeleteReactionExtendMsgSet(ctx context.Context, conversationID string, sessionType int32, clientMsgID string, msgFirstModifyTime int64, reactionExtensionList map[string]*unRelationTb.KeyValueModel) error {
return e.database.DeleteReactionExtendMsgSet(ctx, conversationID, sessionType, clientMsgID, msgFirstModifyTime, reactionExtensionList)
2023-02-15 15:52:32 +08:00
}
2023-05-04 15:06:23 +08:00
func (e *extendMsgDatabase) GetExtendMsg(ctx context.Context, conversationID string, sessionType int32, clientMsgID string, maxMsgUpdateTime int64) (extendMsg *unRelationTb.ExtendMsgModel, err error) {
return e.cache.GetExtendMsg(ctx, conversationID, sessionType, clientMsgID, maxMsgUpdateTime)
2023-02-15 15:52:32 +08:00
}