mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-03 08:35:59 +08:00
errcode
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package unrelation
|
||||
|
||||
import (
|
||||
common "Open_IM/pkg/proto/sdk_ws"
|
||||
common "Open_IM/pkg/proto/sdkws"
|
||||
"context"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package unrelation
|
||||
|
||||
import "strconv"
|
||||
|
||||
const (
|
||||
singleGocMsgNum = 5000
|
||||
CChat = "msg"
|
||||
)
|
||||
|
||||
type UserChatModel struct {
|
||||
UID string `bson:"uid"`
|
||||
Msg []MsgInfoModel `bson:"msg"`
|
||||
}
|
||||
|
||||
type MsgInfoModel struct {
|
||||
SendTime int64 `bson:"sendtime"`
|
||||
Msg []byte `bson:"msg"`
|
||||
}
|
||||
|
||||
func (UserChatModel) TableName() string {
|
||||
return CChat
|
||||
}
|
||||
|
||||
func (UserChatModel) GetSingleGocMsgNum() int {
|
||||
return singleGocMsgNum
|
||||
}
|
||||
|
||||
func (u UserChatModel) getSeqUid(uid string, seq uint32) string {
|
||||
seqSuffix := seq / singleGocMsgNum
|
||||
return u.indexGen(uid, seqSuffix)
|
||||
}
|
||||
|
||||
func (u UserChatModel) getSeqUserIDList(userID string, maxSeq uint32) []string {
|
||||
seqMaxSuffix := maxSeq / singleGocMsgNum
|
||||
var seqUserIDList []string
|
||||
for i := 0; i <= int(seqMaxSuffix); i++ {
|
||||
seqUserID := u.indexGen(userID, uint32(i))
|
||||
seqUserIDList = append(seqUserIDList, seqUserID)
|
||||
}
|
||||
return seqUserIDList
|
||||
}
|
||||
|
||||
func (UserChatModel) getSeqSuperGroupID(groupID string, seq uint32) string {
|
||||
seqSuffix := seq / singleGocMsgNum
|
||||
return superGroupIndexGen(groupID, seqSuffix)
|
||||
}
|
||||
|
||||
func (u UserChatModel) GetSeqUid(uid string, seq uint32) string {
|
||||
return u.getSeqUid(uid, seq)
|
||||
}
|
||||
|
||||
func (UserChatModel) getMsgIndex(seq uint32) int {
|
||||
seqSuffix := seq / singleGocMsgNum
|
||||
var index uint32
|
||||
if seqSuffix == 0 {
|
||||
index = (seq - seqSuffix*singleGocMsgNum) - 1
|
||||
} else {
|
||||
index = seq - seqSuffix*singleGocMsgNum
|
||||
}
|
||||
return int(index)
|
||||
}
|
||||
|
||||
func (UserChatModel) indexGen(uid string, seqSuffix uint32) string {
|
||||
return uid + ":" + strconv.FormatInt(int64(seqSuffix), 10)
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package unrelation
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -37,13 +38,6 @@ type SuperGroupModelInterface interface {
|
||||
RemoveGroupFromUser(ctx context.Context, groupID string, userIDs []string, tx ...any) error
|
||||
}
|
||||
|
||||
//type SuperGroupModelInterface interface {
|
||||
// // tx is your transaction object
|
||||
// CreateSuperGroup(ctx context.Context, groupID string, initMemberIDs []string, tx ...interface{}) error
|
||||
// FindSuperGroup(ctx context.Context, groupIDs []string, tx ...interface{}) ([]*SuperGroupModel, error)
|
||||
// //GetSuperGroup(ctx context.Context, groupID string) (SuperGroupModel, error)
|
||||
// AddUserToSuperGroup(ctx context.Context, groupID string, userIDs []string, tx ...interface{}) error
|
||||
// RemoverUserFromSuperGroup(ctx context.Context, groupID string, userIDs []string, tx ...interface{}) error
|
||||
// GetSuperGroupByUserID(ctx context.Context, userID string, tx ...interface{}) (*UserToSuperGroupModel, error)
|
||||
// DeleteSuperGroup(ctx context.Context, groupID string, tx ...interface{}) error
|
||||
//}
|
||||
func superGroupIndexGen(groupID string, seqSuffix uint32) string {
|
||||
return "super_group_" + groupID + ":" + strconv.FormatInt(int64(seqSuffix), 10)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user