diff --git a/internal/rpc/user/user.go b/internal/rpc/user/user.go index bf28d1f2d..7f340665b 100644 --- a/internal/rpc/user/user.go +++ b/internal/rpc/user/user.go @@ -79,7 +79,7 @@ func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbuser.UpdateUserI if err != nil { return nil, err } - err = s.Update(ctx, []*tablerelation.UserModel{user}) + err = s.Update(ctx, user) if err != nil { return nil, err } diff --git a/pkg/common/db/controller/user.go b/pkg/common/db/controller/user.go index f27af4296..9a3944467 100644 --- a/pkg/common/db/controller/user.go +++ b/pkg/common/db/controller/user.go @@ -15,7 +15,7 @@ type UserDatabase interface { //插入多条 外部保证userID 不重复 且在db中不存在 Create(ctx context.Context, users []*relation.UserModel) (err error) //更新(非零值) 外部保证userID存在 - Update(ctx context.Context, users []*relation.UserModel) (err error) + Update(ctx context.Context, user *relation.UserModel) (err error) //更新(零值) 外部保证userID存在 UpdateByMap(ctx context.Context, userID string, args map[string]interface{}) (err error) //如果没找到,不返回错误 @@ -75,8 +75,8 @@ func (u *userDatabase) Create(ctx context.Context, users []*relation.UserModel) } // 更新(非零值) 外部保证userID存在 -func (u *userDatabase) Update(ctx context.Context, users []*relation.UserModel) (err error) { - return u.userDB.Update(ctx, users) +func (u *userDatabase) Update(ctx context.Context, user *relation.UserModel) (err error) { + return u.userDB.Update(ctx, user) } // 更新(零值) 外部保证userID存在 diff --git a/pkg/common/db/relation/user_model.go b/pkg/common/db/relation/user_model.go index 4f34288d7..734e22a50 100644 --- a/pkg/common/db/relation/user_model.go +++ b/pkg/common/db/relation/user_model.go @@ -26,8 +26,8 @@ func (u *UserGorm) UpdateByMap(ctx context.Context, userID string, args map[stri } // 更新多个用户信息 非零值 -func (u *UserGorm) Update(ctx context.Context, users []*relation.UserModel) (err error) { - return utils.Wrap(u.db(ctx).Updates(&users).Error, "") +func (u *UserGorm) Update(ctx context.Context, user *relation.UserModel) (err error) { + return utils.Wrap(u.db(ctx).Updates(&user).Error, "") } // 获取指定用户信息 不存在,也不返回错误 diff --git a/pkg/common/db/table/relation/user.go b/pkg/common/db/table/relation/user.go index 047046a02..6773b8412 100644 --- a/pkg/common/db/table/relation/user.go +++ b/pkg/common/db/table/relation/user.go @@ -31,7 +31,7 @@ func (UserModel) TableName() string { type UserModelInterface interface { Create(ctx context.Context, users []*UserModel) (err error) UpdateByMap(ctx context.Context, userID string, args map[string]interface{}) (err error) - Update(ctx context.Context, users []*UserModel) (err error) + Update(ctx context.Context, user *UserModel) (err error) // 获取指定用户信息 不存在,也不返回错误 Find(ctx context.Context, userIDs []string) (users []*UserModel, err error) // 获取某个用户信息 不存在,则返回错误