mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-26 11:36:44 +08:00
1
This commit is contained in:
parent
aafe17a0f3
commit
0f3691893e
@ -8,6 +8,7 @@ import (
|
|||||||
"Open_IM/pkg/common/db/cache"
|
"Open_IM/pkg/common/db/cache"
|
||||||
"Open_IM/pkg/common/db/controller"
|
"Open_IM/pkg/common/db/controller"
|
||||||
"Open_IM/pkg/common/db/relation"
|
"Open_IM/pkg/common/db/relation"
|
||||||
|
"Open_IM/pkg/common/db/table"
|
||||||
"Open_IM/pkg/common/db/unrelation"
|
"Open_IM/pkg/common/db/unrelation"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/middleware"
|
"Open_IM/pkg/common/middleware"
|
||||||
@ -54,7 +55,7 @@ func NewGroupServer(port int) *groupServer {
|
|||||||
//mysql init
|
//mysql init
|
||||||
var mysql relation.Mysql
|
var mysql relation.Mysql
|
||||||
var mongo unrelation.Mongo
|
var mongo unrelation.Mongo
|
||||||
var groupModel relation.Group
|
var groupModel table.GroupModel
|
||||||
var redis cache.RedisClient
|
var redis cache.RedisClient
|
||||||
err := mysql.InitConn().AutoMigrateModel(&groupModel)
|
err := mysql.InitConn().AutoMigrateModel(&groupModel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -170,7 +171,7 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
|
|||||||
if err := callbackBeforeCreateGroup(ctx, req); err != nil {
|
if err := callbackBeforeCreateGroup(ctx, req); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var group relation.Group
|
var group relation.GroupGorm
|
||||||
var groupMembers []*relation.GroupMember
|
var groupMembers []*relation.GroupMember
|
||||||
utils.CopyStructFields(&group, req.GroupInfo)
|
utils.CopyStructFields(&group, req.GroupInfo)
|
||||||
group.GroupID = genGroupID(ctx, req.GroupInfo.GroupID)
|
group.GroupID = genGroupID(ctx, req.GroupInfo.GroupID)
|
||||||
@ -203,7 +204,7 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := s.GroupInterface.CreateGroup(ctx, []*relation.Group{&group}, groupMembers); err != nil {
|
if err := s.GroupInterface.CreateGroup(ctx, []*relation.GroupGorm{&group}, groupMembers); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
utils.CopyStructFields(resp.GroupInfo, group)
|
utils.CopyStructFields(resp.GroupInfo, group)
|
||||||
@ -554,7 +555,7 @@ func (s *groupServer) GetGroupApplicationList(ctx context.Context, req *pbGroup.
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
groupMap := make(map[string]*relation.Group)
|
groupMap := make(map[string]*relation.GroupGorm)
|
||||||
for i, group := range groups {
|
for i, group := range groups {
|
||||||
groupMap[group.GroupID] = groups[i]
|
groupMap[group.GroupID] = groups[i]
|
||||||
}
|
}
|
||||||
@ -851,7 +852,7 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//only administrators can set group information
|
//only administrators can set group information
|
||||||
var groupInfo relation.Group
|
var groupInfo relation.GroupGorm
|
||||||
utils.CopyStructFields(&groupInfo, req.GroupInfoForSet)
|
utils.CopyStructFields(&groupInfo, req.GroupInfoForSet)
|
||||||
if req.GroupInfoForSet.Notification != "" {
|
if req.GroupInfoForSet.Notification != "" {
|
||||||
groupInfo.NotificationUserID = tracelog.GetOpUserID(ctx)
|
groupInfo.NotificationUserID = tracelog.GetOpUserID(ctx)
|
||||||
|
14
pkg/common/db/cache/group.go
vendored
14
pkg/common/db/cache/group.go
vendored
@ -29,9 +29,9 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type GroupCache struct {
|
type GroupCache struct {
|
||||||
group *relation.Group
|
group *relation.GroupGorm
|
||||||
groupMember *relation.GroupMember
|
groupMember *relation.GroupMemberGorm
|
||||||
groupRequest *relation.GroupRequest
|
groupRequest *relation.GroupRequestGorm
|
||||||
mongoDB *unrelation.SuperGroupMgoDB
|
mongoDB *unrelation.SuperGroupMgoDB
|
||||||
expireTime time.Duration
|
expireTime time.Duration
|
||||||
redisClient *RedisClient
|
redisClient *RedisClient
|
||||||
@ -47,7 +47,7 @@ type GroupMemberIDsHash struct {
|
|||||||
UserIDs []string
|
UserIDs []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGroupCache(rdb redis.UniversalClient, groupDB *relation.Group, groupMemberDB *relation.GroupMember, groupRequestDB *relation.GroupRequest, mongoClient *unrelation.SuperGroupMgoDB, opts rockscache.Options) *GroupCache {
|
func NewGroupCache(rdb redis.UniversalClient, groupDB *relation.GroupGorm, groupMemberDB *relation.GroupMemberGorm, groupRequestDB *relation.GroupRequestGorm, mongoClient *unrelation.SuperGroupMgoDB, opts rockscache.Options) *GroupCache {
|
||||||
return &GroupCache{rcClient: rockscache.NewClient(rdb, opts), expireTime: groupExpireTime,
|
return &GroupCache{rcClient: rockscache.NewClient(rdb, opts), expireTime: groupExpireTime,
|
||||||
group: groupDB, groupMember: groupMemberDB, groupRequest: groupRequestDB, redisClient: NewRedisClient(rdb),
|
group: groupDB, groupMember: groupMemberDB, groupRequest: groupRequestDB, redisClient: NewRedisClient(rdb),
|
||||||
mongoDB: mongoClient, cacheGroupMemberUserIDs: make(map[string]*GroupMemberIDsHash, 0),
|
mongoDB: mongoClient, cacheGroupMemberUserIDs: make(map[string]*GroupMemberIDsHash, 0),
|
||||||
@ -86,7 +86,7 @@ func (g *GroupCache) getGroupMemberNumKey(groupID string) string {
|
|||||||
return groupMemberNumKey + groupID
|
return groupMemberNumKey + groupID
|
||||||
}
|
}
|
||||||
|
|
||||||
/// groupInfo
|
// / groupInfo
|
||||||
func (g *GroupCache) GetGroupsInfo(ctx context.Context, groupIDs []string) (groups []*relation.Group, err error) {
|
func (g *GroupCache) GetGroupsInfo(ctx context.Context, groupIDs []string) (groups []*relation.Group, err error) {
|
||||||
for _, groupID := range groupIDs {
|
for _, groupID := range groupIDs {
|
||||||
group, err := g.GetGroupInfo(ctx, groupID)
|
group, err := g.GetGroupInfo(ctx, groupID)
|
||||||
@ -98,7 +98,7 @@ func (g *GroupCache) GetGroupsInfo(ctx context.Context, groupIDs []string) (grou
|
|||||||
return groups, nil
|
return groups, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupCache) GetGroupInfo(ctx context.Context, groupID string) (group *relation.Group, err error) {
|
func (g *GroupCache) GetGroupInfo(ctx context.Context, groupID string) (group *relation.GroupGorm, err error) {
|
||||||
getGroup := func() (string, error) {
|
getGroup := func() (string, error) {
|
||||||
groupInfo, err := g.group.Take(ctx, groupID)
|
groupInfo, err := g.group.Take(ctx, groupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -110,7 +110,7 @@ func (g *GroupCache) GetGroupInfo(ctx context.Context, groupID string) (group *r
|
|||||||
}
|
}
|
||||||
return string(bytes), nil
|
return string(bytes), nil
|
||||||
}
|
}
|
||||||
group = &relation.Group{}
|
group = &relation.GroupGorm{}
|
||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "group", *group)
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "group", *group)
|
||||||
}()
|
}()
|
||||||
|
9
pkg/common/db/cache/rockscache.go
vendored
9
pkg/common/db/cache/rockscache.go
vendored
@ -2,17 +2,12 @@ package cache
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/db/mongo"
|
|
||||||
"Open_IM/pkg/common/db/mysql"
|
|
||||||
"Open_IM/pkg/common/db/relation"
|
"Open_IM/pkg/common/db/relation"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/tracelog"
|
"Open_IM/pkg/common/tracelog"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/dtm-labs/rockscache"
|
|
||||||
"github.com/go-redis/redis/v8"
|
|
||||||
"gorm.io/gorm"
|
|
||||||
"math/big"
|
"math/big"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -358,7 +353,7 @@ func DelAllGroupMembersInfoFromCache(ctx context.Context, groupID string) (err e
|
|||||||
return db.DB.Rc.TagAsDeleted(groupAllMemberInfoCache + groupID)
|
return db.DB.Rc.TagAsDeleted(groupAllMemberInfoCache + groupID)
|
||||||
}
|
}
|
||||||
|
|
||||||
//func GetGroupInfoFromCache(ctx context.Context, groupID string) (groupInfo *mysql.Group, err error) {
|
//func GetGroupInfoFromCache(ctx context.Context, groupID string) (groupInfo *mysql.GroupGorm, err error) {
|
||||||
// getGroupInfo := func() (string, error) {
|
// getGroupInfo := func() (string, error) {
|
||||||
// groupInfo, err := mysql.GetGroupInfoByGroupID(groupID)
|
// groupInfo, err := mysql.GetGroupInfoByGroupID(groupID)
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
@ -370,7 +365,7 @@ func DelAllGroupMembersInfoFromCache(ctx context.Context, groupID string) (err e
|
|||||||
// }
|
// }
|
||||||
// return string(bytes), nil
|
// return string(bytes), nil
|
||||||
// }
|
// }
|
||||||
// groupInfo = &mysql.Group{}
|
// groupInfo = &mysql.GroupGorm{}
|
||||||
// defer func() {
|
// defer func() {
|
||||||
// tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "groupInfo", groupInfo)
|
// tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "groupInfo", groupInfo)
|
||||||
// }()
|
// }()
|
||||||
|
@ -3,6 +3,7 @@ package controller
|
|||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/db/cache"
|
"Open_IM/pkg/common/db/cache"
|
||||||
"Open_IM/pkg/common/db/relation"
|
"Open_IM/pkg/common/db/relation"
|
||||||
|
"Open_IM/pkg/common/db/table"
|
||||||
"Open_IM/pkg/common/db/unrelation"
|
"Open_IM/pkg/common/db/unrelation"
|
||||||
"context"
|
"context"
|
||||||
"github.com/dtm-labs/rockscache"
|
"github.com/dtm-labs/rockscache"
|
||||||
@ -13,23 +14,23 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type GroupInterface interface {
|
type GroupInterface interface {
|
||||||
FindGroupsByID(ctx context.Context, groupIDs []string) (groups []*relation.Group, err error)
|
FindGroupsByID(ctx context.Context, groupIDs []string) (groups []*table.GroupModel, err error)
|
||||||
CreateGroup(ctx context.Context, groups []*relation.Group, groupMember []*relation.GroupMember) error
|
CreateGroup(ctx context.Context, groups []*table.GroupModel, groupMember []*table.GroupModel) error
|
||||||
DeleteGroupByIDs(ctx context.Context, groupIDs []string) 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)
|
||||||
TakeGroupMemberByID(ctx context.Context, groupID string, userID string) (groupMember *relation.GroupMember, err error)
|
TakeGroupMemberByID(ctx context.Context, groupID string, userID string) (groupMember *table.GroupModel, err error)
|
||||||
GetJoinedGroupList(ctx context.Context, userID string) ([]*relation.Group, error)
|
GetJoinedGroupList(ctx context.Context, userID string) ([]*table.GroupModel, error)
|
||||||
GetGroupMemberList(ctx context.Context, groupID string) ([]*relation.GroupMember, error)
|
GetGroupMemberList(ctx context.Context, groupID string) ([]*table.GroupModel, error)
|
||||||
GetGroupMemberListByUserID(ctx context.Context, groupID string, userIDs []string) ([]*relation.GroupMember, error)
|
GetGroupMemberListByUserID(ctx context.Context, groupID string, userIDs []string) ([]*table.GroupModel, 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)
|
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 []*relation.GroupMember, err error)
|
FindGroupMembersByID(ctx context.Context, groupID string, userIDs []string) (groups []*table.GroupModel, err error)
|
||||||
DelGroupMember(ctx context.Context, groupID string, userIDs []string) error
|
DelGroupMember(ctx context.Context, groupID string, userIDs []string) error
|
||||||
GetGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]int, error)
|
GetGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]int, error)
|
||||||
GetGroupOwnerUserID(ctx context.Context, groupIDs []string) (map[string]string, 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
|
CreateGroupMember(ctx context.Context, groupMember []*table.GroupModel) error
|
||||||
CreateGroupRequest(ctx context.Context, requests []*relation.GroupRequest) error
|
CreateGroupRequest(ctx context.Context, requests []*table.GroupRequestModel) error
|
||||||
|
|
||||||
//mongo
|
//mongo
|
||||||
CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error
|
CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error
|
||||||
@ -44,12 +45,12 @@ type GroupController struct {
|
|||||||
database GroupDataBaseInterface
|
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
|
//TODO implement me
|
||||||
panic("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
|
//TODO implement me
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
@ -59,7 +60,7 @@ func (g *GroupController) DelGroupMember(ctx context.Context, groupID string, us
|
|||||||
panic("implement me")
|
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
|
var groupRequestList []db.GroupRequest
|
||||||
memberList, err := GetGroupMemberListByUserID(userID)
|
memberList, err := GetGroupMemberListByUserID(userID)
|
||||||
@ -89,22 +90,22 @@ func (g *GroupController) DelSuperGroupMember(ctx context.Context, groupID strin
|
|||||||
panic("implement me")
|
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
|
//TODO implement me
|
||||||
panic("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
|
//TODO implement me
|
||||||
panic("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
|
//TODO implement me
|
||||||
panic("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
|
//TODO implement me
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
@ -119,12 +120,12 @@ func (g *GroupController) GetGroupOwnerUserID(ctx context.Context, groupIDs []st
|
|||||||
panic("implement me")
|
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
|
//TODO implement me
|
||||||
panic("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
|
//TODO implement me
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
@ -139,11 +140,11 @@ func NewGroupController(db *gorm.DB, rdb redis.UniversalClient, mgoClient *mongo
|
|||||||
return groupController
|
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)
|
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)
|
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)
|
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)
|
return g.database.TakeGroupByID(ctx, groupID)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,18 +165,18 @@ func (g *GroupController) CreateSuperGroup(ctx context.Context, groupID string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GroupDataBaseInterface interface {
|
type GroupDataBaseInterface interface {
|
||||||
FindGroupsByID(ctx context.Context, groupIDs []string) (groups []*relation.Group, err error)
|
FindGroupsByID(ctx context.Context, groupIDs []string) (groups []*table.GroupModel, err error)
|
||||||
CreateGroup(ctx context.Context, groups []*relation.Group, groupMember []*relation.GroupMember) error
|
CreateGroup(ctx context.Context, groups []*table.GroupModel, groupMember []*table.GroupModel) error
|
||||||
DeleteGroupByIDs(ctx context.Context, groupIDs []string) 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)
|
GetSuperGroupByID(ctx context.Context, groupID string) (superGroup *unrelation.SuperGroup, err error)
|
||||||
CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error
|
CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type GroupDataBase struct {
|
type GroupDataBase struct {
|
||||||
groupDB *relation.Group
|
groupDB *relation.GroupGorm
|
||||||
groupMemberDB *relation.GroupMember
|
groupMemberDB *relation.GroupMemberGorm
|
||||||
groupRequestDB *relation.GroupRequest
|
groupRequestDB *relation.GroupRequestGorm
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
|
|
||||||
cache *cache.GroupCache
|
cache *cache.GroupCache
|
||||||
@ -204,11 +205,11 @@ func newGroupDatabase(db *gorm.DB, rdb redis.UniversalClient, mgoClient *mongo.C
|
|||||||
return database
|
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)
|
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 {
|
return g.db.Transaction(func(tx *gorm.DB) error {
|
||||||
if len(groups) > 0 {
|
if len(groups) > 0 {
|
||||||
if err := g.groupDB.Create(ctx, groups, tx); err != nil {
|
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)
|
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 {
|
return g.db.Transaction(func(tx *gorm.DB) error {
|
||||||
if err := g.groupDB.Update(ctx, groups, tx); err != nil {
|
if err := g.groupDB.Update(ctx, groups, tx); err != nil {
|
||||||
return err
|
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
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
@ -2,62 +2,48 @@ package relation
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
|
"Open_IM/pkg/common/db/table"
|
||||||
"Open_IM/pkg/common/tracelog"
|
"Open_IM/pkg/common/tracelog"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var GroupMemberDB *gorm.DB
|
type GroupMemberGorm struct {
|
||||||
|
DB *gorm.DB
|
||||||
type GroupMember struct {
|
|
||||||
GroupID string `gorm:"column:group_id;primary_key;size:64"`
|
|
||||||
UserID string `gorm:"column:user_id;primary_key;size:64"`
|
|
||||||
Nickname string `gorm:"column:nickname;size:255"`
|
|
||||||
FaceURL string `gorm:"column:user_group_face_url;size:255"`
|
|
||||||
RoleLevel int32 `gorm:"column:role_level"`
|
|
||||||
JoinTime time.Time `gorm:"column:join_time"`
|
|
||||||
JoinSource int32 `gorm:"column:join_source"`
|
|
||||||
InviterUserID string `gorm:"column:inviter_user_id;size:64"`
|
|
||||||
OperatorUserID string `gorm:"column:operator_user_id;size:64"`
|
|
||||||
MuteEndTime time.Time `gorm:"column:mute_end_time"`
|
|
||||||
Ex string `gorm:"column:ex;size:1024"`
|
|
||||||
DB *gorm.DB `gorm:"-" json:"-"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGroupMemberDB(db *gorm.DB) *GroupMember {
|
func NewGroupMemberDB(db *gorm.DB) *GroupMemberGorm {
|
||||||
return &GroupMember{DB: db}
|
return &GroupMemberGorm{DB: db}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupMember) Create(ctx context.Context, groupMemberList []*GroupMember, tx ...*gorm.DB) (err error) {
|
func (g *GroupMemberGorm) Create(ctx context.Context, groupMemberList []*table.GroupMemberModel, tx ...*gorm.DB) (err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupMemberList", groupMemberList)
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupMemberList", groupMemberList)
|
||||||
}()
|
}()
|
||||||
return utils.Wrap(getDBConn(g.DB, tx).Create(&groupMemberList).Error, "")
|
return utils.Wrap(getDBConn(g.DB, tx).Create(&groupMemberList).Error, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupMember) Delete(ctx context.Context, groupMembers []*GroupMember, tx ...*gorm.DB) (err error) {
|
func (g *GroupMemberGorm) Delete(ctx context.Context, groupMembers []*table.GroupMemberModel, tx ...*gorm.DB) (err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupMembers", groupMembers)
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupMembers", groupMembers)
|
||||||
}()
|
}()
|
||||||
return utils.Wrap(getDBConn(g.DB, tx).Delete(groupMembers).Error, "")
|
return utils.Wrap(getDBConn(g.DB, tx).Delete(groupMembers).Error, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupMember) UpdateByMap(ctx context.Context, groupID string, userID string, args map[string]interface{}, tx ...*gorm.DB) (err error) {
|
func (g *GroupMemberGorm) UpdateByMap(ctx context.Context, groupID string, userID string, args map[string]interface{}, tx ...*gorm.DB) (err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID, "args", args)
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID, "args", args)
|
||||||
}()
|
}()
|
||||||
return utils.Wrap(getDBConn(g.DB, tx).Model(&GroupMember{}).Where("group_id = ? and user_id = ?", groupID, userID).Updates(args).Error, "")
|
return utils.Wrap(getDBConn(g.DB, tx).Model(&table.GroupMemberModel{}).Where("group_id = ? and user_id = ?", groupID, userID).Updates(args).Error, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupMember) Update(ctx context.Context, groupMembers []*GroupMember, tx ...*gorm.DB) (err error) {
|
func (g *GroupMemberGorm) Update(ctx context.Context, groupMembers []*table.GroupMemberModel, tx ...*gorm.DB) (err error) {
|
||||||
defer func() { tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupMembers", groupMembers) }()
|
defer func() { tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupMembers", groupMembers) }()
|
||||||
return utils.Wrap(getDBConn(g.DB, tx).Updates(&groupMembers).Error, "")
|
return utils.Wrap(getDBConn(g.DB, tx).Updates(&groupMembers).Error, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupMember) Find(ctx context.Context, groupMembers []*GroupMember, tx ...*gorm.DB) (groupList []*GroupMember, err error) {
|
func (g *GroupMemberGorm) Find(ctx context.Context, groupMembers []*table.GroupMemberModel, tx ...*gorm.DB) (groupList []*table.GroupMemberModel, err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupMembers", groupMembers, "groupList", groupList)
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupMembers", groupMembers, "groupList", groupList)
|
||||||
}()
|
}()
|
||||||
@ -68,230 +54,230 @@ func (g *GroupMember) Find(ctx context.Context, groupMembers []*GroupMember, tx
|
|||||||
return groupList, utils.Wrap(getDBConn(g.DB, tx).Where("(group_id, user_id) in ?", where).Find(&groupList).Error, "")
|
return groupList, utils.Wrap(getDBConn(g.DB, tx).Where("(group_id, user_id) in ?", where).Find(&groupList).Error, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupMember) Take(ctx context.Context, groupID string, userID string, tx ...*gorm.DB) (groupMember *GroupMember, err error) {
|
func (g *GroupMemberGorm) Take(ctx context.Context, groupID string, userID string, tx ...*gorm.DB) (groupMember *table.GroupMemberModel, err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID, "groupMember", *groupMember)
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID, "groupMember", *groupMember)
|
||||||
}()
|
}()
|
||||||
groupMember = &GroupMember{}
|
groupMember = &table.GroupMemberModel{}
|
||||||
return groupMember, utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ? and user_id = ?", groupID, userID).Take(groupMember).Error, "")
|
return groupMember, utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ? and user_id = ?", groupID, userID).Take(groupMember).Error, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupMember) TakeOwnerInfo(ctx context.Context, groupID string, tx ...*gorm.DB) (groupMember *GroupMember, err error) {
|
func (g *GroupMemberGorm) TakeOwnerInfo(ctx context.Context, groupID string, tx ...*gorm.DB) (groupMember *table.GroupMemberModel, err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "groupMember", *groupMember)
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "groupMember", *groupMember)
|
||||||
}()
|
}()
|
||||||
groupMember = &GroupMember{}
|
groupMember = &table.GroupMemberModel{}
|
||||||
return groupMember, utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ? and role_level = ?", groupID, constant.GroupOwner).Take(groupMember).Error, "")
|
return groupMember, utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ? and role_level = ?", groupID, constant.GroupOwner).Take(groupMember).Error, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func InsertIntoGroupMember(toInsertInfo GroupMember) error {
|
//func InsertIntoGroupMember(toInsertInfo GroupMemberModel) error {
|
||||||
toInsertInfo.JoinTime = time.Now()
|
// toInsertInfo.JoinTime = time.Now()
|
||||||
if toInsertInfo.RoleLevel == 0 {
|
// if toInsertInfo.RoleLevel == 0 {
|
||||||
toInsertInfo.RoleLevel = constant.GroupOrdinaryUsers
|
// toInsertInfo.RoleLevel = constant.GroupOrdinaryUsers
|
||||||
}
|
// }
|
||||||
toInsertInfo.MuteEndTime = time.Unix(int64(time.Now().Second()), 0)
|
// toInsertInfo.MuteEndTime = time.Unix(int64(time.Now().Second()), 0)
|
||||||
err := GroupMemberDB.Table("group_members").Create(toInsertInfo).Error
|
// err := GroupMemberDB.Table("group_members").Create(toInsertInfo).Error
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
return nil
|
// return nil
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func BatchInsertIntoGroupMember(toInsertInfoList []*GroupMember) error {
|
//func BatchInsertIntoGroupMember(toInsertInfoList []*GroupMemberModel) error {
|
||||||
for _, toInsertInfo := range toInsertInfoList {
|
// for _, toInsertInfo := range toInsertInfoList {
|
||||||
toInsertInfo.JoinTime = time.Now()
|
// toInsertInfo.JoinTime = time.Now()
|
||||||
if toInsertInfo.RoleLevel == 0 {
|
// if toInsertInfo.RoleLevel == 0 {
|
||||||
toInsertInfo.RoleLevel = constant.GroupOrdinaryUsers
|
// toInsertInfo.RoleLevel = constant.GroupOrdinaryUsers
|
||||||
}
|
// }
|
||||||
toInsertInfo.MuteEndTime = time.Unix(int64(time.Now().Second()), 0)
|
// toInsertInfo.MuteEndTime = time.Unix(int64(time.Now().Second()), 0)
|
||||||
}
|
// }
|
||||||
return GroupMemberDB.Create(toInsertInfoList).Error
|
// return GroupMemberDB.Create(toInsertInfoList).Error
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func GetGroupMemberListByUserID(userID string) ([]GroupMember, error) {
|
//func GetGroupMemberListByUserID(userID string) ([]GroupMemberModel, error) {
|
||||||
var groupMemberList []GroupMember
|
// var groupMemberList []GroupMemberModel
|
||||||
err := GroupMemberDB.Table("group_members").Where("user_id=?", userID).Find(&groupMemberList).Error
|
// err := GroupMemberDB.Table("group_members").Where("user_id=?", userID).Find(&groupMemberList).Error
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
// }
|
||||||
return groupMemberList, nil
|
// return groupMemberList, nil
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func GetGroupMemberListByGroupID(groupID string) ([]GroupMember, error) {
|
//func GetGroupMemberListByGroupID(groupID string) ([]GroupMemberModel, error) {
|
||||||
var groupMemberList []GroupMember
|
// var groupMemberList []GroupMemberModel
|
||||||
err := GroupMemberDB.Table("group_members").Where("group_id=?", groupID).Find(&groupMemberList).Error
|
// err := GroupMemberDB.Table("group_members").Where("group_id=?", groupID).Find(&groupMemberList).Error
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
// }
|
||||||
return groupMemberList, nil
|
// return groupMemberList, nil
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func GetGroupMemberIDListByGroupID(groupID string) ([]string, error) {
|
//func GetGroupMemberIDListByGroupID(groupID string) ([]string, error) {
|
||||||
var groupMemberIDList []string
|
// var groupMemberIDList []string
|
||||||
err := GroupMemberDB.Table("group_members").Where("group_id=?", groupID).Pluck("user_id", &groupMemberIDList).Error
|
// err := GroupMemberDB.Table("group_members").Where("group_id=?", groupID).Pluck("user_id", &groupMemberIDList).Error
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
// }
|
||||||
return groupMemberIDList, nil
|
// return groupMemberIDList, nil
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func GetGroupMemberListByGroupIDAndRoleLevel(groupID string, roleLevel int32) ([]GroupMember, error) {
|
//func GetGroupMemberListByGroupIDAndRoleLevel(groupID string, roleLevel int32) ([]GroupMemberModel, error) {
|
||||||
var groupMemberList []GroupMember
|
// var groupMemberList []GroupMemberModel
|
||||||
err := GroupMemberDB.Table("group_members").Where("group_id=? and role_level=?", groupID, roleLevel).Find(&groupMemberList).Error
|
// err := GroupMemberDB.Table("group_members").Where("group_id=? and role_level=?", groupID, roleLevel).Find(&groupMemberList).Error
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
// }
|
||||||
return groupMemberList, nil
|
// return groupMemberList, nil
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func GetGroupMemberInfoByGroupIDAndUserID(groupID, userID string) (*GroupMember, error) {
|
//func GetGroupMemberInfoByGroupIDAndUserID(groupID, userID string) (*GroupMemberModel, error) {
|
||||||
var groupMember GroupMember
|
// var groupMember GroupMemberModel
|
||||||
err := GroupMemberDB.Table("group_members").Where("group_id=? and user_id=? ", groupID, userID).Limit(1).Take(&groupMember).Error
|
// err := GroupMemberDB.Table("group_members").Where("group_id=? and user_id=? ", groupID, userID).Limit(1).Take(&groupMember).Error
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
// }
|
||||||
return &groupMember, nil
|
// return &groupMember, nil
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func DeleteGroupMemberByGroupIDAndUserID(groupID, userID string) error {
|
//func DeleteGroupMemberByGroupIDAndUserID(groupID, userID string) error {
|
||||||
return GroupMemberDB.Table("group_members").Where("group_id=? and user_id=? ", groupID, userID).Delete(GroupMember{}).Error
|
// return GroupMemberDB.Table("group_members").Where("group_id=? and user_id=? ", groupID, userID).Delete(GroupMemberModel{}).Error
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func DeleteGroupMemberByGroupID(groupID string) error {
|
//func DeleteGroupMemberByGroupID(groupID string) error {
|
||||||
return GroupMemberDB.Table("group_members").Where("group_id=? ", groupID).Delete(GroupMember{}).Error
|
// return GroupMemberDB.Table("group_members").Where("group_id=? ", groupID).Delete(GroupMemberModel{}).Error
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func UpdateGroupMemberInfo(groupMemberInfo GroupMember) error {
|
//func UpdateGroupMemberInfo(groupMemberInfo GroupMemberModel) error {
|
||||||
return GroupMemberDB.Table("group_members").Where("group_id=? and user_id=?", groupMemberInfo.GroupID, groupMemberInfo.UserID).Updates(&groupMemberInfo).Error
|
// return GroupMemberDB.Table("group_members").Where("group_id=? and user_id=?", groupMemberInfo.GroupID, groupMemberInfo.UserID).Updates(&groupMemberInfo).Error
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func UpdateGroupMemberInfoByMap(groupMemberInfo GroupMember, m map[string]interface{}) error {
|
//func UpdateGroupMemberInfoByMap(groupMemberInfo GroupMemberModel, m map[string]interface{}) error {
|
||||||
return GroupMemberDB.Table("group_members").Where("group_id=? and user_id=?", groupMemberInfo.GroupID, groupMemberInfo.UserID).Updates(m).Error
|
// return GroupMemberDB.Table("group_members").Where("group_id=? and user_id=?", groupMemberInfo.GroupID, groupMemberInfo.UserID).Updates(m).Error
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func GetOwnerManagerByGroupID(groupID string) ([]GroupMember, error) {
|
//func GetOwnerManagerByGroupID(groupID string) ([]GroupMemberModel, error) {
|
||||||
var groupMemberList []GroupMember
|
// var groupMemberList []GroupMemberModel
|
||||||
err := GroupMemberDB.Table("group_members").Where("group_id=? and role_level>?", groupID, constant.GroupOrdinaryUsers).Find(&groupMemberList).Error
|
// err := GroupMemberDB.Table("group_members").Where("group_id=? and role_level>?", groupID, constant.GroupOrdinaryUsers).Find(&groupMemberList).Error
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
// }
|
||||||
return groupMemberList, nil
|
// return groupMemberList, nil
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func GetGroupMemberNumByGroupID(groupID string) (int64, error) {
|
//func GetGroupMemberNumByGroupID(groupID string) (int64, error) {
|
||||||
var number int64
|
// var number int64
|
||||||
err := GroupMemberDB.Table("group_members").Where("group_id=?", groupID).Count(&number).Error
|
// err := GroupMemberDB.Table("group_members").Where("group_id=?", groupID).Count(&number).Error
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return 0, utils.Wrap(err, "")
|
// return 0, utils.Wrap(err, "")
|
||||||
}
|
// }
|
||||||
return number, nil
|
// return number, nil
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func GetGroupOwnerInfoByGroupID(groupID string) (*GroupMember, error) {
|
//func GetGroupOwnerInfoByGroupID(groupID string) (*GroupMemberModel, error) {
|
||||||
omList, err := GetOwnerManagerByGroupID(groupID)
|
// omList, err := GetOwnerManagerByGroupID(groupID)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
// }
|
||||||
for _, v := range omList {
|
// for _, v := range omList {
|
||||||
if v.RoleLevel == constant.GroupOwner {
|
// if v.RoleLevel == constant.GroupOwner {
|
||||||
return &v, nil
|
// return &v, nil
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return nil, utils.Wrap(constant.ErrGroupNoOwner, "")
|
// return nil, utils.Wrap(constant.ErrGroupNoOwner, "")
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func IsExistGroupMember(groupID, userID string) bool {
|
//func IsExistGroupMember(groupID, userID string) bool {
|
||||||
var number int64
|
// var number int64
|
||||||
err := GroupMemberDB.Table("group_members").Where("group_id = ? and user_id = ?", groupID, userID).Count(&number).Error
|
// err := GroupMemberDB.Table("group_members").Where("group_id = ? and user_id = ?", groupID, userID).Count(&number).Error
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return false
|
// return false
|
||||||
}
|
// }
|
||||||
if number != 1 {
|
// if number != 1 {
|
||||||
return false
|
// return false
|
||||||
}
|
// }
|
||||||
return true
|
// return true
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func CheckIsExistGroupMember(ctx context.Context, groupID, userID string) error {
|
//func CheckIsExistGroupMember(ctx context.Context, groupID, userID string) error {
|
||||||
var number int64
|
// var number int64
|
||||||
err := GroupMemberDB.Table("group_members").Where("group_id = ? and user_id = ?", groupID, userID).Count(&number).Error
|
// err := GroupMemberDB.Table("group_members").Where("group_id = ? and user_id = ?", groupID, userID).Count(&number).Error
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return constant.ErrDB.Wrap()
|
// return constant.ErrDB.Wrap()
|
||||||
}
|
// }
|
||||||
if number != 1 {
|
// if number != 1 {
|
||||||
return constant.ErrData.Wrap()
|
// return constant.ErrData.Wrap()
|
||||||
}
|
// }
|
||||||
return nil
|
// return nil
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func GetGroupMemberByGroupID(groupID string, filter int32, begin int32, maxNumber int32) ([]GroupMember, error) {
|
//func GetGroupMemberByGroupID(groupID string, filter int32, begin int32, maxNumber int32) ([]GroupMember, error) {
|
||||||
var memberList []GroupMember
|
// var memberList []GroupMember
|
||||||
var err error
|
// var err error
|
||||||
if filter >= 0 {
|
// if filter >= 0 {
|
||||||
memberList, err = GetGroupMemberListByGroupIDAndRoleLevel(groupID, filter) //sorted by join time
|
// memberList, err = GetGroupMemberListByGroupIDAndRoleLevel(groupID, filter) //sorted by join time
|
||||||
} else {
|
// } else {
|
||||||
memberList, err = GetGroupMemberListByGroupID(groupID)
|
// memberList, err = GetGroupMemberListByGroupID(groupID)
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
// }
|
||||||
if begin >= int32(len(memberList)) {
|
// if begin >= int32(len(memberList)) {
|
||||||
return nil, nil
|
// return nil, nil
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
var end int32
|
// var end int32
|
||||||
if begin+int32(maxNumber) < int32(len(memberList)) {
|
// if begin+int32(maxNumber) < int32(len(memberList)) {
|
||||||
end = begin + maxNumber
|
// end = begin + maxNumber
|
||||||
} else {
|
// } else {
|
||||||
end = int32(len(memberList))
|
// end = int32(len(memberList))
|
||||||
}
|
// }
|
||||||
return memberList[begin:end], nil
|
// return memberList[begin:end], nil
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func GetJoinedGroupIDListByUserID(userID string) ([]string, error) {
|
//func GetJoinedGroupIDListByUserID(userID string) ([]string, error) {
|
||||||
memberList, err := GetGroupMemberListByUserID(userID)
|
// memberList, err := GetGroupMemberListByUserID(userID)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
// }
|
||||||
var groupIDList []string
|
// var groupIDList []string
|
||||||
for _, v := range memberList {
|
// for _, v := range memberList {
|
||||||
groupIDList = append(groupIDList, v.GroupID)
|
// groupIDList = append(groupIDList, v.GroupID)
|
||||||
}
|
// }
|
||||||
return groupIDList, nil
|
// return groupIDList, nil
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func IsGroupOwnerAdmin(groupID, UserID string) bool {
|
//func IsGroupOwnerAdmin(groupID, UserID string) bool {
|
||||||
groupMemberList, err := GetOwnerManagerByGroupID(groupID)
|
// groupMemberList, err := GetOwnerManagerByGroupID(groupID)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return false
|
// return false
|
||||||
}
|
// }
|
||||||
for _, v := range groupMemberList {
|
// for _, v := range groupMemberList {
|
||||||
if v.UserID == UserID && v.RoleLevel > constant.GroupOrdinaryUsers {
|
// if v.UserID == UserID && v.RoleLevel > constant.GroupOrdinaryUsers {
|
||||||
return true
|
// return true
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return false
|
// return false
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func GetGroupMembersByGroupIdCMS(groupId string, userName string, showNumber, pageNumber int32) ([]GroupMember, error) {
|
//func GetGroupMembersByGroupIdCMS(groupId string, userName string, showNumber, pageNumber int32) ([]GroupMember, error) {
|
||||||
var groupMembers []GroupMember
|
// var groupMembers []GroupMember
|
||||||
err := GroupMemberDB.Table("group_members").Where("group_id=?", groupId).Where(fmt.Sprintf(" nickname like '%%%s%%' ", userName)).Limit(int(showNumber)).Offset(int(showNumber * (pageNumber - 1))).Find(&groupMembers).Error
|
// err := GroupMemberDB.Table("group_members").Where("group_id=?", groupId).Where(fmt.Sprintf(" nickname like '%%%s%%' ", userName)).Limit(int(showNumber)).Offset(int(showNumber * (pageNumber - 1))).Find(&groupMembers).Error
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
// }
|
||||||
return groupMembers, nil
|
// return groupMembers, nil
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func GetGroupMembersCount(groupID, userName string) (int64, error) {
|
//func GetGroupMembersCount(groupID, userName string) (int64, error) {
|
||||||
var count int64
|
// var count int64
|
||||||
if err := GroupMemberDB.Table("group_members").Where("group_id=?", groupID).Where(fmt.Sprintf(" nickname like '%%%s%%' ", userName)).Count(&count).Error; err != nil {
|
// if err := GroupMemberDB.Table("group_members").Where("group_id=?", groupID).Where(fmt.Sprintf(" nickname like '%%%s%%' ", userName)).Count(&count).Error; err != nil {
|
||||||
return count, err
|
// return count, err
|
||||||
}
|
// }
|
||||||
return count, nil
|
// return count, nil
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func UpdateGroupMemberInfoDefaultZero(groupMemberInfo GroupMember, args map[string]interface{}) error {
|
//func UpdateGroupMemberInfoDefaultZero(groupMemberInfo GroupMember, args map[string]interface{}) error {
|
||||||
return GroupMemberDB.Model(groupMemberInfo).Updates(args).Error
|
// return GroupMemberDB.Model(groupMemberInfo).Updates(args).Error
|
||||||
}
|
//}
|
||||||
|
@ -1,75 +1,58 @@
|
|||||||
package relation
|
package relation
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"Open_IM/pkg/common/db/table"
|
||||||
"Open_IM/pkg/common/tracelog"
|
"Open_IM/pkg/common/tracelog"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Group struct {
|
type GroupGorm struct {
|
||||||
GroupID string `gorm:"column:group_id;primary_key;size:64" json:"groupID" binding:"required"`
|
DB *gorm.DB
|
||||||
GroupName string `gorm:"column:name;size:255" json:"groupName"`
|
|
||||||
Notification string `gorm:"column:notification;size:255" json:"notification"`
|
|
||||||
Introduction string `gorm:"column:introduction;size:255" json:"introduction"`
|
|
||||||
FaceURL string `gorm:"column:face_url;size:255" json:"faceURL"`
|
|
||||||
CreateTime time.Time `gorm:"column:create_time;index:create_time"`
|
|
||||||
Ex string `gorm:"column:ex" json:"ex;size:1024" json:"ex"`
|
|
||||||
Status int32 `gorm:"column:status"`
|
|
||||||
CreatorUserID string `gorm:"column:creator_user_id;size:64"`
|
|
||||||
GroupType int32 `gorm:"column:group_type"`
|
|
||||||
NeedVerification int32 `gorm:"column:need_verification"`
|
|
||||||
LookMemberInfo int32 `gorm:"column:look_member_info" json:"lookMemberInfo"`
|
|
||||||
ApplyMemberFriend int32 `gorm:"column:apply_member_friend" json:"applyMemberFriend"`
|
|
||||||
NotificationUpdateTime time.Time `gorm:"column:notification_update_time"`
|
|
||||||
NotificationUserID string `gorm:"column:notification_user_id;size:64"`
|
|
||||||
DB *gorm.DB
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGroupDB(db *gorm.DB) *Group {
|
func NewGroupDB(db *gorm.DB) *GroupGorm {
|
||||||
var group Group
|
return &GroupGorm{DB: db}
|
||||||
group.DB = db
|
|
||||||
return &group
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) Create(ctx context.Context, groups []*Group, tx ...*gorm.DB) (err error) {
|
func (g *GroupGorm) Create(ctx context.Context, groups []*table.GroupModel, tx ...*gorm.DB) (err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groups", groups)
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groups", groups)
|
||||||
}()
|
}()
|
||||||
return utils.Wrap(getDBConn(g.DB, tx).Create(&groups).Error, "")
|
return utils.Wrap(getDBConn(g.DB, tx).Create(&groups).Error, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) Delete(ctx context.Context, groupIDs []string, tx ...*gorm.DB) (err error) {
|
func (g *GroupGorm) Delete(ctx context.Context, groupIDs []string, tx ...*gorm.DB) (err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupIDs", groupIDs)
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupIDs", groupIDs)
|
||||||
}()
|
}()
|
||||||
return utils.Wrap(getDBConn(g.DB, tx).Where("group_id in (?)", groupIDs).Delete(&Group{}).Error, "")
|
return utils.Wrap(getDBConn(g.DB, tx).Where("group_id in (?)", groupIDs).Delete(&table.GroupModel{}).Error, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) UpdateByMap(ctx context.Context, groupID string, args map[string]interface{}, tx ...*gorm.DB) (err error) {
|
func (g *GroupGorm) UpdateByMap(ctx context.Context, groupID string, args map[string]interface{}, tx ...*gorm.DB) (err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "args", args)
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "args", args)
|
||||||
}()
|
}()
|
||||||
return utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ?", groupID).Model(g).Updates(args).Error, "")
|
return utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ?", groupID).Model(g).Updates(args).Error, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) Update(ctx context.Context, groups []*Group, tx ...*gorm.DB) (err error) {
|
func (g *GroupGorm) Update(ctx context.Context, groups []*table.GroupModel, tx ...*gorm.DB) (err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groups", groups)
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groups", groups)
|
||||||
}()
|
}()
|
||||||
return utils.Wrap(getDBConn(g.DB, tx).Updates(&groups).Error, "")
|
return utils.Wrap(getDBConn(g.DB, tx).Updates(&groups).Error, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) Find(ctx context.Context, groupIDs []string, tx ...*gorm.DB) (groups []*Group, err error) {
|
func (g *GroupGorm) Find(ctx context.Context, groupIDs []string, tx ...*gorm.DB) (groups []*table.GroupModel, err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupIDs", groupIDs, "groups", groups)
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupIDs", groupIDs, "groups", groups)
|
||||||
}()
|
}()
|
||||||
return groups, utils.Wrap(getDBConn(g.DB, tx).Where("group_id in (?)", groupIDs).Find(&groups).Error, "")
|
return groups, utils.Wrap(getDBConn(g.DB, tx).Where("group_id in (?)", groupIDs).Find(&groups).Error, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) Take(ctx context.Context, groupID string, tx ...*gorm.DB) (group *Group, err error) {
|
func (g *GroupGorm) Take(ctx context.Context, groupID string, tx ...*gorm.DB) (group *table.GroupModel, err error) {
|
||||||
group = &Group{}
|
group = &table.GroupModel{}
|
||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "group", *group)
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "group", *group)
|
||||||
}()
|
}()
|
||||||
|
@ -1,69 +1,52 @@
|
|||||||
package relation
|
package relation
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"Open_IM/pkg/common/db/table"
|
||||||
"Open_IM/pkg/common/tracelog"
|
"Open_IM/pkg/common/tracelog"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var GroupRequestDB *gorm.DB
|
type GroupRequestGorm struct {
|
||||||
|
DB *gorm.DB
|
||||||
type GroupRequest struct {
|
|
||||||
UserID string `gorm:"column:user_id;primary_key;size:64"`
|
|
||||||
GroupID string `gorm:"column:group_id;primary_key;size:64"`
|
|
||||||
HandleResult int32 `gorm:"column:handle_result"`
|
|
||||||
ReqMsg string `gorm:"column:req_msg;size:1024"`
|
|
||||||
HandledMsg string `gorm:"column:handle_msg;size:1024"`
|
|
||||||
ReqTime time.Time `gorm:"column:req_time"`
|
|
||||||
HandleUserID string `gorm:"column:handle_user_id;size:64"`
|
|
||||||
HandledTime time.Time `gorm:"column:handle_time"`
|
|
||||||
JoinSource int32 `gorm:"column:join_source"`
|
|
||||||
InviterUserID string `gorm:"column:inviter_user_id;size:64"`
|
|
||||||
Ex string `gorm:"column:ex;size:1024"`
|
|
||||||
DB *gorm.DB
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGroupRequest(db *gorm.DB) *GroupRequest {
|
func NewGroupRequest(db *gorm.DB) *GroupRequestGorm {
|
||||||
return &GroupRequest{
|
return &GroupRequestGorm{
|
||||||
DB: db,
|
DB: db,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (GroupRequest) TableName() string {
|
func (g *GroupRequestGorm) Create(ctx context.Context, groupRequests []*table.GroupRequestModel, tx ...*gorm.DB) (err error) {
|
||||||
return "friend_requests"
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*GroupRequest) Create(ctx context.Context, groupRequests []*GroupRequest) (err error) {
|
|
||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupRequests", groupRequests)
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupRequests", groupRequests)
|
||||||
}()
|
}()
|
||||||
return utils.Wrap(GroupRequestDB.Create(&groupRequests).Error, utils.GetSelfFuncName())
|
return utils.Wrap(getDBConn(g.DB, tx).Create(&groupRequests).Error, utils.GetSelfFuncName())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*GroupRequest) Delete(ctx context.Context, groupRequests []*GroupRequest) (err error) {
|
func (g *GroupRequestGorm) Delete(ctx context.Context, groupRequests []*table.GroupRequestModel, tx ...*gorm.DB) (err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupRequests", groupRequests)
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupRequests", groupRequests)
|
||||||
}()
|
}()
|
||||||
return utils.Wrap(GroupRequestDB.Delete(&groupRequests).Error, utils.GetSelfFuncName())
|
return utils.Wrap(getDBConn(g.DB, tx).Delete(&groupRequests).Error, utils.GetSelfFuncName())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*GroupRequest) UpdateByMap(ctx context.Context, groupID string, userID string, args map[string]interface{}) (err error) {
|
func (g *GroupRequestGorm) UpdateByMap(ctx context.Context, groupID string, userID string, args map[string]interface{}, tx ...*gorm.DB) (err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID, "args", args)
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID, "args", args)
|
||||||
}()
|
}()
|
||||||
return utils.Wrap(GroupRequestDB.Where("group_id = ? and user_id = ? ", groupID, userID).Updates(args).Error, utils.GetSelfFuncName())
|
return utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ? and user_id = ? ", groupID, userID).Updates(args).Error, utils.GetSelfFuncName())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*GroupRequest) Update(ctx context.Context, groupRequests []*GroupRequest) (err error) {
|
func (g *GroupRequestGorm) Update(ctx context.Context, groupRequests []*table.GroupRequestModel, tx ...*gorm.DB) (err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupRequests", groupRequests)
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupRequests", groupRequests)
|
||||||
}()
|
}()
|
||||||
return utils.Wrap(GroupRequestDB.Updates(&groupRequests).Error, utils.GetSelfFuncName())
|
return utils.Wrap(getDBConn(g.DB, tx).Updates(&groupRequests).Error, utils.GetSelfFuncName())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*GroupRequest) Find(ctx context.Context, groupRequests []*GroupRequest) (resultGroupRequests []*GroupRequest, err error) {
|
func (g *GroupRequestGorm) Find(ctx context.Context, groupRequests []*table.GroupRequestModel, tx ...*gorm.DB) (resultGroupRequests []*table.GroupRequestModel, err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupRequests", groupRequests, "resultGroupRequests", resultGroupRequests)
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupRequests", groupRequests, "resultGroupRequests", resultGroupRequests)
|
||||||
}()
|
}()
|
||||||
@ -71,13 +54,13 @@ func (*GroupRequest) Find(ctx context.Context, groupRequests []*GroupRequest) (r
|
|||||||
for _, groupMember := range groupRequests {
|
for _, groupMember := range groupRequests {
|
||||||
where = append(where, []interface{}{groupMember.GroupID, groupMember.UserID})
|
where = append(where, []interface{}{groupMember.GroupID, groupMember.UserID})
|
||||||
}
|
}
|
||||||
return resultGroupRequests, utils.Wrap(GroupRequestDB.Where("(group_id, user_id) in ?", where).Find(&resultGroupRequests).Error, utils.GetSelfFuncName())
|
return resultGroupRequests, utils.Wrap(getDBConn(g.DB, tx).Where("(group_id, user_id) in ?", where).Find(&resultGroupRequests).Error, utils.GetSelfFuncName())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*GroupRequest) Take(ctx context.Context, groupID string, userID string) (groupRequest *GroupRequest, err error) {
|
func (g *GroupRequestGorm) Take(ctx context.Context, groupID string, userID string, tx ...*gorm.DB) (groupRequest *table.GroupRequestModel, err error) {
|
||||||
groupRequest = &GroupRequest{}
|
groupRequest = &table.GroupRequestModel{}
|
||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID, "groupRequest", *groupRequest)
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID, "groupRequest", *groupRequest)
|
||||||
}()
|
}()
|
||||||
return groupRequest, utils.Wrap(GroupRequestDB.Where("group_id = ? and user_id = ? ", groupID, userID).Take(groupRequest).Error, utils.GetSelfFuncName())
|
return groupRequest, utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ? and user_id = ? ", groupID, userID).Take(groupRequest).Error, utils.GetSelfFuncName())
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package table
|
package table
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
type FriendModel struct {
|
type FriendModel struct {
|
||||||
OwnerUserID string `gorm:"column:owner_user_id;primary_key;size:64"`
|
OwnerUserID string `gorm:"column:owner_user_id;primary_key;size:64"`
|
||||||
@ -29,3 +31,49 @@ type ConversationModel struct {
|
|||||||
AttachedInfo string `gorm:"column:attached_info;type:varchar(1024)" json:"attachedInfo"`
|
AttachedInfo string `gorm:"column:attached_info;type:varchar(1024)" json:"attachedInfo"`
|
||||||
Ex string `gorm:"column:ex;type:varchar(1024)" json:"ex"`
|
Ex string `gorm:"column:ex;type:varchar(1024)" json:"ex"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GroupModel struct {
|
||||||
|
GroupID string `gorm:"column:group_id;primary_key;size:64" json:"groupID" binding:"required"`
|
||||||
|
GroupName string `gorm:"column:name;size:255" json:"groupName"`
|
||||||
|
Notification string `gorm:"column:notification;size:255" json:"notification"`
|
||||||
|
Introduction string `gorm:"column:introduction;size:255" json:"introduction"`
|
||||||
|
FaceURL string `gorm:"column:face_url;size:255" json:"faceURL"`
|
||||||
|
CreateTime time.Time `gorm:"column:create_time;index:create_time"`
|
||||||
|
Ex string `gorm:"column:ex" json:"ex;size:1024" json:"ex"`
|
||||||
|
Status int32 `gorm:"column:status"`
|
||||||
|
CreatorUserID string `gorm:"column:creator_user_id;size:64"`
|
||||||
|
GroupType int32 `gorm:"column:group_type"`
|
||||||
|
NeedVerification int32 `gorm:"column:need_verification"`
|
||||||
|
LookMemberInfo int32 `gorm:"column:look_member_info" json:"lookMemberInfo"`
|
||||||
|
ApplyMemberFriend int32 `gorm:"column:apply_member_friend" json:"applyMemberFriend"`
|
||||||
|
NotificationUpdateTime time.Time `gorm:"column:notification_update_time"`
|
||||||
|
NotificationUserID string `gorm:"column:notification_user_id;size:64"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GroupMemberModel struct {
|
||||||
|
GroupID string `gorm:"column:group_id;primary_key;size:64"`
|
||||||
|
UserID string `gorm:"column:user_id;primary_key;size:64"`
|
||||||
|
Nickname string `gorm:"column:nickname;size:255"`
|
||||||
|
FaceURL string `gorm:"column:user_group_face_url;size:255"`
|
||||||
|
RoleLevel int32 `gorm:"column:role_level"`
|
||||||
|
JoinTime time.Time `gorm:"column:join_time"`
|
||||||
|
JoinSource int32 `gorm:"column:join_source"`
|
||||||
|
InviterUserID string `gorm:"column:inviter_user_id;size:64"`
|
||||||
|
OperatorUserID string `gorm:"column:operator_user_id;size:64"`
|
||||||
|
MuteEndTime time.Time `gorm:"column:mute_end_time"`
|
||||||
|
Ex string `gorm:"column:ex;size:1024"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GroupRequestModel struct {
|
||||||
|
UserID string `gorm:"column:user_id;primary_key;size:64"`
|
||||||
|
GroupID string `gorm:"column:group_id;primary_key;size:64"`
|
||||||
|
HandleResult int32 `gorm:"column:handle_result"`
|
||||||
|
ReqMsg string `gorm:"column:req_msg;size:1024"`
|
||||||
|
HandledMsg string `gorm:"column:handle_msg;size:1024"`
|
||||||
|
ReqTime time.Time `gorm:"column:req_time"`
|
||||||
|
HandleUserID string `gorm:"column:handle_user_id;size:64"`
|
||||||
|
HandledTime time.Time `gorm:"column:handle_time"`
|
||||||
|
JoinSource int32 `gorm:"column:join_source"`
|
||||||
|
InviterUserID string `gorm:"column:inviter_user_id;size:64"`
|
||||||
|
Ex string `gorm:"column:ex;size:1024"`
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user