|
|
|
package group
|
|
|
|
|
|
|
|
import (
|
|
|
|
"Open_IM/pkg/common/db/table/relation"
|
|
|
|
pbGroup "Open_IM/pkg/proto/group"
|
|
|
|
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func DbToPbGroupInfo(m *relation.GroupModel, ownerUserID string, memberCount uint32) *open_im_sdk.GroupInfo {
|
|
|
|
return &open_im_sdk.GroupInfo{
|
|
|
|
GroupID: m.GroupID,
|
|
|
|
GroupName: m.GroupName,
|
|
|
|
Notification: m.Notification,
|
|
|
|
Introduction: m.Introduction,
|
|
|
|
FaceURL: m.FaceURL,
|
|
|
|
OwnerUserID: ownerUserID,
|
|
|
|
CreateTime: m.CreateTime.UnixMilli(),
|
|
|
|
MemberCount: memberCount,
|
|
|
|
Ex: m.Ex,
|
|
|
|
Status: m.Status,
|
|
|
|
CreatorUserID: m.CreatorUserID,
|
|
|
|
GroupType: m.GroupType,
|
|
|
|
NeedVerification: m.NeedVerification,
|
|
|
|
LookMemberInfo: m.LookMemberInfo,
|
|
|
|
ApplyMemberFriend: m.ApplyMemberFriend,
|
|
|
|
NotificationUpdateTime: m.NotificationUpdateTime.UnixMilli(),
|
|
|
|
NotificationUserID: m.NotificationUserID,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func PbToDbGroupRequest(req *pbGroup.GroupApplicationResponseReq, handleUserID string) *relation.GroupRequestModel {
|
|
|
|
return &relation.GroupRequestModel{
|
|
|
|
UserID: req.FromUserID,
|
|
|
|
GroupID: req.GroupID,
|
|
|
|
HandleResult: req.HandleResult,
|
|
|
|
HandledMsg: req.HandledMsg,
|
|
|
|
HandleUserID: handleUserID,
|
|
|
|
HandledTime: time.Now(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func PbToDbMapGroupInfoForSet(group *open_im_sdk.GroupInfoForSet) map[string]any {
|
|
|
|
m := make(map[string]any)
|
|
|
|
if group.GroupName != "" {
|
|
|
|
m["group_name"] = group.GroupName
|
|
|
|
}
|
|
|
|
if group.Notification != "" {
|
|
|
|
m["notification"] = group.Notification
|
|
|
|
}
|
|
|
|
if group.Introduction != "" {
|
|
|
|
m["introduction"] = group.Introduction
|
|
|
|
}
|
|
|
|
if group.FaceURL != "" {
|
|
|
|
m["face_url"] = group.FaceURL
|
|
|
|
}
|
|
|
|
if group.NeedVerification != nil {
|
|
|
|
m["need_verification"] = group.NeedVerification.Value
|
|
|
|
}
|
|
|
|
if group.LookMemberInfo != nil {
|
|
|
|
m["look_member_info"] = group.LookMemberInfo.Value
|
|
|
|
}
|
|
|
|
if group.ApplyMemberFriend != nil {
|
|
|
|
m["apply_member_friend"] = group.ApplyMemberFriend.Value
|
|
|
|
}
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func DbToBpCMSGroup(m *relation.GroupModel, ownerUserID string, ownerUserName string, memberCount uint32) *pbGroup.CMSGroup {
|
|
|
|
return &pbGroup.CMSGroup{
|
|
|
|
GroupInfo: DbToPbGroupInfo(m, ownerUserID, memberCount),
|
|
|
|
GroupOwnerUserID: ownerUserID,
|
|
|
|
GroupOwnerUserName: ownerUserName,
|
|
|
|
}
|
|
|
|
}
|