复制项目
This commit is contained in:
18
pkg/common/storage/model/application.go
Normal file
18
pkg/common/storage/model/application.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Application struct {
|
||||
ID primitive.ObjectID `bson:"_id"`
|
||||
Platform string `bson:"platform"`
|
||||
Hot bool `bson:"hot"`
|
||||
Version string `bson:"version"`
|
||||
Url string `bson:"url"`
|
||||
Text string `bson:"text"`
|
||||
Force bool `bson:"force"`
|
||||
Latest bool `bson:"latest"`
|
||||
CreateTime time.Time `bson:"create_time"`
|
||||
}
|
||||
28
pkg/common/storage/model/black.go
Normal file
28
pkg/common/storage/model/black.go
Normal file
@@ -0,0 +1,28 @@
|
||||
// Copyright © 2023 OpenIM. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type Black struct {
|
||||
OwnerUserID string `bson:"owner_user_id"`
|
||||
BlockUserID string `bson:"block_user_id"`
|
||||
CreateTime time.Time `bson:"create_time"`
|
||||
AddSource int32 `bson:"add_source"`
|
||||
OperatorUserID string `bson:"operator_user_id"`
|
||||
Ex string `bson:"ex"`
|
||||
}
|
||||
9
pkg/common/storage/model/cache.go
Normal file
9
pkg/common/storage/model/cache.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
type Cache struct {
|
||||
Key string `bson:"key"`
|
||||
Value string `bson:"value"`
|
||||
ExpireAt *time.Time `bson:"expire_at"`
|
||||
}
|
||||
7
pkg/common/storage/model/client_config.go
Normal file
7
pkg/common/storage/model/client_config.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package model
|
||||
|
||||
type ClientConfig struct {
|
||||
Key string `bson:"key"`
|
||||
UserID string `bson:"user_id"`
|
||||
Value string `bson:"value"`
|
||||
}
|
||||
40
pkg/common/storage/model/conversation.go
Normal file
40
pkg/common/storage/model/conversation.go
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright © 2023 OpenIM. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type Conversation struct {
|
||||
OwnerUserID string `bson:"owner_user_id"`
|
||||
ConversationID string `bson:"conversation_id"`
|
||||
ConversationType int32 `bson:"conversation_type"`
|
||||
UserID string `bson:"user_id"`
|
||||
GroupID string `bson:"group_id"`
|
||||
RecvMsgOpt int32 `bson:"recv_msg_opt"`
|
||||
IsPinned bool `bson:"is_pinned"`
|
||||
IsPrivateChat bool `bson:"is_private_chat"`
|
||||
BurnDuration int32 `bson:"burn_duration"`
|
||||
GroupAtType int32 `bson:"group_at_type"`
|
||||
AttachedInfo string `bson:"attached_info"`
|
||||
Ex string `bson:"ex"`
|
||||
MaxSeq int64 `bson:"max_seq"`
|
||||
MinSeq int64 `bson:"min_seq"`
|
||||
CreateTime time.Time `bson:"create_time"`
|
||||
IsMsgDestruct bool `bson:"is_msg_destruct"`
|
||||
MsgDestructTime int64 `bson:"msg_destruct_time"`
|
||||
LatestMsgDestructTime time.Time `bson:"latest_msg_destruct_time"`
|
||||
}
|
||||
15
pkg/common/storage/model/doc.go
Normal file
15
pkg/common/storage/model/doc.go
Normal file
@@ -0,0 +1,15 @@
|
||||
// Copyright © 2024 OpenIM. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package model // import "git.imall.cloud/openim/open-im-server-deploy/pkg/common/storage/model/relation"
|
||||
33
pkg/common/storage/model/friend.go
Normal file
33
pkg/common/storage/model/friend.go
Normal file
@@ -0,0 +1,33 @@
|
||||
// Copyright © 2023 OpenIM. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Friend represents the data structure for a friend relationship in MongoDB.
|
||||
type Friend struct {
|
||||
ID primitive.ObjectID `bson:"_id"`
|
||||
OwnerUserID string `bson:"owner_user_id"`
|
||||
FriendUserID string `bson:"friend_user_id"`
|
||||
Remark string `bson:"remark"`
|
||||
CreateTime time.Time `bson:"create_time"`
|
||||
AddSource int32 `bson:"add_source"`
|
||||
OperatorUserID string `bson:"operator_user_id"`
|
||||
Ex string `bson:"ex"`
|
||||
IsPinned bool `bson:"is_pinned"`
|
||||
}
|
||||
31
pkg/common/storage/model/friend_request.go
Normal file
31
pkg/common/storage/model/friend_request.go
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright © 2023 OpenIM. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type FriendRequest struct {
|
||||
FromUserID string `bson:"from_user_id"`
|
||||
ToUserID string `bson:"to_user_id"`
|
||||
HandleResult int32 `bson:"handle_result"`
|
||||
ReqMsg string `bson:"req_msg"`
|
||||
CreateTime time.Time `bson:"create_time"`
|
||||
HandlerUserID string `bson:"handler_user_id"`
|
||||
HandleMsg string `bson:"handle_msg"`
|
||||
HandleTime time.Time `bson:"handle_time"`
|
||||
Ex string `bson:"ex"`
|
||||
}
|
||||
37
pkg/common/storage/model/group.go
Normal file
37
pkg/common/storage/model/group.go
Normal file
@@ -0,0 +1,37 @@
|
||||
// Copyright © 2023 OpenIM. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type Group struct {
|
||||
GroupID string `bson:"group_id"`
|
||||
GroupName string `bson:"group_name"`
|
||||
Notification string `bson:"notification"`
|
||||
Introduction string `bson:"introduction"`
|
||||
FaceURL string `bson:"face_url"`
|
||||
CreateTime time.Time `bson:"create_time"`
|
||||
Ex string `bson:"ex"`
|
||||
Status int32 `bson:"status"`
|
||||
CreatorUserID string `bson:"creator_user_id"`
|
||||
GroupType int32 `bson:"group_type"`
|
||||
NeedVerification int32 `bson:"need_verification"`
|
||||
LookMemberInfo int32 `bson:"look_member_info"`
|
||||
ApplyMemberFriend int32 `bson:"apply_member_friend"`
|
||||
NotificationUpdateTime time.Time `bson:"notification_update_time"`
|
||||
NotificationUserID string `bson:"notification_user_id"`
|
||||
}
|
||||
35
pkg/common/storage/model/group_member.go
Normal file
35
pkg/common/storage/model/group_member.go
Normal file
@@ -0,0 +1,35 @@
|
||||
// Copyright © 2023 OpenIM. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type GroupMember struct {
|
||||
GroupID string `bson:"group_id"`
|
||||
UserID string `bson:"user_id"`
|
||||
Nickname string `bson:"nickname"`
|
||||
FaceURL string `bson:"face_url"`
|
||||
RoleLevel int32 `bson:"role_level"`
|
||||
JoinTime time.Time `bson:"join_time"`
|
||||
JoinSource int32 `bson:"join_source"`
|
||||
InviterUserID string `bson:"inviter_user_id"`
|
||||
OperatorUserID string `bson:"operator_user_id"`
|
||||
MuteEndTime time.Time `bson:"mute_end_time"`
|
||||
Ex string `bson:"ex"`
|
||||
UserType int32 `bson:"user_type"`
|
||||
UserFlag string `bson:"user_flag"`
|
||||
}
|
||||
33
pkg/common/storage/model/group_request.go
Normal file
33
pkg/common/storage/model/group_request.go
Normal file
@@ -0,0 +1,33 @@
|
||||
// Copyright © 2023 OpenIM. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type GroupRequest struct {
|
||||
UserID string `bson:"user_id"`
|
||||
GroupID string `bson:"group_id"`
|
||||
HandleResult int32 `bson:"handle_result"`
|
||||
ReqMsg string `bson:"req_msg"`
|
||||
HandledMsg string `bson:"handled_msg"`
|
||||
ReqTime time.Time `bson:"req_time"`
|
||||
HandleUserID string `bson:"handle_user_id"`
|
||||
HandledTime time.Time `bson:"handled_time"`
|
||||
JoinSource int32 `bson:"join_source"`
|
||||
InviterUserID string `bson:"inviter_user_id"`
|
||||
Ex string `bson:"ex"`
|
||||
}
|
||||
32
pkg/common/storage/model/log.go
Normal file
32
pkg/common/storage/model/log.go
Normal file
@@ -0,0 +1,32 @@
|
||||
// Copyright © 2023 OpenIM. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type Log struct {
|
||||
LogID string `bson:"log_id"`
|
||||
Platform string `bson:"platform"`
|
||||
UserID string `bson:"user_id"`
|
||||
CreateTime time.Time `bson:"create_time"`
|
||||
Url string `bson:"url"`
|
||||
FileName string `bson:"file_name"`
|
||||
SystemType string `bson:"system_type"`
|
||||
AppFramework string `bson:"app_framework"`
|
||||
Version string `bson:"version"`
|
||||
Ex string `bson:"ex"`
|
||||
}
|
||||
57
pkg/common/storage/model/meeting.go
Normal file
57
pkg/common/storage/model/meeting.go
Normal file
@@ -0,0 +1,57 @@
|
||||
// Copyright © 2023 OpenIM. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
MeetingTableName = "meetings"
|
||||
)
|
||||
|
||||
// MeetingStatus 会议状态
|
||||
const (
|
||||
MeetingStatusScheduled = 1 // 已预约
|
||||
MeetingStatusOngoing = 2 // 进行中
|
||||
MeetingStatusFinished = 3 // 已结束
|
||||
MeetingStatusCancelled = 4 // 已取消
|
||||
)
|
||||
|
||||
// Meeting 会议表
|
||||
type Meeting struct {
|
||||
MeetingID string `bson:"meeting_id"` // 会议ID(唯一)
|
||||
Subject string `bson:"subject"` // 会议主题
|
||||
CoverURL string `bson:"cover_url"` // 封面URL
|
||||
ScheduledTime time.Time `bson:"scheduled_time"` // 预约时间
|
||||
Status int32 `bson:"status"` // 会议状态:1-已预约,2-进行中,3-已结束,4-已取消
|
||||
CreatorUserID string `bson:"creator_user_id"` // 创建者用户ID
|
||||
Description string `bson:"description"` // 会议描述
|
||||
Duration int32 `bson:"duration"` // 会议时长(分钟)
|
||||
EstimatedCount int32 `bson:"estimated_count"` // 会议预估人数
|
||||
EnableMic bool `bson:"enable_mic"` // 是否开启连麦
|
||||
EnableComment bool `bson:"enable_comment"` // 是否开启评论
|
||||
AnchorUserIDs []string `bson:"anchor_user_ids"` // 主播用户ID列表(多选)
|
||||
GroupID string `bson:"group_id"` // 关联的群聊ID
|
||||
CheckInCount int32 `bson:"check_in_count"` // 签到人数统计
|
||||
Password string `bson:"password"` // 会议密码(6位数字)
|
||||
CreateTime time.Time `bson:"create_time"` // 创建时间
|
||||
UpdateTime time.Time `bson:"update_time"` // 更新时间
|
||||
Ex string `bson:"ex"` // 扩展字段
|
||||
}
|
||||
|
||||
func (*Meeting) TableName() string {
|
||||
return MeetingTableName
|
||||
}
|
||||
38
pkg/common/storage/model/meeting_checkin.go
Normal file
38
pkg/common/storage/model/meeting_checkin.go
Normal file
@@ -0,0 +1,38 @@
|
||||
// Copyright © 2023 OpenIM. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
MeetingCheckInTableName = "meeting_checkins"
|
||||
)
|
||||
|
||||
// MeetingCheckIn 会议签到表
|
||||
type MeetingCheckIn struct {
|
||||
CheckInID string `bson:"check_in_id"` // 签到ID(唯一)
|
||||
MeetingID string `bson:"meeting_id"` // 会议ID
|
||||
UserID string `bson:"user_id"` // 用户ID
|
||||
CheckInTime time.Time `bson:"check_in_time"` // 签到时间
|
||||
CreateTime time.Time `bson:"create_time"` // 创建时间
|
||||
Ex string `bson:"ex"` // 扩展字段
|
||||
}
|
||||
|
||||
func (*MeetingCheckIn) TableName() string {
|
||||
return MeetingCheckInTableName
|
||||
}
|
||||
|
||||
158
pkg/common/storage/model/msg.go
Normal file
158
pkg/common/storage/model/msg.go
Normal file
@@ -0,0 +1,158 @@
|
||||
// Copyright © 2023 OpenIM. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"git.imall.cloud/openim/protocol/sdkws"
|
||||
"github.com/openimsdk/tools/errs"
|
||||
)
|
||||
|
||||
const (
|
||||
singleGocMsgNum = 100
|
||||
singleGocMsgNum5000 = 5000
|
||||
MsgTableName = "msg"
|
||||
OldestList = 0
|
||||
NewestList = -1
|
||||
)
|
||||
|
||||
var ErrMsgListNotExist = errs.New("user not have msg in mongoDB")
|
||||
|
||||
type MsgDocModel struct {
|
||||
DocID string `bson:"doc_id"`
|
||||
Msg []*MsgInfoModel `bson:"msgs"`
|
||||
}
|
||||
|
||||
type RevokeModel struct {
|
||||
Role int32 `bson:"role"`
|
||||
UserID string `bson:"user_id"`
|
||||
Nickname string `bson:"nickname"`
|
||||
Time int64 `bson:"time"`
|
||||
}
|
||||
|
||||
type OfflinePushModel struct {
|
||||
Title string `bson:"title"`
|
||||
Desc string `bson:"desc"`
|
||||
Ex string `bson:"ex"`
|
||||
IOSPushSound string `bson:"ios_push_sound"`
|
||||
IOSBadgeCount bool `bson:"ios_badge_count"`
|
||||
}
|
||||
|
||||
type MsgDataModel struct {
|
||||
SendID string `bson:"send_id"`
|
||||
RecvID string `bson:"recv_id"`
|
||||
GroupID string `bson:"group_id"`
|
||||
ClientMsgID string `bson:"client_msg_id"`
|
||||
ServerMsgID string `bson:"server_msg_id"`
|
||||
SenderPlatformID int32 `bson:"sender_platform_id"`
|
||||
SenderNickname string `bson:"sender_nickname"`
|
||||
SenderFaceURL string `bson:"sender_face_url"`
|
||||
SessionType int32 `bson:"session_type"`
|
||||
MsgFrom int32 `bson:"msg_from"`
|
||||
ContentType int32 `bson:"content_type"`
|
||||
Content string `bson:"content"`
|
||||
Seq int64 `bson:"seq"`
|
||||
SendTime int64 `bson:"send_time"`
|
||||
CreateTime int64 `bson:"create_time"`
|
||||
Status int32 `bson:"status"`
|
||||
IsRead bool `bson:"is_read"`
|
||||
Options map[string]bool `bson:"options"`
|
||||
OfflinePush *OfflinePushModel `bson:"offline_push"`
|
||||
AtUserIDList []string `bson:"at_user_id_list"`
|
||||
AttachedInfo string `bson:"attached_info"`
|
||||
Ex string `bson:"ex"`
|
||||
}
|
||||
|
||||
type MsgInfoModel struct {
|
||||
Msg *MsgDataModel `bson:"msg"`
|
||||
Revoke *RevokeModel `bson:"revoke"`
|
||||
DelList []string `bson:"del_list"`
|
||||
IsRead bool `bson:"is_read"`
|
||||
}
|
||||
|
||||
type UserCount struct {
|
||||
UserID string `bson:"user_id"`
|
||||
Count int64 `bson:"count"`
|
||||
}
|
||||
|
||||
type GroupCount struct {
|
||||
GroupID string `bson:"group_id"`
|
||||
Count int64 `bson:"count"`
|
||||
}
|
||||
|
||||
func (*MsgDocModel) TableName() string {
|
||||
return MsgTableName
|
||||
}
|
||||
|
||||
func (*MsgDocModel) GetSingleGocMsgNum() int64 {
|
||||
return singleGocMsgNum
|
||||
}
|
||||
|
||||
func (*MsgDocModel) GetSingleGocMsgNum5000() int64 {
|
||||
return singleGocMsgNum5000
|
||||
}
|
||||
|
||||
func (m *MsgDocModel) IsFull() bool {
|
||||
return m.Msg[len(m.Msg)-1].Msg != nil
|
||||
}
|
||||
|
||||
func (m *MsgDocModel) GetDocIndex(seq int64) int64 {
|
||||
return (seq - 1) / singleGocMsgNum
|
||||
}
|
||||
|
||||
func (m *MsgDocModel) GetDocID(conversationID string, seq int64) string {
|
||||
seqSuffix := (seq - 1) / singleGocMsgNum
|
||||
return m.indexGen(conversationID, seqSuffix)
|
||||
}
|
||||
|
||||
func (m *MsgDocModel) GetDocIDSeqsMap(conversationID string, seqs []int64) map[string][]int64 {
|
||||
t := make(map[string][]int64)
|
||||
for _, seq := range seqs {
|
||||
docID := m.GetDocID(conversationID, seq)
|
||||
t[docID] = append(t[docID], seq)
|
||||
}
|
||||
|
||||
return t
|
||||
}
|
||||
|
||||
func (*MsgDocModel) GetMsgIndex(seq int64) int64 {
|
||||
return (seq - 1) % singleGocMsgNum
|
||||
}
|
||||
|
||||
func (*MsgDocModel) GetLimitForSingleDoc(seq int64) int64 {
|
||||
return seq % singleGocMsgNum
|
||||
}
|
||||
|
||||
func (*MsgDocModel) indexGen(conversationID string, seqSuffix int64) string {
|
||||
return conversationID + ":" + strconv.FormatInt(seqSuffix, 10)
|
||||
}
|
||||
|
||||
func (*MsgDocModel) BuildDocIDByIndex(conversationID string, index int64) string {
|
||||
return conversationID + ":" + strconv.FormatInt(index, 10)
|
||||
}
|
||||
|
||||
func (*MsgDocModel) GenExceptionMessageBySeqs(seqs []int64) (exceptionMsg []*sdkws.MsgData) {
|
||||
for _, v := range seqs {
|
||||
msgModel := new(sdkws.MsgData)
|
||||
msgModel.Seq = v
|
||||
exceptionMsg = append(exceptionMsg, msgModel)
|
||||
}
|
||||
return exceptionMsg
|
||||
}
|
||||
|
||||
func (*MsgDocModel) GetMinSeq(index int) int64 {
|
||||
return int64(index*singleGocMsgNum) + 1
|
||||
}
|
||||
31
pkg/common/storage/model/object.go
Normal file
31
pkg/common/storage/model/object.go
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright © 2023 OpenIM. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type Object struct {
|
||||
Name string `bson:"name"`
|
||||
UserID string `bson:"user_id"`
|
||||
Hash string `bson:"hash"`
|
||||
Engine string `bson:"engine"`
|
||||
Key string `bson:"key"`
|
||||
Size int64 `bson:"size"`
|
||||
ContentType string `bson:"content_type"`
|
||||
Group string `bson:"group"`
|
||||
CreateTime time.Time `bson:"create_time"`
|
||||
}
|
||||
75
pkg/common/storage/model/redpacket.go
Normal file
75
pkg/common/storage/model/redpacket.go
Normal file
@@ -0,0 +1,75 @@
|
||||
// Copyright © 2023 OpenIM. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
RedPacketTableName = "red_packets"
|
||||
RedPacketReceiveTableName = "red_packet_receives"
|
||||
)
|
||||
|
||||
// RedPacketType 红包类型
|
||||
const (
|
||||
RedPacketTypeNormal = 1 // 普通红包(平均分配)
|
||||
RedPacketTypeRandom = 2 // 拼手气红包(随机分配)
|
||||
)
|
||||
|
||||
// RedPacketStatus 红包状态
|
||||
const (
|
||||
RedPacketStatusActive = 0 // 进行中
|
||||
RedPacketStatusFinished = 1 // 已领完
|
||||
RedPacketStatusExpired = 2 // 已过期
|
||||
)
|
||||
|
||||
// RedPacket 红包主表
|
||||
type RedPacket struct {
|
||||
RedPacketID string `bson:"red_packet_id"` // 红包ID
|
||||
SendUserID string `bson:"send_user_id"` // 发送者ID
|
||||
GroupID string `bson:"group_id"` // 群ID(群红包)
|
||||
ConversationID string `bson:"conversation_id"` // 会话ID
|
||||
SessionType int32 `bson:"session_type"` // 会话类型:1-单聊,3-群聊
|
||||
RedPacketType int32 `bson:"red_packet_type"` // 红包类型:1-普通红包,2-拼手气红包
|
||||
TotalAmount int64 `bson:"total_amount"` // 总金额(分)
|
||||
TotalCount int32 `bson:"total_count"` // 总个数
|
||||
RemainAmount int64 `bson:"remain_amount"` // 剩余金额(分)
|
||||
RemainCount int32 `bson:"remain_count"` // 剩余个数
|
||||
Blessing string `bson:"blessing"` // 祝福语
|
||||
Status int32 `bson:"status"` // 状态:0-进行中,1-已领完,2-已过期
|
||||
ExpireTime time.Time `bson:"expire_time"` // 过期时间(默认24小时)
|
||||
CreateTime time.Time `bson:"create_time"` // 创建时间
|
||||
Ex string `bson:"ex"` // 扩展字段
|
||||
}
|
||||
|
||||
// RedPacketReceive 红包领取记录表
|
||||
type RedPacketReceive struct {
|
||||
ReceiveID string `bson:"receive_id"` // 领取记录ID
|
||||
RedPacketID string `bson:"red_packet_id"` // 红包ID
|
||||
ReceiveUserID string `bson:"receive_user_id"` // 领取者ID
|
||||
Amount int64 `bson:"amount"` // 领取金额(分)
|
||||
ReceiveTime time.Time `bson:"receive_time"` // 领取时间
|
||||
IsLucky bool `bson:"is_lucky"` // 是否为手气最佳(仅拼手气红包有效)
|
||||
Ex string `bson:"ex"` // 扩展字段
|
||||
}
|
||||
|
||||
func (*RedPacket) TableName() string {
|
||||
return RedPacketTableName
|
||||
}
|
||||
|
||||
func (*RedPacketReceive) TableName() string {
|
||||
return RedPacketReceiveTableName
|
||||
}
|
||||
7
pkg/common/storage/model/seq.go
Normal file
7
pkg/common/storage/model/seq.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package model
|
||||
|
||||
type SeqConversation struct {
|
||||
ConversationID string `bson:"conversation_id"`
|
||||
MaxSeq int64 `bson:"max_seq"`
|
||||
MinSeq int64 `bson:"min_seq"`
|
||||
}
|
||||
9
pkg/common/storage/model/seq_user.go
Normal file
9
pkg/common/storage/model/seq_user.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package model
|
||||
|
||||
type SeqUser struct {
|
||||
UserID string `bson:"user_id"`
|
||||
ConversationID string `bson:"conversation_id"`
|
||||
MinSeq int64 `bson:"min_seq"`
|
||||
MaxSeq int64 `bson:"max_seq"`
|
||||
ReadSeq int64 `bson:"read_seq"`
|
||||
}
|
||||
30
pkg/common/storage/model/subscribe.go
Normal file
30
pkg/common/storage/model/subscribe.go
Normal file
@@ -0,0 +1,30 @@
|
||||
// Copyright © 2023 OpenIM. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package model
|
||||
|
||||
// SubscribeUserTableName collection constant.
|
||||
const (
|
||||
SubscribeUserTableName = "subscribe_user"
|
||||
)
|
||||
|
||||
// SubscribeUser collection structure.
|
||||
type SubscribeUser struct {
|
||||
UserID string `bson:"user_id" json:"userID"`
|
||||
UserIDList []string `bson:"user_id_list" json:"userIDList"`
|
||||
}
|
||||
|
||||
func (SubscribeUser) TableName() string {
|
||||
return SubscribeUserTableName
|
||||
}
|
||||
48
pkg/common/storage/model/system_config.go
Normal file
48
pkg/common/storage/model/system_config.go
Normal file
@@ -0,0 +1,48 @@
|
||||
// Copyright © 2023 OpenIM. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
SystemConfigTableName = "system_configs"
|
||||
)
|
||||
|
||||
// SystemConfigValueType 配置值类型
|
||||
const (
|
||||
SystemConfigValueTypeString = 1 // 字符串
|
||||
SystemConfigValueTypeNumber = 2 // 数字
|
||||
SystemConfigValueTypeBool = 3 // 布尔
|
||||
SystemConfigValueTypeJSON = 4 // JSON
|
||||
)
|
||||
|
||||
// SystemConfig 系统配置表
|
||||
type SystemConfig struct {
|
||||
Key string `bson:"key"` // 配置键(唯一标识)
|
||||
Title string `bson:"title"` // 配置标题
|
||||
Value string `bson:"value"` // 配置值(字符串形式存储,根据ValueType解析)
|
||||
ValueType int32 `bson:"value_type"` // 配置值类型:1-字符串,2-数字,3-布尔,4-JSON
|
||||
Description string `bson:"description"` // 配置描述
|
||||
Enabled bool `bson:"enabled"` // 是否启用(用于开关类配置)
|
||||
ShowInApp bool `bson:"show_in_app"` // 是否在APP端展示
|
||||
CreateTime time.Time `bson:"create_time"` // 创建时间
|
||||
UpdateTime time.Time `bson:"update_time"` // 更新时间
|
||||
}
|
||||
|
||||
func (*SystemConfig) TableName() string {
|
||||
return SystemConfigTableName
|
||||
}
|
||||
55
pkg/common/storage/model/user.go
Normal file
55
pkg/common/storage/model/user.go
Normal file
@@ -0,0 +1,55 @@
|
||||
// Copyright © 2023 OpenIM. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
UserID string `bson:"user_id"`
|
||||
Nickname string `bson:"nickname"`
|
||||
FaceURL string `bson:"face_url"`
|
||||
Ex string `bson:"ex"`
|
||||
AppMangerLevel int32 `bson:"app_manger_level"`
|
||||
GlobalRecvMsgOpt int32 `bson:"global_recv_msg_opt"`
|
||||
UserType int32 `bson:"user_type"`
|
||||
UserFlag string `bson:"user_flag"`
|
||||
CreateTime time.Time `bson:"create_time"`
|
||||
}
|
||||
|
||||
func (u *User) GetNickname() string {
|
||||
return u.Nickname
|
||||
}
|
||||
|
||||
func (u *User) GetFaceURL() string {
|
||||
return u.FaceURL
|
||||
}
|
||||
|
||||
func (u *User) GetUserID() string {
|
||||
return u.UserID
|
||||
}
|
||||
|
||||
func (u *User) GetEx() string {
|
||||
return u.Ex
|
||||
}
|
||||
|
||||
func (u *User) GetUserType() int32 {
|
||||
return u.UserType
|
||||
}
|
||||
|
||||
func (u *User) GetUserFlag() string {
|
||||
return u.UserFlag
|
||||
}
|
||||
74
pkg/common/storage/model/version_log.go
Normal file
74
pkg/common/storage/model/version_log.go
Normal file
@@ -0,0 +1,74 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/openimsdk/tools/log"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
VersionStateInsert = iota + 1
|
||||
VersionStateDelete
|
||||
VersionStateUpdate
|
||||
)
|
||||
|
||||
const (
|
||||
VersionGroupChangeID = ""
|
||||
VersionSortChangeID = "____S_O_R_T_I_D____"
|
||||
)
|
||||
|
||||
type VersionLogElem struct {
|
||||
EID string `bson:"e_id"`
|
||||
State int32 `bson:"state"`
|
||||
Version uint `bson:"version"`
|
||||
LastUpdate time.Time `bson:"last_update"`
|
||||
}
|
||||
|
||||
type VersionLogTable struct {
|
||||
ID primitive.ObjectID `bson:"_id"`
|
||||
DID string `bson:"d_id"`
|
||||
Logs []VersionLogElem `bson:"logs"`
|
||||
Version uint `bson:"version"`
|
||||
Deleted uint `bson:"deleted"`
|
||||
LastUpdate time.Time `bson:"last_update"`
|
||||
}
|
||||
|
||||
func (v *VersionLogTable) VersionLog() *VersionLog {
|
||||
return &VersionLog{
|
||||
ID: v.ID,
|
||||
DID: v.DID,
|
||||
Logs: v.Logs,
|
||||
Version: v.Version,
|
||||
Deleted: v.Deleted,
|
||||
LastUpdate: v.LastUpdate,
|
||||
LogLen: len(v.Logs),
|
||||
}
|
||||
}
|
||||
|
||||
type VersionLog struct {
|
||||
ID primitive.ObjectID `bson:"_id"`
|
||||
DID string `bson:"d_id"`
|
||||
Logs []VersionLogElem `bson:"logs"`
|
||||
Version uint `bson:"version"`
|
||||
Deleted uint `bson:"deleted"`
|
||||
LastUpdate time.Time `bson:"last_update"`
|
||||
LogLen int `bson:"log_len"`
|
||||
}
|
||||
|
||||
func (v *VersionLog) DeleteAndChangeIDs() (insertIds, deleteIds, updateIds []string) {
|
||||
for _, l := range v.Logs {
|
||||
switch l.State {
|
||||
case VersionStateInsert:
|
||||
insertIds = append(insertIds, l.EID)
|
||||
case VersionStateDelete:
|
||||
deleteIds = append(deleteIds, l.EID)
|
||||
case VersionStateUpdate:
|
||||
updateIds = append(updateIds, l.EID)
|
||||
default:
|
||||
log.ZError(context.Background(), "invalid version status found", errors.New("dirty database data"), "objID", v.ID.Hex(), "did", v.DID, "elem", l)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
56
pkg/common/storage/model/wallet.go
Normal file
56
pkg/common/storage/model/wallet.go
Normal file
@@ -0,0 +1,56 @@
|
||||
// Copyright © 2023 OpenIM. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
WalletTableName = "wallets"
|
||||
WalletBalanceRecordTableName = "wallet_balance_records"
|
||||
)
|
||||
|
||||
// Wallet 用户钱包表
|
||||
type Wallet struct {
|
||||
UserID string `bson:"user_id"` // 用户ID(唯一)
|
||||
Balance int64 `bson:"balance"` // 余额(分)
|
||||
Version int64 `bson:"version"` // 版本号(用于乐观锁,防止并发覆盖)
|
||||
CreateTime time.Time `bson:"create_time"` // 创建时间
|
||||
UpdateTime time.Time `bson:"update_time"` // 更新时间
|
||||
Ex string `bson:"ex"` // 扩展字段
|
||||
}
|
||||
|
||||
type WalletBalanceRecord struct {
|
||||
ID string `bson:"_id"` // 记录ID
|
||||
UserID string `bson:"user_id"` // 用户ID
|
||||
Amount int64 `bson:"amount"` // 变动金额(单位:分,正数表示增加,负数表示减少)
|
||||
Type int32 `bson:"type"` // 变动类型:1-充值,2-提现/提款,3-消费,4-退款,5-奖励,6-后台充值,7-发红包,8-抢红包,99-其他
|
||||
BeforeBalance int64 `bson:"before_balance"` // 变动前余额(单位:分)
|
||||
AfterBalance int64 `bson:"after_balance"` // 变动后余额(单位:分)
|
||||
OrderID string `bson:"order_id"` // 关联订单ID(可选)
|
||||
TransactionID string `bson:"transaction_id"` // 交易ID(可选)
|
||||
RedPacketID string `bson:"red_packet_id"` // 红包ID(用于发红包和抢红包记录关联,可选)
|
||||
Remark string `bson:"remark"` // 备注
|
||||
CreateTime time.Time `bson:"create_time"` // 创建时间
|
||||
}
|
||||
|
||||
func (*Wallet) TableName() string {
|
||||
return WalletTableName
|
||||
}
|
||||
|
||||
func (*WalletBalanceRecord) TableName() string {
|
||||
return WalletBalanceRecordTableName
|
||||
}
|
||||
Reference in New Issue
Block a user