relation

package
v3.3.0-rc.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsMysqlDuplicateKey

func IsMysqlDuplicateKey(err error) bool

func NewBlackGorm

func NewBlackGorm(db *gorm.DB) relation.BlackModelInterface

func NewChatLogGorm

func NewChatLogGorm(db *gorm.DB) relation.ChatLogModelInterface

func NewConversationGorm

func NewConversationGorm(db *gorm.DB) relation.ConversationModelInterface

func NewFriendGorm

func NewFriendGorm(db *gorm.DB) relation.FriendModelInterface

func NewFriendRequestGorm

func NewFriendRequestGorm(db *gorm.DB) relation.FriendRequestModelInterface

func NewGormDB

func NewGormDB() (*gorm.DB, error)

NewGormDB gorm mysql.

func NewGroupDB

func NewGroupDB(db *gorm.DB) relation.GroupModelInterface

func NewGroupMemberDB

func NewGroupMemberDB(db *gorm.DB) relation.GroupMemberModelInterface

func NewGroupRequest

func NewGroupRequest(db *gorm.DB) relation.GroupRequestModelInterface

func NewObjectInfo

func NewObjectInfo(db *gorm.DB) relation.ObjectInfoModelInterface

func NewUserGorm

func NewUserGorm(db *gorm.DB) relation.UserModelInterface

Types

type BlackGorm

type BlackGorm struct {
	*MetaDB
}

func (*BlackGorm) Create

func (b *BlackGorm) Create(ctx context.Context, blacks []*relation.BlackModel) (err error)

func (*BlackGorm) Delete

func (b *BlackGorm) Delete(ctx context.Context, blacks []*relation.BlackModel) (err error)

func (*BlackGorm) Find

func (b *BlackGorm) Find(
	ctx context.Context,
	blacks []*relation.BlackModel,
) (blackList []*relation.BlackModel, err error)

func (*BlackGorm) FindBlackUserIDs

func (b *BlackGorm) FindBlackUserIDs(ctx context.Context, ownerUserID string) (blackUserIDs []string, err error)

func (*BlackGorm) FindOwnerBlackInfos

func (b *BlackGorm) FindOwnerBlackInfos(ctx context.Context, ownerUserID string, userIDs []string) (blacks []*relation.BlackModel, err error)

func (*BlackGorm) FindOwnerBlacks

func (b *BlackGorm) FindOwnerBlacks(
	ctx context.Context,
	ownerUserID string,
	pageNumber, showNumber int32,
) (blacks []*relation.BlackModel, total int64, err error)

func (*BlackGorm) Take

func (b *BlackGorm) Take(ctx context.Context, ownerUserID, blockUserID string) (black *relation.BlackModel, err error)

func (*BlackGorm) Update

func (b *BlackGorm) Update(ctx context.Context, blacks []*relation.BlackModel) (err error)

func (*BlackGorm) UpdateByMap

func (b *BlackGorm) UpdateByMap(
	ctx context.Context,
	ownerUserID, blockUserID string,
	args map[string]interface{},
) (err error)

type ChatLogGorm

type ChatLogGorm struct {
	*MetaDB
}

func (*ChatLogGorm) Create

func (c *ChatLogGorm) Create(msg *pbmsg.MsgDataToMQ) error

type ConversationGorm

type ConversationGorm struct {
	*MetaDB
}

func (*ConversationGorm) Create

func (c *ConversationGorm) Create(ctx context.Context, conversations []*relation.ConversationModel) (err error)

func (*ConversationGorm) Delete

func (c *ConversationGorm) Delete(ctx context.Context, groupIDs []string) (err error)

func (*ConversationGorm) Find

func (c *ConversationGorm) Find(
	ctx context.Context,
	ownerUserID string,
	conversationIDs []string,
) (conversations []*relation.ConversationModel, err error)

func (*ConversationGorm) FindConversationID

func (c *ConversationGorm) FindConversationID(
	ctx context.Context,
	userID string,
	conversationIDList []string,
) (existConversationID []string, err error)

func (*ConversationGorm) FindRecvMsgNotNotifyUserIDs

func (c *ConversationGorm) FindRecvMsgNotNotifyUserIDs(
	ctx context.Context,
	groupID string,
) (userIDs []string, err error)

func (*ConversationGorm) FindSuperGroupRecvMsgNotNotifyUserIDs

func (c *ConversationGorm) FindSuperGroupRecvMsgNotNotifyUserIDs(
	ctx context.Context,
	groupID string,
) (userIDs []string, err error)

func (*ConversationGorm) FindUserID

func (c *ConversationGorm) FindUserID(
	ctx context.Context,
	userIDs []string,
	conversationIDs []string,
) (existUserID []string, err error)

func (*ConversationGorm) FindUserIDAllConversationID

func (c *ConversationGorm) FindUserIDAllConversationID(
	ctx context.Context,
	userID string,
) (conversationIDList []string, err error)

func (*ConversationGorm) FindUserIDAllConversations

func (c *ConversationGorm) FindUserIDAllConversations(
	ctx context.Context,
	userID string,
) (conversations []*relation.ConversationModel, err error)

func (*ConversationGorm) GetAllConversationIDs

func (c *ConversationGorm) GetAllConversationIDs(ctx context.Context) (conversationIDs []string, err error)

func (*ConversationGorm) GetConversationIDsNeedDestruct

func (c *ConversationGorm) GetConversationIDsNeedDestruct(
	ctx context.Context,
) (conversations []*relation.ConversationModel, err error)

func (*ConversationGorm) GetConversationsByConversationID

func (c *ConversationGorm) GetConversationsByConversationID(
	ctx context.Context,
	conversationIDs []string,
) (conversations []*relation.ConversationModel, err error)

func (*ConversationGorm) GetUserAllHasReadSeqs

func (c *ConversationGorm) GetUserAllHasReadSeqs(
	ctx context.Context,
	ownerUserID string,
) (hasReadSeqs map[string]int64, err error)

func (*ConversationGorm) GetUserRecvMsgOpt

func (c *ConversationGorm) GetUserRecvMsgOpt(
	ctx context.Context,
	ownerUserID, conversationID string,
) (opt int, err error)

func (*ConversationGorm) NewTx

func (*ConversationGorm) Take

func (c *ConversationGorm) Take(
	ctx context.Context,
	userID, conversationID string,
) (conversation *relation.ConversationModel, err error)

func (*ConversationGorm) Update

func (c *ConversationGorm) Update(ctx context.Context, conversation *relation.ConversationModel) (err error)

func (*ConversationGorm) UpdateByMap

func (c *ConversationGorm) UpdateByMap(
	ctx context.Context,
	userIDList []string,
	conversationID string,
	args map[string]interface{},
) (rows int64, err error)

type FriendGorm

type FriendGorm struct {
	*MetaDB
}

func (*FriendGorm) Create

func (f *FriendGorm) Create(ctx context.Context, friends []*relation.FriendModel) (err error)

插入多条记录.

func (*FriendGorm) Delete

func (f *FriendGorm) Delete(ctx context.Context, ownerUserID string, friendUserIDs []string) (err error)

删除ownerUserID指定的好友.

func (*FriendGorm) FindFriendUserIDs

func (f *FriendGorm) FindFriendUserIDs(ctx context.Context, ownerUserID string) (friendUserIDs []string, err error)

func (*FriendGorm) FindFriends

func (f *FriendGorm) FindFriends(
	ctx context.Context,
	ownerUserID string,
	friendUserIDs []string,
) (friends []*relation.FriendModel, err error)

获取 owner指定的好友列表 如果有friendUserIDs不存在,也不返回错误.

func (*FriendGorm) FindInWhoseFriends

func (f *FriendGorm) FindInWhoseFriends(
	ctx context.Context,
	friendUserID string,
	pageNumber, showNumber int32,
) (friends []*relation.FriendModel, total int64, err error)

获取哪些人添加了friendUserID 支持翻页.

func (*FriendGorm) FindOwnerFriends

func (f *FriendGorm) FindOwnerFriends(
	ctx context.Context,
	ownerUserID string,
	pageNumber, showNumber int32,
) (friends []*relation.FriendModel, total int64, err error)

获取ownerUserID好友列表 支持翻页.

func (*FriendGorm) FindReversalFriends

func (f *FriendGorm) FindReversalFriends(
	ctx context.Context,
	friendUserID string,
	ownerUserIDs []string,
) (friends []*relation.FriendModel, err error)

获取哪些人添加了friendUserID 如果有ownerUserIDs不存在,也不返回错误.

func (*FriendGorm) FindUserState

func (f *FriendGorm) FindUserState(
	ctx context.Context,
	userID1, userID2 string,
) (friends []*relation.FriendModel, err error)

查找好友关系,如果是双向关系,则都返回.

func (*FriendGorm) NewTx

func (*FriendGorm) Take

func (f *FriendGorm) Take(
	ctx context.Context,
	ownerUserID, friendUserID string,
) (friend *relation.FriendModel, err error)

获取单个好友信息,如没找到 返回错误.

func (*FriendGorm) Update

func (f *FriendGorm) Update(ctx context.Context, friends []*relation.FriendModel) (err error)

更新好友信息的非零值.

func (*FriendGorm) UpdateByMap

func (f *FriendGorm) UpdateByMap(
	ctx context.Context,
	ownerUserID string,
	friendUserID string,
	args map[string]interface{},
) (err error)

更新ownerUserID单个好友信息 更新零值.

func (*FriendGorm) UpdateRemark

func (f *FriendGorm) UpdateRemark(ctx context.Context, ownerUserID, friendUserID, remark string) (err error)

更新好友备注(也支持零值 ).

type FriendRequestGorm

type FriendRequestGorm struct {
	*MetaDB
}

func (*FriendRequestGorm) Create

func (f *FriendRequestGorm) Create(ctx context.Context, friendRequests []*relation.FriendRequestModel) (err error)

插入多条记录.

func (*FriendRequestGorm) Delete

func (f *FriendRequestGorm) Delete(ctx context.Context, fromUserID, toUserID string) (err error)

删除记录.

func (*FriendRequestGorm) Find

func (f *FriendRequestGorm) Find(
	ctx context.Context,
	fromUserID, toUserID string,
) (friendRequest *relation.FriendRequestModel, err error)

获取来指定用户的好友申请 未找到 不返回错误.

func (*FriendRequestGorm) FindBothFriendRequests

func (f *FriendRequestGorm) FindBothFriendRequests(ctx context.Context, fromUserID, toUserID string) (friends []*relation.FriendRequestModel, err error)

func (*FriendRequestGorm) FindFromUserID

func (f *FriendRequestGorm) FindFromUserID(
	ctx context.Context,
	fromUserID string,
	pageNumber, showNumber int32,
) (friendRequests []*relation.FriendRequestModel, total int64, err error)

获取fromUserID发出去的好友申请列表.

func (*FriendRequestGorm) FindToUserID

func (f *FriendRequestGorm) FindToUserID(
	ctx context.Context,
	toUserID string,
	pageNumber, showNumber int32,
) (friendRequests []*relation.FriendRequestModel, total int64, err error)

获取toUserID收到的好友申请列表.

func (*FriendRequestGorm) NewTx

func (*FriendRequestGorm) Take

func (f *FriendRequestGorm) Take(
	ctx context.Context,
	fromUserID, toUserID string,
) (friendRequest *relation.FriendRequestModel, err error)

func (*FriendRequestGorm) Update

func (f *FriendRequestGorm) Update(ctx context.Context, friendRequest *relation.FriendRequestModel) (err error)

更新记录 (非零值).

func (*FriendRequestGorm) UpdateByMap

func (f *FriendRequestGorm) UpdateByMap(
	ctx context.Context,
	fromUserID string,
	toUserID string,
	args map[string]interface{},
) (err error)

更新零值.

type GroupGorm

type GroupGorm struct {
	*MetaDB
}

func (*GroupGorm) CountRangeEverydayTotal

func (g *GroupGorm) CountRangeEverydayTotal(ctx context.Context, start time.Time, end time.Time) (map[string]int64, error)

func (*GroupGorm) CountTotal

func (g *GroupGorm) CountTotal(ctx context.Context, before *time.Time) (count int64, err error)

func (*GroupGorm) Create

func (g *GroupGorm) Create(ctx context.Context, groups []*relation.GroupModel) (err error)

func (*GroupGorm) Find

func (g *GroupGorm) Find(ctx context.Context, groupIDs []string) (groups []*relation.GroupModel, err error)

func (*GroupGorm) FindNotDismissedGroup

func (g *GroupGorm) FindNotDismissedGroup(ctx context.Context, groupIDs []string) (groups []*relation.GroupModel, err error)

func (*GroupGorm) GetGroupIDsByGroupType

func (g *GroupGorm) GetGroupIDsByGroupType(ctx context.Context, groupType int) (groupIDs []string, err error)

func (*GroupGorm) NewTx

func (*GroupGorm) Search

func (g *GroupGorm) Search(ctx context.Context, keyword string, pageNumber, showNumber int32) (total uint32, groups []*relation.GroupModel, err error)

func (*GroupGorm) Take

func (g *GroupGorm) Take(ctx context.Context, groupID string) (group *relation.GroupModel, err error)

func (*GroupGorm) UpdateMap

func (g *GroupGorm) UpdateMap(ctx context.Context, groupID string, args map[string]interface{}) (err error)

func (*GroupGorm) UpdateStatus

func (g *GroupGorm) UpdateStatus(ctx context.Context, groupID string, status int32) (err error)

type GroupMemberGorm

type GroupMemberGorm struct {
	*MetaDB
}

func (*GroupMemberGorm) Create

func (g *GroupMemberGorm) Create(ctx context.Context, groupMemberList []*relation.GroupMemberModel) (err error)

func (*GroupMemberGorm) Delete

func (g *GroupMemberGorm) Delete(ctx context.Context, groupID string, userIDs []string) (err error)

func (*GroupMemberGorm) DeleteGroup

func (g *GroupMemberGorm) DeleteGroup(ctx context.Context, groupIDs []string) (err error)

func (*GroupMemberGorm) Find

func (g *GroupMemberGorm) Find(
	ctx context.Context,
	groupIDs []string,
	userIDs []string,
	roleLevels []int32,
) (groupMembers []*relation.GroupMemberModel, err error)

func (*GroupMemberGorm) FindJoinUserID

func (g *GroupMemberGorm) FindJoinUserID(
	ctx context.Context,
	groupIDs []string,
) (groupUsers map[string][]string, err error)

func (*GroupMemberGorm) FindMemberUserID

func (g *GroupMemberGorm) FindMemberUserID(ctx context.Context, groupID string) (userIDs []string, err error)

func (*GroupMemberGorm) FindUserJoinedGroupID

func (g *GroupMemberGorm) FindUserJoinedGroupID(ctx context.Context, userID string) (groupIDs []string, err error)

func (*GroupMemberGorm) FindUserManagedGroupID

func (g *GroupMemberGorm) FindUserManagedGroupID(ctx context.Context, userID string) (groupIDs []string, err error)

func (*GroupMemberGorm) FindUsersJoinedGroupID

func (g *GroupMemberGorm) FindUsersJoinedGroupID(ctx context.Context, userIDs []string) (map[string][]string, error)

func (*GroupMemberGorm) MapGroupMemberNum

func (g *GroupMemberGorm) MapGroupMemberNum(
	ctx context.Context,
	groupIDs []string,
) (count map[string]uint32, err error)

func (*GroupMemberGorm) NewTx

func (*GroupMemberGorm) SearchMember

func (g *GroupMemberGorm) SearchMember(
	ctx context.Context,
	keyword string,
	groupIDs []string,
	userIDs []string,
	roleLevels []int32,
	pageNumber, showNumber int32,
) (total uint32, groupList []*relation.GroupMemberModel, err error)

func (*GroupMemberGorm) Take

func (g *GroupMemberGorm) Take(
	ctx context.Context,
	groupID string,
	userID string,
) (groupMember *relation.GroupMemberModel, err error)

func (*GroupMemberGorm) TakeGroupMemberNum

func (g *GroupMemberGorm) TakeGroupMemberNum(ctx context.Context, groupID string) (count int64, err error)

func (*GroupMemberGorm) TakeOwner

func (g *GroupMemberGorm) TakeOwner(
	ctx context.Context,
	groupID string,
) (groupMember *relation.GroupMemberModel, err error)

func (*GroupMemberGorm) Update

func (g *GroupMemberGorm) Update(ctx context.Context, groupID string, userID string, data map[string]any) (err error)

func (*GroupMemberGorm) UpdateRoleLevel

func (g *GroupMemberGorm) UpdateRoleLevel(
	ctx context.Context,
	groupID string,
	userID string,
	roleLevel int32,
) (rowsAffected int64, err error)

type GroupRequestGorm

type GroupRequestGorm struct {
	*MetaDB
}

func (*GroupRequestGorm) Create

func (g *GroupRequestGorm) Create(ctx context.Context, groupRequests []*relation.GroupRequestModel) (err error)

func (*GroupRequestGorm) Delete

func (g *GroupRequestGorm) Delete(ctx context.Context, groupID string, userID string) (err error)

func (*GroupRequestGorm) FindGroupRequests

func (g *GroupRequestGorm) FindGroupRequests(ctx context.Context, groupID string, userIDs []string) (total int64, groupRequests []*relation.GroupRequestModel, err error)

func (*GroupRequestGorm) NewTx

func (*GroupRequestGorm) Page

func (g *GroupRequestGorm) Page(
	ctx context.Context,
	userID string,
	pageNumber, showNumber int32,
) (total uint32, groups []*relation.GroupRequestModel, err error)

func (*GroupRequestGorm) PageGroup

func (g *GroupRequestGorm) PageGroup(
	ctx context.Context,
	groupIDs []string,
	pageNumber, showNumber int32,
) (total uint32, groups []*relation.GroupRequestModel, err error)

func (*GroupRequestGorm) Take

func (g *GroupRequestGorm) Take(
	ctx context.Context,
	groupID string,
	userID string,
) (groupRequest *relation.GroupRequestModel, err error)

func (*GroupRequestGorm) UpdateHandler

func (g *GroupRequestGorm) UpdateHandler(
	ctx context.Context,
	groupID string,
	userID string,
	handledMsg string,
	handleResult int32,
) (err error)

type MetaDB

type MetaDB struct {
	DB *gorm.DB
	// contains filtered or unexported fields
}

func NewMetaDB

func NewMetaDB(db *gorm.DB, table any) *MetaDB

type ObjectInfoGorm

type ObjectInfoGorm struct {
	*MetaDB
}

func (*ObjectInfoGorm) NewTx

func (*ObjectInfoGorm) SetObject

func (o *ObjectInfoGorm) SetObject(ctx context.Context, obj *relation.ObjectModel) (err error)

func (*ObjectInfoGorm) Take

func (o *ObjectInfoGorm) Take(ctx context.Context, name string) (info *relation.ObjectModel, err error)

type UserGorm

type UserGorm struct {
	*MetaDB
}

func (*UserGorm) CountRangeEverydayTotal

func (u *UserGorm) CountRangeEverydayTotal(
	ctx context.Context,
	start time.Time,
	end time.Time,
) (map[string]int64, error)

func (*UserGorm) CountTotal

func (u *UserGorm) CountTotal(ctx context.Context, before *time.Time) (count int64, err error)

func (*UserGorm) Create

func (u *UserGorm) Create(ctx context.Context, users []*relation.UserModel) (err error)

插入多条.

func (*UserGorm) Find

func (u *UserGorm) Find(ctx context.Context, userIDs []string) (users []*relation.UserModel, err error)

获取指定用户信息 不存在,也不返回错误.

func (*UserGorm) GetAllUserID

func (u *UserGorm) GetAllUserID(ctx context.Context, pageNumber, showNumber int32) (userIDs []string, err error)

获取所有用户ID.

func (*UserGorm) GetUserGlobalRecvMsgOpt

func (u *UserGorm) GetUserGlobalRecvMsgOpt(ctx context.Context, userID string) (opt int, err error)

func (*UserGorm) Page

func (u *UserGorm) Page(
	ctx context.Context,
	pageNumber, showNumber int32,
) (users []*relation.UserModel, count int64, err error)

获取用户信息 不存在,不返回错误.

func (*UserGorm) Take

func (u *UserGorm) Take(ctx context.Context, userID string) (user *relation.UserModel, err error)

获取某个用户信息 不存在,则返回错误.

func (*UserGorm) Update

func (u *UserGorm) Update(ctx context.Context, user *relation.UserModel) (err error)

更新多个用户信息 非零值.

func (*UserGorm) UpdateByMap

func (u *UserGorm) UpdateByMap(ctx context.Context, userID string, args map[string]interface{}) (err error)

更新用户信息 零值.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL