Feature/all method #4
			
				
			
		
		
		
	| 
						 | 
					@ -24,8 +24,7 @@ func (s Service) Create(payload CreateOptions) error {
 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Validate payload
 | 
						// Validate payload
 | 
				
			||||||
	err := payload.validate(ctx)
 | 
						if err := payload.validate(ctx); err != nil {
 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -36,8 +35,7 @@ func (s Service) Create(payload CreateOptions) error {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Create user
 | 
						// Create user
 | 
				
			||||||
	err = s.userCreate(ctx, doc)
 | 
						if err = s.userCreate(ctx, doc); err != nil {
 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -30,8 +30,7 @@ func (s Service) UpdateByUserID(userID string, payload UpdateOptions) error {
 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Validate payload
 | 
						// Validate payload
 | 
				
			||||||
	err := payload.validate(ctx)
 | 
						if err := payload.validate(ctx); err != nil {
 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -55,8 +54,7 @@ func (s Service) UpdateByUserID(userID string, payload UpdateOptions) error {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Update
 | 
						// Update
 | 
				
			||||||
	err = s.userUpdateOneByCondition(ctx, cond, updateData)
 | 
						if err := s.userUpdateOneByCondition(ctx, cond, updateData); err != nil {
 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -88,13 +86,12 @@ func (s Service) ChangeUserPassword(userID string, opt ChangePasswordOptions) er
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Update password
 | 
						// 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{
 | 
							"$set": bson.M{
 | 
				
			||||||
			"hashedPassword": hashPassword(opt.NewPassword),
 | 
								"hashedPassword": hashPassword(opt.NewPassword),
 | 
				
			||||||
			"updatedAt":      now(),
 | 
								"updatedAt":      now(),
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	})
 | 
						}); err != nil {
 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -114,13 +111,12 @@ func (s Service) ChangeUserStatus(userID, newStatus string) error {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Update status
 | 
						// 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{
 | 
							"$set": bson.M{
 | 
				
			||||||
			"status":    newStatus,
 | 
								"status":    newStatus,
 | 
				
			||||||
			"updatedAt": now(),
 | 
								"updatedAt": now(),
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	})
 | 
						}); err != nil {
 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue