mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-05 01:25:58 +08:00
Merge branch 'errcode' of github.com:OpenIMSDK/Open-IM-Server into errcode
Conflicts: pkg/common/db/controller/group.go
This commit is contained in:
@@ -17,7 +17,9 @@ type GroupInterface interface {
|
||||
CreateGroup(ctx context.Context, groups []*relation.Group, groupMember []*relation.GroupMember) error
|
||||
DeleteGroupByIDs(ctx context.Context, groupIDs []string) error
|
||||
TakeGroupByID(ctx context.Context, groupID string) (group *relation.Group, err error)
|
||||
|
||||
GetJoinedGroupList(ctx context.Context, userID string) ([]*relation.Group, error)
|
||||
GetGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]int, error)
|
||||
GetGroupOwnerUserID(ctx context.Context, groupIDs []string) (map[string]string, error)
|
||||
//mongo
|
||||
CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error
|
||||
GetSuperGroupByID(ctx context.Context, groupID string) (superGroup *unrelation.SuperGroup, err error)
|
||||
@@ -146,6 +148,11 @@ func (g *GroupDataBase) Update(ctx context.Context, groups []*relation.Group) er
|
||||
})
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) GetJoinedGroupList(ctx context.Context, userID string) ([]*relation.Group, error) {
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error {
|
||||
sess, err := g.mongoDB.MgoClient.StartSession()
|
||||
if err != nil {
|
||||
|
||||
@@ -11,6 +11,8 @@ type UserInterface interface {
|
||||
Create(ctx context.Context, users []*relation.User) error
|
||||
Take(ctx context.Context, userID string) (user *relation.User, err error)
|
||||
Update(ctx context.Context, users []*relation.User) (err error)
|
||||
UpdateByMap(ctx context.Context, userID string, args map[string]interface{}) (err error)
|
||||
GetByName(ctx context.Context, userName string, showNumber, pageNumber int32) (users []*relation.User, err error)
|
||||
}
|
||||
|
||||
type UserController struct {
|
||||
@@ -29,6 +31,12 @@ func (u *UserController) Take(ctx context.Context, userID string) (user *relatio
|
||||
func (u *UserController) Update(ctx context.Context, users []*relation.User) (err error) {
|
||||
return u.database.Update(ctx, users)
|
||||
}
|
||||
func (u *UserController) UpdateByMap(ctx context.Context, userID string, args map[string]interface{}) (err error) {
|
||||
return u.database.UpdateByMap(ctx, userID, args)
|
||||
}
|
||||
func (u *UserController) GetByName(ctx context.Context, userName string, showNumber, pageNumber int32) (users []*relation.User, err error) {
|
||||
return u.database.GetByName(ctx, userName, showNumber, pageNumber)
|
||||
}
|
||||
|
||||
func NewUserController(db *gorm.DB) UserInterface {
|
||||
controller := &UserController{database: newUserDatabase(db)}
|
||||
@@ -40,6 +48,8 @@ type UserDatabaseInterface interface {
|
||||
Create(ctx context.Context, users []*relation.User) error
|
||||
Take(ctx context.Context, userID string) (user *relation.User, err error)
|
||||
Update(ctx context.Context, users []*relation.User) (err error)
|
||||
UpdateByMap(ctx context.Context, userID string, args map[string]interface{}) (err error)
|
||||
GetByName(ctx context.Context, userName string, showNumber, pageNumber int32) (users []*relation.User, err error)
|
||||
}
|
||||
|
||||
type UserDatabase struct {
|
||||
@@ -67,3 +77,9 @@ func (u *UserDatabase) Take(ctx context.Context, userID string) (user *relation.
|
||||
func (u *UserDatabase) Update(ctx context.Context, users []*relation.User) (err error) {
|
||||
return u.sqlDB.Update(ctx, users)
|
||||
}
|
||||
func (u *UserDatabase) UpdateByMap(ctx context.Context, userID string, args map[string]interface{}) (err error) {
|
||||
return u.sqlDB.UpdateByMap(ctx, userID, args)
|
||||
}
|
||||
func (u *UserDatabase) GetByName(ctx context.Context, userName string, showNumber, pageNumber int32) (users []*relation.User, err error) {
|
||||
return u.sqlDB.GetByName(ctx, userName, showNumber, pageNumber)
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"Open_IM/pkg/common/trace_log"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"fmt"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
@@ -69,3 +70,11 @@ func (u *User) Take(ctx context.Context, userID string) (user *User, err error)
|
||||
err = utils.Wrap(u.DB.Where("user_id = ?", userID).Take(&user).Error, "")
|
||||
return user, err
|
||||
}
|
||||
|
||||
func (u *User) GetByName(ctx context.Context, userName string, showNumber, pageNumber int32) (users []*User, err error) {
|
||||
defer func() {
|
||||
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userName", userName, "showNumber", showNumber, "pageNumber", pageNumber, "users", users)
|
||||
}()
|
||||
err = u.DB.Where(" name like ?", fmt.Sprintf("%%%s%%", userName)).Limit(int(showNumber)).Offset(int(showNumber * (pageNumber - 1))).Find(&users).Error
|
||||
return users, utils.Wrap(err, "")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user