Merge branch 'master' into feature/AllMethod

This commit is contained in:
Hoang 2021-11-09 11:49:08 +07:00
commit 4b4d16fd58
2 changed files with 8 additions and 14 deletions

View File

@ -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
}

View File

@ -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
}