test-errcode
parent
58866c1b41
commit
6ab9cff3c3
@ -1,14 +1,25 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
server_api_params "Open_IM/pkg/proto/sdk_ws"
|
||||
"context"
|
||||
"errors"
|
||||
)
|
||||
|
||||
func GetUserInfo(ctx context.Context, userID string) (interface{}, error) {
|
||||
func GetUserInfo(ctx context.Context, userID string) (*server_api_params.PublicUserInfo, error) {
|
||||
return nil, errors.New("TODO:GetUserInfo")
|
||||
}
|
||||
|
||||
func GetUserInfoBatch(ctx context.Context, userIDs []string) (interface{}, error) {
|
||||
func GetPublicUserInfoBatch(ctx context.Context, userIDs []string) ([]*server_api_params.PublicUserInfo, error) {
|
||||
if len(userIDs) == 0 {
|
||||
return []*server_api_params.PublicUserInfo{}, nil
|
||||
}
|
||||
return nil, errors.New("TODO:GetUserInfo")
|
||||
}
|
||||
|
||||
func GetUserInfoList(ctx context.Context, userIDs []string) ([]*server_api_params.UserInfo, error) {
|
||||
if len(userIDs) == 0 {
|
||||
return []*server_api_params.UserInfo{}, nil
|
||||
}
|
||||
return nil, errors.New("TODO:GetUserInfo")
|
||||
}
|
||||
|
@ -0,0 +1,40 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/db/cache"
|
||||
"Open_IM/pkg/common/db/mysql"
|
||||
"context"
|
||||
)
|
||||
|
||||
type BlackModel struct {
|
||||
db *mysql.Black
|
||||
cache *cache.GroupCache
|
||||
}
|
||||
|
||||
func (b *BlackModel) Create(ctx context.Context, blacks []*mysql.Black) (err error) {
|
||||
return b.db.Create(ctx, blacks)
|
||||
}
|
||||
|
||||
func (b *BlackModel) Delete(ctx context.Context, blacks []*mysql.Black) (err error) {
|
||||
return b.db.Delete(ctx, blacks)
|
||||
}
|
||||
|
||||
func (b *BlackModel) UpdateByMap(ctx context.Context, ownerUserID, blockUserID string, args map[string]interface{}) (err error) {
|
||||
return b.db.UpdateByMap(ctx, ownerUserID, blockUserID, args)
|
||||
}
|
||||
|
||||
func (b *BlackModel) Update(ctx context.Context, blacks []*mysql.Black) (err error) {
|
||||
return b.db.Update(ctx, blacks)
|
||||
}
|
||||
|
||||
func (b *BlackModel) Find(ctx context.Context, blacks []*mysql.Black) (blackList []*mysql.Black, err error) {
|
||||
return b.db.Find(ctx, blacks)
|
||||
}
|
||||
|
||||
func (b *BlackModel) Take(ctx context.Context, blackID string) (black *mysql.Black, err error) {
|
||||
return b.db.Take(ctx, blackID)
|
||||
}
|
||||
|
||||
func (b *BlackModel) FindByOwnerUserID(ctx context.Context, ownerUserID string) (blackList []*mysql.Black, err error) {
|
||||
return b.db.FindByOwnerUserID(ctx, ownerUserID)
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/db/cache"
|
||||
"Open_IM/pkg/common/db/mysql"
|
||||
"context"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type FriendModel struct {
|
||||
db *mysql.Friend
|
||||
cache *cache.GroupCache
|
||||
}
|
||||
|
||||
func (f *FriendModel) Create(ctx context.Context, friends []*mysql.Friend) (err error) {
|
||||
return f.db.Create(ctx, friends)
|
||||
}
|
||||
|
||||
func (f *FriendModel) Delete(ctx context.Context, ownerUserID string, friendUserIDs string) (err error) {
|
||||
return f.db.Delete(ctx, ownerUserID, friendUserIDs)
|
||||
}
|
||||
|
||||
func (f *FriendModel) UpdateByMap(ctx context.Context, ownerUserID string, args map[string]interface{}) (err error) {
|
||||
return f.db.UpdateByMap(ctx, ownerUserID, args)
|
||||
}
|
||||
|
||||
func (f *FriendModel) Update(ctx context.Context, friends []*mysql.Friend) (err error) {
|
||||
return f.db.Update(ctx, friends)
|
||||
}
|
||||
|
||||
func (f *FriendModel) UpdateRemark(ctx context.Context, ownerUserID, friendUserID, remark string) (err error) {
|
||||
return f.db.UpdateRemark(ctx, ownerUserID, friendUserID, remark)
|
||||
}
|
||||
|
||||
func (f *FriendModel) FindOwnerUserID(ctx context.Context, ownerUserID string) (friends []*mysql.Friend, err error) {
|
||||
return f.db.FindOwnerUserID(ctx, ownerUserID)
|
||||
}
|
||||
|
||||
func (f *FriendModel) FindFriendUserID(ctx context.Context, friendUserID string) (friends []*mysql.Friend, err error) {
|
||||
return f.db.FindFriendUserID(ctx, friendUserID)
|
||||
}
|
||||
|
||||
func (f *FriendModel) Take(ctx context.Context, ownerUserID, friendUserID string) (friend *mysql.Friend, err error) {
|
||||
return f.db.Take(ctx, ownerUserID, friendUserID)
|
||||
}
|
||||
|
||||
func (f *FriendModel) FindUserState(ctx context.Context, userID1, userID2 string) (friends []*mysql.Friend, err error) {
|
||||
return f.db.FindUserState(ctx, userID1, userID2)
|
||||
}
|
||||
|
||||
func (f *FriendModel) IsExist(ctx context.Context, ownerUserID, friendUserID string) (bool, error) {
|
||||
if _, err := f.Take(ctx, ownerUserID, friendUserID); err == nil {
|
||||
return true, nil
|
||||
} else if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return false, nil
|
||||
} else {
|
||||
return false, err
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/db/cache"
|
||||
"Open_IM/pkg/common/db/mysql"
|
||||
"context"
|
||||
)
|
||||
|
||||
type FriendRequestModel struct {
|
||||
db *mysql.FriendRequest
|
||||
cache *cache.GroupCache
|
||||
}
|
||||
|
||||
func (f *FriendRequestModel) Create(ctx context.Context, friends []*mysql.FriendRequest) (err error) {
|
||||
return f.db.Create(ctx, friends)
|
||||
}
|
||||
|
||||
func (f *FriendRequestModel) Delete(ctx context.Context, fromUserID, toUserID string) (err error) {
|
||||
return f.db.Delete(ctx, fromUserID, toUserID)
|
||||
}
|
||||
|
||||
func (f *FriendRequestModel) UpdateByMap(ctx context.Context, ownerUserID string, args map[string]interface{}) (err error) {
|
||||
return f.db.UpdateByMap(ctx, ownerUserID, args)
|
||||
}
|
||||
|
||||
func (f *FriendRequestModel) Update(ctx context.Context, friends []*mysql.FriendRequest) (err error) {
|
||||
return f.db.Update(ctx, friends)
|
||||
}
|
||||
|
||||
func (f *FriendRequestModel) Find(ctx context.Context, ownerUserID string) (friends []*mysql.FriendRequest, err error) {
|
||||
return f.db.Find(ctx, ownerUserID)
|
||||
}
|
||||
|
||||
func (f *FriendRequestModel) Take(ctx context.Context, fromUserID, toUserID string) (friend *mysql.FriendRequest, err error) {
|
||||
return f.db.Take(ctx, fromUserID, toUserID)
|
||||
}
|
||||
|
||||
func (f *FriendRequestModel) FindToUserID(ctx context.Context, toUserID string) (friends []*mysql.FriendRequest, err error) {
|
||||
return f.db.FindToUserID(ctx, toUserID)
|
||||
}
|
||||
|
||||
func (f *FriendRequestModel) FindFromUserID(ctx context.Context, fromUserID string) (friends []*mysql.FriendRequest, err error) {
|
||||
return f.db.FindFromUserID(ctx, fromUserID)
|
||||
}
|
Loading…
Reference in new issue