mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-13 05:25:59 +08:00
Merge branch 'errcode' of github.com:OpenIMSDK/Open-IM-Server into errcode
Conflicts: internal/api/group/group.go internal/api/group/super_group.go pkg/common/db/controller/user.go
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
relation2 "Open_IM/pkg/common/db/relation"
|
||||
"Open_IM/pkg/common/db/table/relation"
|
||||
"context"
|
||||
"errors"
|
||||
@@ -27,17 +28,17 @@ func NewBlackController(db *gorm.DB) *BlackController {
|
||||
}
|
||||
|
||||
// Create 增加黑名单
|
||||
func (b *BlackController) Create(ctx context.Context, blacks []*relation.Black) (err error) {
|
||||
func (b *BlackController) Create(ctx context.Context, blacks []*relation.BlackModel) (err error) {
|
||||
return b.database.Create(ctx, blacks)
|
||||
}
|
||||
|
||||
// Delete 删除黑名单
|
||||
func (b *BlackController) Delete(ctx context.Context, blacks []*relation.Black) (err error) {
|
||||
func (b *BlackController) Delete(ctx context.Context, blacks []*relation.BlackModel) (err error) {
|
||||
return b.database.Delete(ctx, blacks)
|
||||
}
|
||||
|
||||
// FindOwnerBlacks 获取黑名单列表
|
||||
func (b *BlackController) FindOwnerBlacks(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (blackList []*relation.Black, total int64, err error) {
|
||||
func (b *BlackController) FindOwnerBlacks(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (blackList []*relation.BlackModel, total int64, err error) {
|
||||
return b.database.FindOwnerBlacks(ctx, ownerUserID, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
@@ -48,21 +49,21 @@ func (b *BlackController) CheckIn(ctx context.Context, userID1, userID2 string)
|
||||
|
||||
type BlackDatabaseInterface interface {
|
||||
// Create 增加黑名单
|
||||
Create(ctx context.Context, blacks []*relation.Black) (err error)
|
||||
Create(ctx context.Context, blacks []*relation.BlackModel) (err error)
|
||||
// Delete 删除黑名单
|
||||
Delete(ctx context.Context, blacks []*relation.Black) (err error)
|
||||
Delete(ctx context.Context, blacks []*relation.BlackModel) (err error)
|
||||
// FindOwnerBlacks 获取黑名单列表
|
||||
FindOwnerBlacks(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (blacks []*relation.Black, total int64, err error)
|
||||
FindOwnerBlacks(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (blacks []*relation.BlackModel, total int64, err error)
|
||||
// CheckIn 检查user2是否在user1的黑名单列表中(inUser1Blacks==true) 检查user1是否在user2的黑名单列表中(inUser2Blacks==true)
|
||||
CheckIn(ctx context.Context, userID1, userID2 string) (inUser1Blacks bool, inUser2Blacks bool, err error)
|
||||
}
|
||||
|
||||
type BlackDatabase struct {
|
||||
sqlDB *relation.Black
|
||||
sqlDB *relation2.BlackGorm
|
||||
}
|
||||
|
||||
func NewBlackDatabase(db *gorm.DB) *BlackDatabase {
|
||||
sqlDB := relation.NewBlack(db)
|
||||
sqlDB := relation2.NewBlackGorm(db)
|
||||
database := &BlackDatabase{
|
||||
sqlDB: sqlDB,
|
||||
}
|
||||
@@ -70,17 +71,17 @@ func NewBlackDatabase(db *gorm.DB) *BlackDatabase {
|
||||
}
|
||||
|
||||
// Create 增加黑名单
|
||||
func (b *BlackDatabase) Create(ctx context.Context, blacks []*relation.Black) (err error) {
|
||||
func (b *BlackDatabase) Create(ctx context.Context, blacks []*relation.BlackModel) (err error) {
|
||||
return b.sqlDB.Create(ctx, blacks)
|
||||
}
|
||||
|
||||
// Delete 删除黑名单
|
||||
func (b *BlackDatabase) Delete(ctx context.Context, blacks []*relation.Black) (err error) {
|
||||
func (b *BlackDatabase) Delete(ctx context.Context, blacks []*relation.BlackModel) (err error) {
|
||||
return b.sqlDB.Delete(ctx, blacks)
|
||||
}
|
||||
|
||||
// FindOwnerBlacks 获取黑名单列表
|
||||
func (b *BlackDatabase) FindOwnerBlacks(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (blacks []*relation.Black, total int64, err error) {
|
||||
func (b *BlackDatabase) FindOwnerBlacks(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (blacks []*relation.BlackModel, total int64, err error) {
|
||||
return b.sqlDB.FindOwnerBlacks(ctx, ownerUserID, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
|
||||
@@ -81,28 +81,28 @@ func (f *FriendController) UpdateRemark(ctx context.Context, ownerUserID, friend
|
||||
}
|
||||
|
||||
// FindOwnerFriends 获取ownerUserID的好友列表
|
||||
func (f *FriendController) FindOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) {
|
||||
return f.database.FindOwnerFriends(ctx, ownerUserID, pageNumber, showNumber)
|
||||
func (f *FriendController) PageOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) {
|
||||
return f.database.PageOwnerFriends(ctx, ownerUserID, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
// FindInWhoseFriends friendUserID在哪些人的好友列表中
|
||||
func (f *FriendController) FindInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) {
|
||||
return f.database.FindInWhoseFriends(ctx, friendUserID, pageNumber, showNumber)
|
||||
func (f *FriendController) PageInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) {
|
||||
return f.database.PageInWhoseFriends(ctx, friendUserID, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
// FindFriendRequestFromMe 获取我发出去的好友申请
|
||||
func (f *FriendController) FindFriendRequestFromMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) {
|
||||
return f.database.FindFriendRequestFromMe(ctx, userID, pageNumber, showNumber)
|
||||
func (f *FriendController) PageFriendRequestFromMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) {
|
||||
return f.database.PageFriendRequestFromMe(ctx, userID, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
// FindFriendRequestToMe 获取我收到的的好友申请
|
||||
func (f *FriendController) FindFriendRequestToMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) {
|
||||
return f.database.FindFriendRequestToMe(ctx, userID, pageNumber, showNumber)
|
||||
func (f *FriendController) PageFriendRequestToMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) {
|
||||
return f.database.PageFriendRequestToMe(ctx, userID, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
// FindFriends 获取某人指定好友的信息
|
||||
func (f *FriendController) FindFriends(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*relation.FriendModel, err error) {
|
||||
return f.database.FindFriends(ctx, ownerUserID, friendUserIDs)
|
||||
func (f *FriendController) FindFriendsWithError(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*relation.FriendModel, err error) {
|
||||
return f.database.FindFriendsWithError(ctx, ownerUserID, friendUserIDs)
|
||||
}
|
||||
|
||||
type FriendDatabaseInterface interface {
|
||||
@@ -121,15 +121,15 @@ type FriendDatabaseInterface interface {
|
||||
// 更新好友备注
|
||||
UpdateRemark(ctx context.Context, ownerUserID, friendUserID, remark string) (err error)
|
||||
// 获取ownerUserID的好友列表
|
||||
FindOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error)
|
||||
PageOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error)
|
||||
// friendUserID在哪些人的好友列表中
|
||||
FindInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error)
|
||||
PageInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error)
|
||||
// 获取我发出去的好友申请
|
||||
FindFriendRequestFromMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error)
|
||||
PageFriendRequestFromMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error)
|
||||
// 获取我收到的的好友申请
|
||||
FindFriendRequestToMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error)
|
||||
PageFriendRequestToMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error)
|
||||
// 获取某人指定好友的信息
|
||||
FindFriends(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*relation.FriendModel, err error)
|
||||
FindFriendsWithError(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*relation.FriendModel, err error)
|
||||
}
|
||||
|
||||
type FriendDatabase struct {
|
||||
@@ -302,27 +302,27 @@ func (f *FriendDatabase) UpdateRemark(ctx context.Context, ownerUserID, friendUs
|
||||
}
|
||||
|
||||
// 获取ownerUserID的好友列表 无结果不返回错误
|
||||
func (f *FriendDatabase) FindOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) {
|
||||
func (f *FriendDatabase) PageOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) {
|
||||
return f.friend.FindOwnerFriends(ctx, ownerUserID, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
// friendUserID在哪些人的好友列表中
|
||||
func (f *FriendDatabase) FindInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) {
|
||||
func (f *FriendDatabase) PageInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) {
|
||||
return f.friend.FindInWhoseFriends(ctx, friendUserID, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
// 获取我发出去的好友申请 无结果不返回错误
|
||||
func (f *FriendDatabase) FindFriendRequestFromMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) {
|
||||
func (f *FriendDatabase) PageFriendRequestFromMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) {
|
||||
return f.friendRequest.FindFromUserID(ctx, userID, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
// 获取我收到的的好友申请 无结果不返回错误
|
||||
func (f *FriendDatabase) FindFriendRequestToMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) {
|
||||
func (f *FriendDatabase) PageFriendRequestToMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) {
|
||||
return f.friendRequest.FindToUserID(ctx, userID, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
// 获取某人指定好友的信息 如果有好友不存在,也返回错误
|
||||
func (f *FriendDatabase) FindFriends(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*relation.FriendModel, err error) {
|
||||
func (f *FriendDatabase) FindFriendsWithError(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*relation.FriendModel, err error) {
|
||||
friends, err = f.friend.FindFriends(ctx, ownerUserID, friendUserIDs)
|
||||
if err != nil {
|
||||
return
|
||||
|
||||
@@ -29,7 +29,12 @@ type UserController struct {
|
||||
database UserDatabaseInterface
|
||||
}
|
||||
|
||||
func (u *UserController) Find(ctx context.Context, userIDs []string) (users []*relationTb.UserModel, err error) {
|
||||
// 获取指定用户的信息 如有userID未找到 也返回错误
|
||||
func (u *UserController) FindWithError(ctx context.Context, userIDs []string) (users []*relation2.UserModel, err error) {
|
||||
return u.database.FindWithError(ctx, userIDs)
|
||||
}
|
||||
|
||||
func (u *UserController) Find(ctx context.Context, userIDs []string) (users []*relation2.UserModel, err error) {
|
||||
return u.database.Find(ctx, userIDs)
|
||||
}
|
||||
func (u *UserController) Create(ctx context.Context, users []*relationTb.UserModel) error {
|
||||
@@ -43,8 +48,8 @@ func (u *UserController) UpdateByMap(ctx context.Context, userID string, args ma
|
||||
return u.database.UpdateByMap(ctx, userID, args)
|
||||
}
|
||||
|
||||
func (u *UserController) Get(ctx context.Context, pageNumber, showNumber int32) (users []*relationTb.UserModel, count int64, err error) {
|
||||
return u.database.Get(ctx, pageNumber, showNumber)
|
||||
func (u *UserController) Page(ctx context.Context, pageNumber, showNumber int32) (users []*relationTb.UserModel, count int64, err error) {
|
||||
return u.database.Page(ctx, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
func (u *UserController) IsExist(ctx context.Context, userIDs []string) (exist bool, err error) {
|
||||
@@ -56,11 +61,19 @@ func NewUserController(db *gorm.DB) *UserController {
|
||||
}
|
||||
|
||||
type UserDatabaseInterface interface {
|
||||
//获取指定用户的信息 如有userID未找到 也返回错误
|
||||
FindWithError(ctx context.Context, userIDs []string) (users []*relationTb.UserModel, err error)
|
||||
//获取指定用户的信息 如有userID未找到 不返回错误
|
||||
Find(ctx context.Context, userIDs []string) (users []*relationTb.UserModel, err error)
|
||||
Create(ctx context.Context, users []*relationTb.UserModel) error
|
||||
//插入多条 外部保证userID 不重复 且在db中不存在
|
||||
Create(ctx context.Context, users []*relationTb.UserModel) (err error)
|
||||
//更新(非零值) 外部保证userID存在
|
||||
Update(ctx context.Context, users []*relationTb.UserModel) (err error)
|
||||
//更新(零值) 外部保证userID存在
|
||||
UpdateByMap(ctx context.Context, userID string, args map[string]interface{}) (err error)
|
||||
Get(ctx context.Context, pageNumber, showNumber int32) (users []*relationTb.UserModel, count int64, err error)
|
||||
//如果没找到,不返回错误
|
||||
Page(ctx context.Context, pageNumber, showNumber int32) (users []*relationTb.UserModel, count int64, err error)
|
||||
//只要有一个存在就为true
|
||||
IsExist(ctx context.Context, userIDs []string) (exist bool, err error)
|
||||
}
|
||||
|
||||
@@ -77,7 +90,7 @@ func newUserDatabase(db *gorm.DB) *UserDatabase {
|
||||
}
|
||||
|
||||
// 获取指定用户的信息 如有userID未找到 也返回错误
|
||||
func (u *UserDatabase) Find(ctx context.Context, userIDs []string) (users []*relationTb.UserModel, err error) {
|
||||
func (u *UserDatabase) FindWithError(ctx context.Context, userIDs []string) (users []*relation2.UserModel, err error) {
|
||||
users, err = u.user.Find(ctx, userIDs)
|
||||
if err != nil {
|
||||
return
|
||||
@@ -88,6 +101,12 @@ func (u *UserDatabase) Find(ctx context.Context, userIDs []string) (users []*rel
|
||||
return
|
||||
}
|
||||
|
||||
// 获取指定用户的信息 如有userID未找到 不返回错误
|
||||
func (u *UserDatabase) Find(ctx context.Context, userIDs []string) (users []*relation2.UserModel, err error) {
|
||||
users, err = u.user.Find(ctx, userIDs)
|
||||
return
|
||||
}
|
||||
|
||||
// 插入多条 外部保证userID 不重复 且在db中不存在
|
||||
func (u *UserDatabase) Create(ctx context.Context, users []*relationTb.UserModel) (err error) {
|
||||
return u.user.Create(ctx, users)
|
||||
@@ -104,8 +123,8 @@ func (u *UserDatabase) UpdateByMap(ctx context.Context, userID string, args map[
|
||||
}
|
||||
|
||||
// 获取,如果没找到,不返回错误
|
||||
func (u *UserDatabase) Get(ctx context.Context, showNumber, pageNumber int32) (users []*relationTb.UserModel, count int64, err error) {
|
||||
return u.user.Get(ctx, showNumber, pageNumber)
|
||||
func (u *UserDatabase) Page(ctx context.Context, showNumber, pageNumber int32) (users []*relation2.UserModel, count int64, err error) {
|
||||
return u.user.Page(ctx, showNumber, pageNumber)
|
||||
}
|
||||
|
||||
// userIDs是否存在 只要有一个存在就为true
|
||||
|
||||
@@ -31,7 +31,7 @@ type FriendUser struct {
|
||||
}
|
||||
|
||||
// 插入多条记录
|
||||
func (f *FriendGorm) Create(ctx context.Context, friends []*relation.FriendModel, tx ...*gorm.DB) (err error) {
|
||||
func (f *FriendGorm) Create(ctx context.Context, friends []*relation.FriendModel, tx ...any) (err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "friends", friends)
|
||||
}()
|
||||
@@ -39,7 +39,7 @@ func (f *FriendGorm) Create(ctx context.Context, friends []*relation.FriendModel
|
||||
}
|
||||
|
||||
// 删除ownerUserID指定的好友
|
||||
func (f *FriendGorm) Delete(ctx context.Context, ownerUserID string, friendUserIDs []string, tx ...*gorm.DB) (err error) {
|
||||
func (f *FriendGorm) Delete(ctx context.Context, ownerUserID string, friendUserIDs []string, tx ...any) (err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "friendUserIDs", friendUserIDs)
|
||||
}()
|
||||
@@ -48,7 +48,7 @@ func (f *FriendGorm) Delete(ctx context.Context, ownerUserID string, friendUserI
|
||||
}
|
||||
|
||||
// 更新ownerUserID单个好友信息 更新零值
|
||||
func (f *FriendGorm) UpdateByMap(ctx context.Context, ownerUserID string, friendUserID string, args map[string]interface{}, tx ...*gorm.DB) (err error) {
|
||||
func (f *FriendGorm) UpdateByMap(ctx context.Context, ownerUserID string, friendUserID string, args map[string]interface{}, tx ...any) (err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "friendUserID", friendUserID, "args", args)
|
||||
}()
|
||||
@@ -56,7 +56,7 @@ func (f *FriendGorm) UpdateByMap(ctx context.Context, ownerUserID string, friend
|
||||
}
|
||||
|
||||
// 更新好友信息的非零值
|
||||
func (f *FriendGorm) Update(ctx context.Context, friends []*relation.FriendModel, tx ...*gorm.DB) (err error) {
|
||||
func (f *FriendGorm) Update(ctx context.Context, friends []*relation.FriendModel, tx ...any) (err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "friends", friends)
|
||||
}()
|
||||
@@ -64,7 +64,7 @@ func (f *FriendGorm) Update(ctx context.Context, friends []*relation.FriendModel
|
||||
}
|
||||
|
||||
// 更新好友备注(也支持零值 )
|
||||
func (f *FriendGorm) UpdateRemark(ctx context.Context, ownerUserID, friendUserID, remark string, tx ...*gorm.DB) (err error) {
|
||||
func (f *FriendGorm) UpdateRemark(ctx context.Context, ownerUserID, friendUserID, remark string, tx ...any) (err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "friendUserID", friendUserID, "remark", remark)
|
||||
}()
|
||||
@@ -78,14 +78,14 @@ func (f *FriendGorm) UpdateRemark(ctx context.Context, ownerUserID, friendUserID
|
||||
}
|
||||
|
||||
// 获取单个好友信息,如没找到 返回错误
|
||||
func (f *FriendGorm) Take(ctx context.Context, ownerUserID, friendUserID string, tx ...*gorm.DB) (friend *relation.FriendModel, err error) {
|
||||
func (f *FriendGorm) Take(ctx context.Context, ownerUserID, friendUserID string, tx ...any) (friend *relation.FriendModel, err error) {
|
||||
friend = &relation.FriendModel{}
|
||||
defer tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "friendUserID", friendUserID, "friend", *friend)
|
||||
return friend, utils.Wrap(getDBConn(f.DB, tx).Where("owner_user_id = ? and friend_user_id", ownerUserID, friendUserID).Take(friend).Error, "")
|
||||
}
|
||||
|
||||
// 查找好友关系,如果是双向关系,则都返回
|
||||
func (f *FriendGorm) FindUserState(ctx context.Context, userID1, userID2 string, tx ...*gorm.DB) (friends []*relation.FriendModel, err error) {
|
||||
func (f *FriendGorm) FindUserState(ctx context.Context, userID1, userID2 string, tx ...any) (friends []*relation.FriendModel, err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID1", userID1, "userID2", userID2, "friends", friends)
|
||||
}()
|
||||
@@ -93,7 +93,7 @@ func (f *FriendGorm) FindUserState(ctx context.Context, userID1, userID2 string,
|
||||
}
|
||||
|
||||
// 获取 owner指定的好友列表 如果有friendUserIDs不存在,也不返回错误
|
||||
func (f *FriendGorm) FindFriends(ctx context.Context, ownerUserID string, friendUserIDs []string, tx ...*gorm.DB) (friends []*relation.FriendModel, err error) {
|
||||
func (f *FriendGorm) FindFriends(ctx context.Context, ownerUserID string, friendUserIDs []string, tx ...any) (friends []*relation.FriendModel, err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "friendUserIDs", friendUserIDs, "friends", friends)
|
||||
}()
|
||||
@@ -101,7 +101,7 @@ func (f *FriendGorm) FindFriends(ctx context.Context, ownerUserID string, friend
|
||||
}
|
||||
|
||||
// 获取哪些人添加了friendUserID 如果有ownerUserIDs不存在,也不返回错误
|
||||
func (f *FriendGorm) FindReversalFriends(ctx context.Context, friendUserID string, ownerUserIDs []string, tx ...*gorm.DB) (friends []*relation.FriendModel, err error) {
|
||||
func (f *FriendGorm) FindReversalFriends(ctx context.Context, friendUserID string, ownerUserIDs []string, tx ...any) (friends []*relation.FriendModel, err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "friendUserID", friendUserID, "ownerUserIDs", ownerUserIDs, "friends", friends)
|
||||
}()
|
||||
@@ -109,7 +109,7 @@ func (f *FriendGorm) FindReversalFriends(ctx context.Context, friendUserID strin
|
||||
}
|
||||
|
||||
// 获取ownerUserID好友列表 支持翻页
|
||||
func (f *FriendGorm) FindOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32, tx ...*gorm.DB) (friends []*relation.FriendModel, total int64, err error) {
|
||||
func (f *FriendGorm) FindOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32, tx ...any) (friends []*relation.FriendModel, total int64, err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "pageNumber", pageNumber, "showNumber", showNumber, "friends", friends, "total", total)
|
||||
}()
|
||||
@@ -122,7 +122,7 @@ func (f *FriendGorm) FindOwnerFriends(ctx context.Context, ownerUserID string, p
|
||||
}
|
||||
|
||||
// 获取哪些人添加了friendUserID 支持翻页
|
||||
func (f *FriendGorm) FindInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32, tx ...*gorm.DB) (friends []*relation.FriendModel, total int64, err error) {
|
||||
func (f *FriendGorm) FindInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32, tx ...any) (friends []*relation.FriendModel, total int64, err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "friendUserID", friendUserID, "pageNumber", pageNumber, "showNumber", showNumber, "friends", friends, "total", total)
|
||||
}()
|
||||
|
||||
@@ -20,7 +20,7 @@ func NewUserGorm(db *gorm.DB) *UserGorm {
|
||||
}
|
||||
|
||||
// 插入多条
|
||||
func (u *UserGorm) Create(ctx context.Context, users []*relation.UserModel, tx ...*gorm.DB) (err error) {
|
||||
func (u *UserGorm) Create(ctx context.Context, users []*relation.UserModel, tx ...any) (err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "users", users)
|
||||
}()
|
||||
@@ -28,7 +28,7 @@ func (u *UserGorm) Create(ctx context.Context, users []*relation.UserModel, tx .
|
||||
}
|
||||
|
||||
// 更新用户信息 零值
|
||||
func (u *UserGorm) UpdateByMap(ctx context.Context, userID string, args map[string]interface{}, tx ...*gorm.DB) (err error) {
|
||||
func (u *UserGorm) UpdateByMap(ctx context.Context, userID string, args map[string]interface{}, tx ...any) (err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "args", args)
|
||||
}()
|
||||
@@ -36,7 +36,7 @@ func (u *UserGorm) UpdateByMap(ctx context.Context, userID string, args map[stri
|
||||
}
|
||||
|
||||
// 更新多个用户信息 非零值
|
||||
func (u *UserGorm) Update(ctx context.Context, users []*relation.UserModel, tx ...*gorm.DB) (err error) {
|
||||
func (u *UserGorm) Update(ctx context.Context, users []*relation.UserModel, tx ...any) (err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "users", users)
|
||||
}()
|
||||
@@ -44,7 +44,7 @@ func (u *UserGorm) Update(ctx context.Context, users []*relation.UserModel, tx .
|
||||
}
|
||||
|
||||
// 获取指定用户信息 不存在,也不返回错误
|
||||
func (u *UserGorm) Find(ctx context.Context, userIDs []string, tx ...*gorm.DB) (users []*relation.UserModel, err error) {
|
||||
func (u *UserGorm) Find(ctx context.Context, userIDs []string, tx ...any) (users []*relation.UserModel, err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userIDs", userIDs, "users", users)
|
||||
}()
|
||||
@@ -53,7 +53,7 @@ func (u *UserGorm) Find(ctx context.Context, userIDs []string, tx ...*gorm.DB) (
|
||||
}
|
||||
|
||||
// 获取某个用户信息 不存在,则返回错误
|
||||
func (u *UserGorm) Take(ctx context.Context, userID string, tx ...*gorm.DB) (user *relation.UserModel, err error) {
|
||||
func (u *UserGorm) Take(ctx context.Context, userID string, tx ...any) (user *relation.UserModel, err error) {
|
||||
user = &relation.UserModel{}
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "user", *user)
|
||||
@@ -63,7 +63,7 @@ func (u *UserGorm) Take(ctx context.Context, userID string, tx ...*gorm.DB) (use
|
||||
}
|
||||
|
||||
// 通过名字查找用户 不存在,不返回错误
|
||||
func (u *UserGorm) GetByName(ctx context.Context, userName string, pageNumber, showNumber int32, tx ...*gorm.DB) (users []*relation.UserModel, count int64, err error) {
|
||||
func (u *UserGorm) GetByName(ctx context.Context, userName string, pageNumber, showNumber int32, tx ...any) (users []*relation.UserModel, count int64, err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userName", userName, "pageNumber", pageNumber, "showNumber", showNumber, "users", users, "count", count)
|
||||
}()
|
||||
@@ -76,7 +76,7 @@ func (u *UserGorm) GetByName(ctx context.Context, userName string, pageNumber, s
|
||||
}
|
||||
|
||||
// 通过名字或userID查找用户 不存在,不返回错误
|
||||
func (u *UserGorm) GetByNameAndID(ctx context.Context, content string, pageNumber, showNumber int32, tx ...*gorm.DB) (users []*relation.UserModel, count int64, err error) {
|
||||
func (u *UserGorm) GetByNameAndID(ctx context.Context, content string, pageNumber, showNumber int32, tx ...any) (users []*relation.UserModel, count int64, err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "content", content, "pageNumber", pageNumber, "showNumber", showNumber, "users", users, "count", count)
|
||||
}()
|
||||
@@ -89,7 +89,7 @@ func (u *UserGorm) GetByNameAndID(ctx context.Context, content string, pageNumbe
|
||||
}
|
||||
|
||||
// 获取用户信息 不存在,不返回错误
|
||||
func (u *UserGorm) Get(ctx context.Context, pageNumber, showNumber int32, tx ...*gorm.DB) (users []*relation.UserModel, count int64, err error) {
|
||||
func (u *UserGorm) Page(ctx context.Context, pageNumber, showNumber int32, tx ...any) (users []*relation.UserModel, count int64, err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "pageNumber", pageNumber, "showNumber", showNumber, "users", users, "count", count)
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user