Skip to content

Commit

Permalink
fix: update user bool
Browse files Browse the repository at this point in the history
  • Loading branch information
bookpanda committed Jun 30, 2024
1 parent f17d8ca commit 0c48e9f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/golang-jwt/jwt/v4 v4.5.0
github.com/golang/mock v1.6.0
github.com/google/uuid v1.6.0
github.com/isd-sgcu/rpkm67-go-proto v0.2.0
github.com/isd-sgcu/rpkm67-go-proto v0.2.2
github.com/isd-sgcu/rpkm67-model v0.0.4
github.com/joho/godotenv v1.5.1
github.com/pkg/errors v0.9.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ github.com/isd-sgcu/rpkm67-go-proto v0.1.8 h1:ng1FzEeJIOrMHNg1FrSnbdquwYRlfOW/az
github.com/isd-sgcu/rpkm67-go-proto v0.1.8/go.mod h1:Z5SYz5kEe4W+MdqPouF0zEOiaqvg+s9I1S5d0q6e+Jw=
github.com/isd-sgcu/rpkm67-go-proto v0.2.0 h1:tPfNgCuqS4g0f+2hzcpY+8hYXSa7DZDPvRejRzOk2cI=
github.com/isd-sgcu/rpkm67-go-proto v0.2.0/go.mod h1:Z5SYz5kEe4W+MdqPouF0zEOiaqvg+s9I1S5d0q6e+Jw=
github.com/isd-sgcu/rpkm67-go-proto v0.2.2 h1:FP2EBqRp+/z2DUSXygOC7SgmS1T3ZRlm4gqRhpU7qbw=
github.com/isd-sgcu/rpkm67-go-proto v0.2.2/go.mod h1:Z5SYz5kEe4W+MdqPouF0zEOiaqvg+s9I1S5d0q6e+Jw=
github.com/isd-sgcu/rpkm67-model v0.0.3 h1:xvUNozwDIc0e5a68NQPzViH5ICID+5n/0wlMJLXp5Gw=
github.com/isd-sgcu/rpkm67-model v0.0.3/go.mod h1:dxgLSkrFpbQOXsrzqgepZoEOyZUIG2LBGtm5gsuBbVc=
github.com/isd-sgcu/rpkm67-model v0.0.4 h1:tk6z6pXnhWBoG2SaSIoyLxNnwRaXwdbSIEEa/cSi8EY=
Expand Down
3 changes: 1 addition & 2 deletions internal/user/user.service.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ func (s *serviceImpl) FindOne(_ context.Context, req *proto.FindOneUserRequest)
return nil, status.Error(codes.Internal, err.Error())
}

s.log.Named("FindOne").Info("FindOne: ", zap.Any("user", ModelToProto(user)))
return &proto.FindOneUserResponse{
User: ModelToProto(user),
}, nil
Expand Down Expand Up @@ -103,6 +102,6 @@ func (s *serviceImpl) Update(_ context.Context, req *proto.UpdateUserRequest) (r
}

return &proto.UpdateUserResponse{
User: ModelToProto(updateUser),
Success: true,
}, nil
}
21 changes: 12 additions & 9 deletions internal/user/user.utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,7 @@ func ModelToProto(in *model.User) *proto.User {
}

func UpdateRequestToModel(in *proto.UpdateUserRequest) (*model.User, error) {
groupId, err := uuid.Parse(in.GroupId)
if err != nil {
return nil, err
}

return &model.User{
Email: in.Email,
user := &model.User{
Nickname: in.Nickname,
Title: in.Title,
Firstname: in.Firstname,
Expand All @@ -61,7 +55,16 @@ func UpdateRequestToModel(in *proto.UpdateUserRequest) (*model.User, error) {
PhotoKey: in.PhotoKey,
PhotoUrl: in.PhotoUrl,
Baan: in.Baan,
GroupID: &groupId,
ReceiveGift: int(in.ReceiveGift),
}, nil
}

if in.GroupId != "" {
groupId, err := uuid.Parse(in.GroupId)
if err != nil {
return nil, err
}
user.GroupID = &groupId
}

return user, nil
}

0 comments on commit 0c48e9f

Please sign in to comment.