From bc0e3b4076de0ea44b5f2de14c3db008e08e15a8 Mon Sep 17 00:00:00 2001 From: Hoang Date: Tue, 9 Nov 2021 10:54:14 +0700 Subject: [PATCH] fix comment againt --- action_create.go | 6 ++---- action_update.go | 16 ++++++---------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/action_create.go b/action_create.go index cc0cb4a..27a17fc 100644 --- a/action_create.go +++ b/action_create.go @@ -24,8 +24,7 @@ func (s Service) Create(payload CreateOptions) error { ) // Validate payload - err := payload.validate(ctx) - if err != nil { + if err := payload.validate(ctx); err != nil { return err } @@ -36,8 +35,7 @@ func (s Service) Create(payload CreateOptions) error { } // Create user - err = s.userCreate(ctx, doc) - if err != nil { + if err = s.userCreate(ctx, doc); err != nil { return err } diff --git a/action_update.go b/action_update.go index f726b85..064f091 100644 --- a/action_update.go +++ b/action_update.go @@ -30,8 +30,7 @@ func (s Service) UpdateByUserID(userID string, payload UpdateOptions) error { ) // Validate payload - err := payload.validate(ctx) - if err != nil { + if err := payload.validate(ctx); err != nil { return err } @@ -55,8 +54,7 @@ func (s Service) UpdateByUserID(userID string, payload UpdateOptions) error { } // Update - err = s.userUpdateOneByCondition(ctx, cond, updateData) - if err != nil { + if err := s.userUpdateOneByCondition(ctx, cond, updateData); err != nil { return err } @@ -88,13 +86,12 @@ func (s Service) ChangeUserPassword(userID string, opt ChangePasswordOptions) er } // Update password - err = s.userUpdateOneByCondition(ctx, bson.M{"_id": user.ID}, bson.M{ + if err = s.userUpdateOneByCondition(ctx, bson.M{"_id": user.ID}, bson.M{ "$set": bson.M{ "hashedPassword": hashPassword(opt.NewPassword), "updatedAt": now(), }, - }) - if err != nil { + }); err != nil { return err } @@ -114,13 +111,12 @@ func (s Service) ChangeUserStatus(userID, newStatus string) error { } // Update status - err := s.userUpdateOneByCondition(ctx, bson.M{"_id": id}, bson.M{ + if err := s.userUpdateOneByCondition(ctx, bson.M{"_id": id}, bson.M{ "$set": bson.M{ "status": newStatus, "updatedAt": now(), }, - }) - if err != nil { + }); err != nil { return err }