mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-01 07:35:58 +08:00
Merge remote-tracking branch 'origin/errcode' into errcode
# Conflicts: # pkg/common/db/table/table.go
This commit is contained in:
@@ -3,6 +3,7 @@ package controller
|
||||
import (
|
||||
"Open_IM/pkg/common/db/cache"
|
||||
"Open_IM/pkg/common/db/relation"
|
||||
"Open_IM/pkg/common/db/table"
|
||||
"Open_IM/pkg/common/db/unrelation"
|
||||
"context"
|
||||
"github.com/dtm-labs/rockscache"
|
||||
@@ -13,23 +14,23 @@ import (
|
||||
)
|
||||
|
||||
type GroupInterface interface {
|
||||
FindGroupsByID(ctx context.Context, groupIDs []string) (groups []*relation.Group, err error)
|
||||
CreateGroup(ctx context.Context, groups []*relation.Group, groupMember []*relation.GroupMember) error
|
||||
FindGroupsByID(ctx context.Context, groupIDs []string) (groups []*table.GroupModel, err error)
|
||||
CreateGroup(ctx context.Context, groups []*table.GroupModel, groupMember []*table.GroupModel) error
|
||||
DeleteGroupByIDs(ctx context.Context, groupIDs []string) error
|
||||
TakeGroupByID(ctx context.Context, groupID string) (group *relation.Group, err error)
|
||||
TakeGroupMemberByID(ctx context.Context, groupID string, userID string) (groupMember *relation.GroupMember, err error)
|
||||
GetJoinedGroupList(ctx context.Context, userID string) ([]*relation.Group, error)
|
||||
GetGroupMemberList(ctx context.Context, groupID string) ([]*relation.GroupMember, error)
|
||||
GetGroupMemberListByUserID(ctx context.Context, groupID string, userIDs []string) ([]*relation.GroupMember, error)
|
||||
GetGroupMemberFilterList(ctx context.Context, groupID string, filter int32, begin int32, maxNumber int32) ([]*relation.GroupMember, error) // relation.GetGroupMemberByGroupID(req.GroupID, req.Filter, req.NextSeq, 30)
|
||||
FindGroupMembersByID(ctx context.Context, groupID string, userIDs []string) (groups []*relation.GroupMember, err error)
|
||||
TakeGroupByID(ctx context.Context, groupID string) (group *table.GroupModel, err error)
|
||||
TakeGroupMemberByID(ctx context.Context, groupID string, userID string) (groupMember *table.GroupModel, err error)
|
||||
GetJoinedGroupList(ctx context.Context, userID string) ([]*table.GroupModel, error)
|
||||
GetGroupMemberList(ctx context.Context, groupID string) ([]*table.GroupModel, error)
|
||||
GetGroupMemberListByUserID(ctx context.Context, groupID string, userIDs []string) ([]*table.GroupModel, error)
|
||||
GetGroupMemberFilterList(ctx context.Context, groupID string, filter int32, begin int32, maxNumber int32) ([]*table.GroupModel, error) // relation.GetGroupMemberByGroupID(req.GroupID, req.Filter, req.NextSeq, 30)
|
||||
FindGroupMembersByID(ctx context.Context, groupID string, userIDs []string) (groups []*table.GroupModel, err error)
|
||||
DelGroupMember(ctx context.Context, groupID string, userIDs []string) error
|
||||
GetGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]int, error)
|
||||
GetGroupOwnerUserID(ctx context.Context, groupIDs []string) (map[string]string, error)
|
||||
GetGroupRecvApplicationList(ctx context.Context, userID string) ([]*relation.GroupRequest, error)
|
||||
GetGroupRecvApplicationList(ctx context.Context, userID string) ([]*table.GroupRequestModel, error)
|
||||
|
||||
CreateGroupMember(ctx context.Context, groupMember []*relation.GroupMember) error
|
||||
CreateGroupRequest(ctx context.Context, requests []*relation.GroupRequest) error
|
||||
CreateGroupMember(ctx context.Context, groupMember []*table.GroupModel) error
|
||||
CreateGroupRequest(ctx context.Context, requests []*table.GroupRequestModel) error
|
||||
|
||||
//mongo
|
||||
CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error
|
||||
@@ -44,12 +45,12 @@ type GroupController struct {
|
||||
database GroupDataBaseInterface
|
||||
}
|
||||
|
||||
func (g *GroupController) TakeGroupMemberByID(ctx context.Context, groupID string, userID string) (groupMember *relation.GroupMember, err error) {
|
||||
func (g *GroupController) TakeGroupMemberByID(ctx context.Context, groupID string, userID string) (groupMember *table.GroupModel, err error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (g *GroupController) FindGroupMembersByID(ctx context.Context, groupID string, userIDs []string) (groups []*relation.GroupMember, err error) {
|
||||
func (g *GroupController) FindGroupMembersByID(ctx context.Context, groupID string, userIDs []string) (groups []*table.GroupModel, err error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
@@ -59,7 +60,7 @@ func (g *GroupController) DelGroupMember(ctx context.Context, groupID string, us
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (g *GroupController) GetGroupRecvApplicationList(ctx context.Context, userID string) ([]*relation.GroupRequest, error) {
|
||||
func (g *GroupController) GetGroupRecvApplicationList(ctx context.Context, userID string) ([]*table.GroupRequestModel, error) {
|
||||
/*
|
||||
var groupRequestList []db.GroupRequest
|
||||
memberList, err := GetGroupMemberListByUserID(userID)
|
||||
@@ -89,22 +90,22 @@ func (g *GroupController) DelSuperGroupMember(ctx context.Context, groupID strin
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (g *GroupController) GetJoinedGroupList(ctx context.Context, userID string) ([]*relation.Group, error) {
|
||||
func (g *GroupController) GetJoinedGroupList(ctx context.Context, userID string) ([]*table.GroupModel, error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (g *GroupController) GetGroupMemberList(ctx context.Context, groupID string) ([]*relation.GroupMember, error) {
|
||||
func (g *GroupController) GetGroupMemberList(ctx context.Context, groupID string) ([]*table.GroupModel, error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (g *GroupController) GetGroupMemberListByUserID(ctx context.Context, groupID string, userIDs []string) ([]*relation.GroupMember, error) {
|
||||
func (g *GroupController) GetGroupMemberListByUserID(ctx context.Context, groupID string, userIDs []string) ([]*table.GroupModel, error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (g *GroupController) GetGroupMemberFilterList(ctx context.Context, groupID string, filter int32, begin int32, maxNumber int32) ([]*relation.GroupMember, error) {
|
||||
func (g *GroupController) GetGroupMemberFilterList(ctx context.Context, groupID string, filter int32, begin int32, maxNumber int32) ([]*table.GroupModel, error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
@@ -119,12 +120,12 @@ func (g *GroupController) GetGroupOwnerUserID(ctx context.Context, groupIDs []st
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (g *GroupController) CreateGroupMember(ctx context.Context, groupMember []*relation.GroupMember) error {
|
||||
func (g *GroupController) CreateGroupMember(ctx context.Context, groupMember []*table.GroupModel) error {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (g *GroupController) CreateGroupRequest(ctx context.Context, requests []*relation.GroupRequest) error {
|
||||
func (g *GroupController) CreateGroupRequest(ctx context.Context, requests []*table.GroupRequestModel) error {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
@@ -139,11 +140,11 @@ func NewGroupController(db *gorm.DB, rdb redis.UniversalClient, mgoClient *mongo
|
||||
return groupController
|
||||
}
|
||||
|
||||
func (g *GroupController) FindGroupsByID(ctx context.Context, groupIDs []string) (groups []*relation.Group, err error) {
|
||||
func (g *GroupController) FindGroupsByID(ctx context.Context, groupIDs []string) (groups []*table.GroupModel, err error) {
|
||||
return g.database.FindGroupsByID(ctx, groupIDs)
|
||||
}
|
||||
|
||||
func (g *GroupController) CreateGroup(ctx context.Context, groups []*relation.Group, groupMember []*relation.GroupMember) error {
|
||||
func (g *GroupController) CreateGroup(ctx context.Context, groups []*table.GroupModel, groupMember []*table.GroupModel) error {
|
||||
return g.database.CreateGroup(ctx, groups, groupMember)
|
||||
}
|
||||
|
||||
@@ -151,7 +152,7 @@ func (g *GroupController) DeleteGroupByIDs(ctx context.Context, groupIDs []strin
|
||||
return g.database.DeleteGroupByIDs(ctx, groupIDs)
|
||||
}
|
||||
|
||||
func (g *GroupController) TakeGroupByID(ctx context.Context, groupID string) (group *relation.Group, err error) {
|
||||
func (g *GroupController) TakeGroupByID(ctx context.Context, groupID string) (group *table.GroupModel, err error) {
|
||||
return g.database.TakeGroupByID(ctx, groupID)
|
||||
}
|
||||
|
||||
@@ -164,18 +165,18 @@ func (g *GroupController) CreateSuperGroup(ctx context.Context, groupID string,
|
||||
}
|
||||
|
||||
type GroupDataBaseInterface interface {
|
||||
FindGroupsByID(ctx context.Context, groupIDs []string) (groups []*relation.Group, err error)
|
||||
CreateGroup(ctx context.Context, groups []*relation.Group, groupMember []*relation.GroupMember) error
|
||||
FindGroupsByID(ctx context.Context, groupIDs []string) (groups []*table.GroupModel, err error)
|
||||
CreateGroup(ctx context.Context, groups []*table.GroupModel, groupMember []*table.GroupModel) error
|
||||
DeleteGroupByIDs(ctx context.Context, groupIDs []string) error
|
||||
TakeGroupByID(ctx context.Context, groupID string) (group *relation.Group, err error)
|
||||
TakeGroupByID(ctx context.Context, groupID string) (group *table.GroupModel, err error)
|
||||
GetSuperGroupByID(ctx context.Context, groupID string) (superGroup *unrelation.SuperGroup, err error)
|
||||
CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error
|
||||
}
|
||||
|
||||
type GroupDataBase struct {
|
||||
groupDB *relation.Group
|
||||
groupMemberDB *relation.GroupMember
|
||||
groupRequestDB *relation.GroupRequest
|
||||
groupDB *relation.GroupGorm
|
||||
groupMemberDB *relation.GroupMemberGorm
|
||||
groupRequestDB *relation.GroupRequestGorm
|
||||
db *gorm.DB
|
||||
|
||||
cache *cache.GroupCache
|
||||
@@ -204,11 +205,11 @@ func newGroupDatabase(db *gorm.DB, rdb redis.UniversalClient, mgoClient *mongo.C
|
||||
return database
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) FindGroupsByID(ctx context.Context, groupIDs []string) (groups []*relation.Group, err error) {
|
||||
func (g *GroupDataBase) FindGroupsByID(ctx context.Context, groupIDs []string) (groups []*table.GroupModel, err error) {
|
||||
return g.cache.GetGroupsInfo(ctx, groupIDs)
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) CreateGroup(ctx context.Context, groups []*relation.Group, groupMembers []*relation.GroupMember) error {
|
||||
func (g *GroupDataBase) CreateGroup(ctx context.Context, groups []*table.GroupModel, groupMembers []*table.GroupMemberModel) error {
|
||||
return g.db.Transaction(func(tx *gorm.DB) error {
|
||||
if len(groups) > 0 {
|
||||
if err := g.groupDB.Create(ctx, groups, tx); err != nil {
|
||||
@@ -236,11 +237,11 @@ func (g *GroupDataBase) DeleteGroupByIDs(ctx context.Context, groupIDs []string)
|
||||
})
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) TakeGroupByID(ctx context.Context, groupID string) (group *relation.Group, err error) {
|
||||
func (g *GroupDataBase) TakeGroupByID(ctx context.Context, groupID string) (group *table.GroupModel, err error) {
|
||||
return g.cache.GetGroupInfo(ctx, groupID)
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) Update(ctx context.Context, groups []*relation.Group) error {
|
||||
func (g *GroupDataBase) Update(ctx context.Context, groups []*table.GroupModel) error {
|
||||
return g.db.Transaction(func(tx *gorm.DB) error {
|
||||
if err := g.groupDB.Update(ctx, groups, tx); err != nil {
|
||||
return err
|
||||
@@ -256,7 +257,7 @@ func (g *GroupDataBase) Update(ctx context.Context, groups []*relation.Group) er
|
||||
})
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) GetJoinedGroupList(ctx context.Context, userID string) ([]*relation.Group, error) {
|
||||
func (g *GroupDataBase) GetJoinedGroupList(ctx context.Context, userID string) ([]*table.GroupModel, error) {
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user