add createMethod #1
			
				
			
		
		
		
	| 
						 | 
				
			
			@ -2,11 +2,8 @@ package usermngmt
 | 
			
		|||
| 
					
 | 
			||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
| 
					
 boolean thì: 
 trên sửa lại  boolean thì:
- check existed dùng prefix `is`
- check có value, field nào đó dùng prefix `has`
trên sửa lại `isNameOrPhoneExisted` 
			
		have name or phone existed -> phone number or email already existed have name or phone existed -> phone number or email already existed 
			
		thiếu check roleId trong db thiếu check roleId trong db 
			
		done done 
			
		done done  
			
		done done 
			
		password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword 
			
		isRoleIDAlreadyExisted -> isRoleIDExisted isRoleIDAlreadyExisted -> isRoleIDExisted 
			
		roleID does not exist -> role id does not exist lỗi là ngữ cảnh cho user đọc, nên viết clear tí roleID does not exist -> role id does not exist
lỗi là ngữ cảnh cho user đọc, nên viết clear tí 
			
		func này với func isRoleIDExisted nên đưa vô func  func này với func isRoleIDExisted nên đưa vô func `payload.validate()`, gom tất cả validate trước khi xử lý về 1 chỗ 
			
		bỏ dấu space sau Create bỏ dấu space sau Create 
			
		password do module này hash, xem link này: password do module này hash, xem link này:
https://gowebexamples.com/password-hashing/ 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file 
			
		nên là  note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được nên là `string`, nếu client không dùng mongodb thì phải cài thêm thư viện
note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được 
			
		done done 
			
		done done 
			
		 | 
			||||
 | 
			
		||||
	"github.com/Selly-Modules/logger"
 | 
			
		||||
| 
					
 boolean thì: 
 trên sửa lại  boolean thì:
- check existed dùng prefix `is`
- check có value, field nào đó dùng prefix `has`
trên sửa lại `isNameOrPhoneExisted` 
			
		have name or phone existed -> phone number or email already existed have name or phone existed -> phone number or email already existed 
			
		thiếu check roleId trong db thiếu check roleId trong db 
			
		done done 
			
		done done  
			
		done done 
			
		password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword 
			
		isRoleIDAlreadyExisted -> isRoleIDExisted isRoleIDAlreadyExisted -> isRoleIDExisted 
			
		roleID does not exist -> role id does not exist lỗi là ngữ cảnh cho user đọc, nên viết clear tí roleID does not exist -> role id does not exist
lỗi là ngữ cảnh cho user đọc, nên viết clear tí 
			
		func này với func isRoleIDExisted nên đưa vô func  func này với func isRoleIDExisted nên đưa vô func `payload.validate()`, gom tất cả validate trước khi xử lý về 1 chỗ 
			
		bỏ dấu space sau Create bỏ dấu space sau Create 
			
		password do module này hash, xem link này: password do module này hash, xem link này:
https://gowebexamples.com/password-hashing/ 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file 
			
		nên là  note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được nên là `string`, nếu client không dùng mongodb thì phải cài thêm thư viện
note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được 
			
		done done 
			
		done done 
			
		 | 
			||||
	"github.com/Selly-Modules/mongodb"
 | 
			
		||||
	"go.mongodb.org/mongo-driver/bson/primitive"
 | 
			
		||||
| 
					
 boolean thì: 
 trên sửa lại  boolean thì:
- check existed dùng prefix `is`
- check có value, field nào đó dùng prefix `has`
trên sửa lại `isNameOrPhoneExisted` 
			
		have name or phone existed -> phone number or email already existed have name or phone existed -> phone number or email already existed 
			
		thiếu check roleId trong db thiếu check roleId trong db 
			
		done done 
			
		done done  
			
		done done 
			
		password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword 
			
		isRoleIDAlreadyExisted -> isRoleIDExisted isRoleIDAlreadyExisted -> isRoleIDExisted 
			
		roleID does not exist -> role id does not exist lỗi là ngữ cảnh cho user đọc, nên viết clear tí roleID does not exist -> role id does not exist
lỗi là ngữ cảnh cho user đọc, nên viết clear tí 
			
		func này với func isRoleIDExisted nên đưa vô func  func này với func isRoleIDExisted nên đưa vô func `payload.validate()`, gom tất cả validate trước khi xử lý về 1 chỗ 
			
		bỏ dấu space sau Create bỏ dấu space sau Create 
			
		password do module này hash, xem link này: password do module này hash, xem link này:
https://gowebexamples.com/password-hashing/ 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file 
			
		nên là  note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được nên là `string`, nếu client không dùng mongodb thì phải cài thêm thư viện
note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được 
			
		done done 
			
		done done 
			
		 | 
			||||
)
 | 
			
		||||
 | 
			
		||||
// CreateOptions ...
 | 
			
		||||
| 
						 | 
				
			
			@ -16,14 +13,13 @@ type CreateOptions struct {
 | 
			
		|||
| 
					
 boolean thì: 
 trên sửa lại  boolean thì:
- check existed dùng prefix `is`
- check có value, field nào đó dùng prefix `has`
trên sửa lại `isNameOrPhoneExisted` 
			
		boolean thì: 
 trên sửa lại  boolean thì:
- check existed dùng prefix `is`
- check có value, field nào đó dùng prefix `has`
trên sửa lại `isNameOrPhoneExisted` 
			
		have name or phone existed -> phone number or email already existed have name or phone existed -> phone number or email already existed 
			
		have name or phone existed -> phone number or email already existed have name or phone existed -> phone number or email already existed 
			
		thiếu check roleId trong db thiếu check roleId trong db 
			
		thiếu check roleId trong db thiếu check roleId trong db 
			
		done done 
			
		done done 
			
		done done  
			
		done done  
			
		done done 
			
		done done 
			
		password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword 
			
		password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword 
			
		isRoleIDAlreadyExisted -> isRoleIDExisted isRoleIDAlreadyExisted -> isRoleIDExisted 
			
		isRoleIDAlreadyExisted -> isRoleIDExisted isRoleIDAlreadyExisted -> isRoleIDExisted 
			
		roleID does not exist -> role id does not exist lỗi là ngữ cảnh cho user đọc, nên viết clear tí roleID does not exist -> role id does not exist
lỗi là ngữ cảnh cho user đọc, nên viết clear tí 
			
		roleID does not exist -> role id does not exist lỗi là ngữ cảnh cho user đọc, nên viết clear tí roleID does not exist -> role id does not exist
lỗi là ngữ cảnh cho user đọc, nên viết clear tí 
			
		func này với func isRoleIDExisted nên đưa vô func  func này với func isRoleIDExisted nên đưa vô func `payload.validate()`, gom tất cả validate trước khi xử lý về 1 chỗ 
			
		func này với func isRoleIDExisted nên đưa vô func  func này với func isRoleIDExisted nên đưa vô func `payload.validate()`, gom tất cả validate trước khi xử lý về 1 chỗ 
			
		bỏ dấu space sau Create bỏ dấu space sau Create 
			
		bỏ dấu space sau Create bỏ dấu space sau Create 
			
		password do module này hash, xem link này: password do module này hash, xem link này:
https://gowebexamples.com/password-hashing/ 
			
		password do module này hash, xem link này: password do module này hash, xem link này:
https://gowebexamples.com/password-hashing/ 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file 
			
		đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file 
			
		nên là  note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được nên là `string`, nếu client không dùng mongodb thì phải cài thêm thư viện
note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được 
			
		nên là  note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được nên là `string`, nếu client không dùng mongodb thì phải cài thêm thư viện
note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		 | 
			||||
	Email    string
 | 
			
		||||
	Password string
 | 
			
		||||
	Status   string
 | 
			
		||||
	RoleID   primitive.ObjectID
 | 
			
		||||
| 
					
 boolean thì: 
 trên sửa lại  boolean thì:
- check existed dùng prefix `is`
- check có value, field nào đó dùng prefix `has`
trên sửa lại `isNameOrPhoneExisted` 
			
		have name or phone existed -> phone number or email already existed have name or phone existed -> phone number or email already existed 
			
		thiếu check roleId trong db thiếu check roleId trong db 
			
		done done 
			
		done done  
			
		done done 
			
		password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword 
			
		isRoleIDAlreadyExisted -> isRoleIDExisted isRoleIDAlreadyExisted -> isRoleIDExisted 
			
		roleID does not exist -> role id does not exist lỗi là ngữ cảnh cho user đọc, nên viết clear tí roleID does not exist -> role id does not exist
lỗi là ngữ cảnh cho user đọc, nên viết clear tí 
			
		func này với func isRoleIDExisted nên đưa vô func  func này với func isRoleIDExisted nên đưa vô func `payload.validate()`, gom tất cả validate trước khi xử lý về 1 chỗ 
			
		bỏ dấu space sau Create bỏ dấu space sau Create 
			
		password do module này hash, xem link này: password do module này hash, xem link này:
https://gowebexamples.com/password-hashing/ 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file 
			
		nên là  note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được nên là `string`, nếu client không dùng mongodb thì phải cài thêm thư viện
note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được 
			
		done done 
			
		done done 
			
		 | 
			||||
	RoleID   string
 | 
			
		||||
| 
					
 boolean thì: 
 trên sửa lại  boolean thì:
- check existed dùng prefix `is`
- check có value, field nào đó dùng prefix `has`
trên sửa lại `isNameOrPhoneExisted` 
			
		have name or phone existed -> phone number or email already existed have name or phone existed -> phone number or email already existed 
			
		thiếu check roleId trong db thiếu check roleId trong db 
			
		done done 
			
		done done  
			
		done done 
			
		password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword 
			
		isRoleIDAlreadyExisted -> isRoleIDExisted isRoleIDAlreadyExisted -> isRoleIDExisted 
			
		roleID does not exist -> role id does not exist lỗi là ngữ cảnh cho user đọc, nên viết clear tí roleID does not exist -> role id does not exist
lỗi là ngữ cảnh cho user đọc, nên viết clear tí 
			
		func này với func isRoleIDExisted nên đưa vô func  func này với func isRoleIDExisted nên đưa vô func `payload.validate()`, gom tất cả validate trước khi xử lý về 1 chỗ 
			
		bỏ dấu space sau Create bỏ dấu space sau Create 
			
		password do module này hash, xem link này: password do module này hash, xem link này:
https://gowebexamples.com/password-hashing/ 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file 
			
		nên là  note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được nên là `string`, nếu client không dùng mongodb thì phải cài thêm thư viện
note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được 
			
		done done 
			
		done done 
			
		 | 
			||||
	Other    string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Create ...
 | 
			
		||||
func (s Service) Create(payload CreateOptions) error {
 | 
			
		||||
	var (
 | 
			
		||||
		col = s.getUserCollection()
 | 
			
		||||
| 
					
 boolean thì: 
 trên sửa lại  boolean thì:
- check existed dùng prefix `is`
- check có value, field nào đó dùng prefix `has`
trên sửa lại `isNameOrPhoneExisted` 
			
		have name or phone existed -> phone number or email already existed have name or phone existed -> phone number or email already existed 
			
		thiếu check roleId trong db thiếu check roleId trong db 
			
		done done 
			
		done done  
			
		done done 
			
		password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword 
			
		isRoleIDAlreadyExisted -> isRoleIDExisted isRoleIDAlreadyExisted -> isRoleIDExisted 
			
		roleID does not exist -> role id does not exist lỗi là ngữ cảnh cho user đọc, nên viết clear tí roleID does not exist -> role id does not exist
lỗi là ngữ cảnh cho user đọc, nên viết clear tí 
			
		func này với func isRoleIDExisted nên đưa vô func  func này với func isRoleIDExisted nên đưa vô func `payload.validate()`, gom tất cả validate trước khi xử lý về 1 chỗ 
			
		bỏ dấu space sau Create bỏ dấu space sau Create 
			
		password do module này hash, xem link này: password do module này hash, xem link này:
https://gowebexamples.com/password-hashing/ 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file 
			
		nên là  note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được nên là `string`, nếu client không dùng mongodb thì phải cài thêm thư viện
note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được 
			
		done done 
			
		done done 
			
		 | 
			||||
		ctx = context.Background()
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -34,19 +30,15 @@ func (s Service) Create(payload CreateOptions) error {
 | 
			
		|||
| 
					
 boolean thì: 
 trên sửa lại  boolean thì:
- check existed dùng prefix `is`
- check có value, field nào đó dùng prefix `has`
trên sửa lại `isNameOrPhoneExisted` 
			
		boolean thì: 
 trên sửa lại  boolean thì:
- check existed dùng prefix `is`
- check có value, field nào đó dùng prefix `has`
trên sửa lại `isNameOrPhoneExisted` 
			
		have name or phone existed -> phone number or email already existed have name or phone existed -> phone number or email already existed 
			
		have name or phone existed -> phone number or email already existed have name or phone existed -> phone number or email already existed 
			
		thiếu check roleId trong db thiếu check roleId trong db 
			
		thiếu check roleId trong db thiếu check roleId trong db 
			
		done done 
			
		done done 
			
		done done  
			
		done done  
			
		done done 
			
		done done 
			
		password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword 
			
		password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword 
			
		isRoleIDAlreadyExisted -> isRoleIDExisted isRoleIDAlreadyExisted -> isRoleIDExisted 
			
		isRoleIDAlreadyExisted -> isRoleIDExisted isRoleIDAlreadyExisted -> isRoleIDExisted 
			
		roleID does not exist -> role id does not exist lỗi là ngữ cảnh cho user đọc, nên viết clear tí roleID does not exist -> role id does not exist
lỗi là ngữ cảnh cho user đọc, nên viết clear tí 
			
		roleID does not exist -> role id does not exist lỗi là ngữ cảnh cho user đọc, nên viết clear tí roleID does not exist -> role id does not exist
lỗi là ngữ cảnh cho user đọc, nên viết clear tí 
			
		func này với func isRoleIDExisted nên đưa vô func  func này với func isRoleIDExisted nên đưa vô func `payload.validate()`, gom tất cả validate trước khi xử lý về 1 chỗ 
			
		func này với func isRoleIDExisted nên đưa vô func  func này với func isRoleIDExisted nên đưa vô func `payload.validate()`, gom tất cả validate trước khi xử lý về 1 chỗ 
			
		bỏ dấu space sau Create bỏ dấu space sau Create 
			
		bỏ dấu space sau Create bỏ dấu space sau Create 
			
		password do module này hash, xem link này: password do module này hash, xem link này:
https://gowebexamples.com/password-hashing/ 
			
		password do module này hash, xem link này: password do module này hash, xem link này:
https://gowebexamples.com/password-hashing/ 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file 
			
		đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file 
			
		nên là  note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được nên là `string`, nếu client không dùng mongodb thì phải cài thêm thư viện
note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được 
			
		nên là  note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được nên là `string`, nếu client không dùng mongodb thì phải cài thêm thư viện
note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		 | 
			||||
	}
 | 
			
		||||
 | 
			
		||||
	// New user data from payload
 | 
			
		||||
	userData, err := payload.newUser()
 | 
			
		||||
| 
					
 boolean thì: 
 trên sửa lại  boolean thì:
- check existed dùng prefix `is`
- check có value, field nào đó dùng prefix `has`
trên sửa lại `isNameOrPhoneExisted` 
			
		have name or phone existed -> phone number or email already existed have name or phone existed -> phone number or email already existed 
			
		thiếu check roleId trong db thiếu check roleId trong db 
			
		done done 
			
		done done  
			
		done done 
			
		password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword 
			
		isRoleIDAlreadyExisted -> isRoleIDExisted isRoleIDAlreadyExisted -> isRoleIDExisted 
			
		roleID does not exist -> role id does not exist lỗi là ngữ cảnh cho user đọc, nên viết clear tí roleID does not exist -> role id does not exist
lỗi là ngữ cảnh cho user đọc, nên viết clear tí 
			
		func này với func isRoleIDExisted nên đưa vô func  func này với func isRoleIDExisted nên đưa vô func `payload.validate()`, gom tất cả validate trước khi xử lý về 1 chỗ 
			
		bỏ dấu space sau Create bỏ dấu space sau Create 
			
		password do module này hash, xem link này: password do module này hash, xem link này:
https://gowebexamples.com/password-hashing/ 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file 
			
		nên là  note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được nên là `string`, nếu client không dùng mongodb thì phải cài thêm thư viện
note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được 
			
		done done 
			
		done done 
			
		 | 
			||||
	doc, err := payload.newUser()
 | 
			
		||||
| 
					
 boolean thì: 
 trên sửa lại  boolean thì:
- check existed dùng prefix `is`
- check có value, field nào đó dùng prefix `has`
trên sửa lại `isNameOrPhoneExisted` 
			
		have name or phone existed -> phone number or email already existed have name or phone existed -> phone number or email already existed 
			
		thiếu check roleId trong db thiếu check roleId trong db 
			
		done done 
			
		done done  
			
		done done 
			
		password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword 
			
		isRoleIDAlreadyExisted -> isRoleIDExisted isRoleIDAlreadyExisted -> isRoleIDExisted 
			
		roleID does not exist -> role id does not exist lỗi là ngữ cảnh cho user đọc, nên viết clear tí roleID does not exist -> role id does not exist
lỗi là ngữ cảnh cho user đọc, nên viết clear tí 
			
		func này với func isRoleIDExisted nên đưa vô func  func này với func isRoleIDExisted nên đưa vô func `payload.validate()`, gom tất cả validate trước khi xử lý về 1 chỗ 
			
		bỏ dấu space sau Create bỏ dấu space sau Create 
			
		password do module này hash, xem link này: password do module này hash, xem link này:
https://gowebexamples.com/password-hashing/ 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file 
			
		nên là  note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được nên là `string`, nếu client không dùng mongodb thì phải cài thêm thư viện
note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được 
			
		done done 
			
		done done 
			
		 | 
			||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Create device
 | 
			
		||||
| 
					
 boolean thì: 
 trên sửa lại  boolean thì:
- check existed dùng prefix `is`
- check có value, field nào đó dùng prefix `has`
trên sửa lại `isNameOrPhoneExisted` 
			
		have name or phone existed -> phone number or email already existed have name or phone existed -> phone number or email already existed 
			
		thiếu check roleId trong db thiếu check roleId trong db 
			
		done done 
			
		done done  
			
		done done 
			
		password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword 
			
		isRoleIDAlreadyExisted -> isRoleIDExisted isRoleIDAlreadyExisted -> isRoleIDExisted 
			
		roleID does not exist -> role id does not exist lỗi là ngữ cảnh cho user đọc, nên viết clear tí roleID does not exist -> role id does not exist
lỗi là ngữ cảnh cho user đọc, nên viết clear tí 
			
		func này với func isRoleIDExisted nên đưa vô func  func này với func isRoleIDExisted nên đưa vô func `payload.validate()`, gom tất cả validate trước khi xử lý về 1 chỗ 
			
		bỏ dấu space sau Create bỏ dấu space sau Create 
			
		password do module này hash, xem link này: password do module này hash, xem link này:
https://gowebexamples.com/password-hashing/ 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file 
			
		nên là  note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được nên là `string`, nếu client không dùng mongodb thì phải cài thêm thư viện
note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được 
			
		done done 
			
		done done 
			
		 | 
			||||
	_, err = col.InsertOne(ctx, userData)
 | 
			
		||||
| 
					
 boolean thì: 
 trên sửa lại  boolean thì:
- check existed dùng prefix `is`
- check có value, field nào đó dùng prefix `has`
trên sửa lại `isNameOrPhoneExisted` 
			
		have name or phone existed -> phone number or email already existed have name or phone existed -> phone number or email already existed 
			
		thiếu check roleId trong db thiếu check roleId trong db 
			
		done done 
			
		done done  
			
		done done 
			
		password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword 
			
		isRoleIDAlreadyExisted -> isRoleIDExisted isRoleIDAlreadyExisted -> isRoleIDExisted 
			
		roleID does not exist -> role id does not exist lỗi là ngữ cảnh cho user đọc, nên viết clear tí roleID does not exist -> role id does not exist
lỗi là ngữ cảnh cho user đọc, nên viết clear tí 
			
		func này với func isRoleIDExisted nên đưa vô func  func này với func isRoleIDExisted nên đưa vô func `payload.validate()`, gom tất cả validate trước khi xử lý về 1 chỗ 
			
		bỏ dấu space sau Create bỏ dấu space sau Create 
			
		password do module này hash, xem link này: password do module này hash, xem link này:
https://gowebexamples.com/password-hashing/ 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file 
			
		nên là  note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được nên là `string`, nếu client không dùng mongodb thì phải cài thêm thư viện
note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được 
			
		done done 
			
		done done 
			
		 | 
			||||
	// Create user
 | 
			
		||||
| 
					
 boolean thì: 
 trên sửa lại  boolean thì:
- check existed dùng prefix `is`
- check có value, field nào đó dùng prefix `has`
trên sửa lại `isNameOrPhoneExisted` 
			
		have name or phone existed -> phone number or email already existed have name or phone existed -> phone number or email already existed 
			
		thiếu check roleId trong db thiếu check roleId trong db 
			
		done done 
			
		done done  
			
		done done 
			
		password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword 
			
		isRoleIDAlreadyExisted -> isRoleIDExisted isRoleIDAlreadyExisted -> isRoleIDExisted 
			
		roleID does not exist -> role id does not exist lỗi là ngữ cảnh cho user đọc, nên viết clear tí roleID does not exist -> role id does not exist
lỗi là ngữ cảnh cho user đọc, nên viết clear tí 
			
		func này với func isRoleIDExisted nên đưa vô func  func này với func isRoleIDExisted nên đưa vô func `payload.validate()`, gom tất cả validate trước khi xử lý về 1 chỗ 
			
		bỏ dấu space sau Create bỏ dấu space sau Create 
			
		password do module này hash, xem link này: password do module này hash, xem link này:
https://gowebexamples.com/password-hashing/ 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file 
			
		nên là  note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được nên là `string`, nếu client không dùng mongodb thì phải cài thêm thư viện
note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được 
			
		done done 
			
		done done 
			
		 | 
			||||
	err = s.userCreate(ctx, doc)
 | 
			
		||||
| 
					
 boolean thì: 
 trên sửa lại  boolean thì:
- check existed dùng prefix `is`
- check có value, field nào đó dùng prefix `has`
trên sửa lại `isNameOrPhoneExisted` 
			
		have name or phone existed -> phone number or email already existed have name or phone existed -> phone number or email already existed 
			
		thiếu check roleId trong db thiếu check roleId trong db 
			
		done done 
			
		done done  
			
		done done 
			
		password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword 
			
		isRoleIDAlreadyExisted -> isRoleIDExisted isRoleIDAlreadyExisted -> isRoleIDExisted 
			
		roleID does not exist -> role id does not exist lỗi là ngữ cảnh cho user đọc, nên viết clear tí roleID does not exist -> role id does not exist
lỗi là ngữ cảnh cho user đọc, nên viết clear tí 
			
		func này với func isRoleIDExisted nên đưa vô func  func này với func isRoleIDExisted nên đưa vô func `payload.validate()`, gom tất cả validate trước khi xử lý về 1 chỗ 
			
		bỏ dấu space sau Create bỏ dấu space sau Create 
			
		password do module này hash, xem link này: password do module này hash, xem link này:
https://gowebexamples.com/password-hashing/ 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file 
			
		nên là  note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được nên là `string`, nếu client không dùng mongodb thì phải cài thêm thư viện
note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được 
			
		done done 
			
		done done 
			
		 | 
			||||
	if err != nil {
 | 
			
		||||
		logger.Error("usermngmt - Create", logger.LogData{
 | 
			
		||||
| 
					
 boolean thì: 
 trên sửa lại  boolean thì:
- check existed dùng prefix `is`
- check có value, field nào đó dùng prefix `has`
trên sửa lại `isNameOrPhoneExisted` 
			
		have name or phone existed -> phone number or email already existed have name or phone existed -> phone number or email already existed 
			
		thiếu check roleId trong db thiếu check roleId trong db 
			
		done done 
			
		done done  
			
		done done 
			
		password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword 
			
		isRoleIDAlreadyExisted -> isRoleIDExisted isRoleIDAlreadyExisted -> isRoleIDExisted 
			
		roleID does not exist -> role id does not exist lỗi là ngữ cảnh cho user đọc, nên viết clear tí roleID does not exist -> role id does not exist
lỗi là ngữ cảnh cho user đọc, nên viết clear tí 
			
		func này với func isRoleIDExisted nên đưa vô func  func này với func isRoleIDExisted nên đưa vô func `payload.validate()`, gom tất cả validate trước khi xử lý về 1 chỗ 
			
		bỏ dấu space sau Create bỏ dấu space sau Create 
			
		password do module này hash, xem link này: password do module này hash, xem link này:
https://gowebexamples.com/password-hashing/ 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file 
			
		nên là  note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được nên là `string`, nếu client không dùng mongodb thì phải cài thêm thư viện
note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được 
			
		done done 
			
		done done 
			
		 | 
			||||
			"doc": userData,
 | 
			
		||||
| 
					
 boolean thì: 
 trên sửa lại  boolean thì:
- check existed dùng prefix `is`
- check có value, field nào đó dùng prefix `has`
trên sửa lại `isNameOrPhoneExisted` 
			
		have name or phone existed -> phone number or email already existed have name or phone existed -> phone number or email already existed 
			
		thiếu check roleId trong db thiếu check roleId trong db 
			
		done done 
			
		done done  
			
		done done 
			
		password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword 
			
		isRoleIDAlreadyExisted -> isRoleIDExisted isRoleIDAlreadyExisted -> isRoleIDExisted 
			
		roleID does not exist -> role id does not exist lỗi là ngữ cảnh cho user đọc, nên viết clear tí roleID does not exist -> role id does not exist
lỗi là ngữ cảnh cho user đọc, nên viết clear tí 
			
		func này với func isRoleIDExisted nên đưa vô func  func này với func isRoleIDExisted nên đưa vô func `payload.validate()`, gom tất cả validate trước khi xử lý về 1 chỗ 
			
		bỏ dấu space sau Create bỏ dấu space sau Create 
			
		password do module này hash, xem link này: password do module này hash, xem link này:
https://gowebexamples.com/password-hashing/ 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file 
			
		nên là  note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được nên là `string`, nếu client không dùng mongodb thì phải cài thêm thư viện
note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được 
			
		done done 
			
		done done 
			
		 | 
			||||
			"err": err.Error(),
 | 
			
		||||
| 
					
 boolean thì: 
 trên sửa lại  boolean thì:
- check existed dùng prefix `is`
- check có value, field nào đó dùng prefix `has`
trên sửa lại `isNameOrPhoneExisted` 
			
		have name or phone existed -> phone number or email already existed have name or phone existed -> phone number or email already existed 
			
		thiếu check roleId trong db thiếu check roleId trong db 
			
		done done 
			
		done done  
			
		done done 
			
		password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword 
			
		isRoleIDAlreadyExisted -> isRoleIDExisted isRoleIDAlreadyExisted -> isRoleIDExisted 
			
		roleID does not exist -> role id does not exist lỗi là ngữ cảnh cho user đọc, nên viết clear tí roleID does not exist -> role id does not exist
lỗi là ngữ cảnh cho user đọc, nên viết clear tí 
			
		func này với func isRoleIDExisted nên đưa vô func  func này với func isRoleIDExisted nên đưa vô func `payload.validate()`, gom tất cả validate trước khi xử lý về 1 chỗ 
			
		bỏ dấu space sau Create bỏ dấu space sau Create 
			
		password do module này hash, xem link này: password do module này hash, xem link này:
https://gowebexamples.com/password-hashing/ 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file 
			
		nên là  note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được nên là `string`, nếu client không dùng mongodb thì phải cài thêm thư viện
note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được 
			
		done done 
			
		done done 
			
		 | 
			||||
		})
 | 
			
		||||
| 
					
 boolean thì: 
 trên sửa lại  boolean thì:
- check existed dùng prefix `is`
- check có value, field nào đó dùng prefix `has`
trên sửa lại `isNameOrPhoneExisted` 
			
		have name or phone existed -> phone number or email already existed have name or phone existed -> phone number or email already existed 
			
		thiếu check roleId trong db thiếu check roleId trong db 
			
		done done 
			
		done done  
			
		done done 
			
		password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword 
			
		isRoleIDAlreadyExisted -> isRoleIDExisted isRoleIDAlreadyExisted -> isRoleIDExisted 
			
		roleID does not exist -> role id does not exist lỗi là ngữ cảnh cho user đọc, nên viết clear tí roleID does not exist -> role id does not exist
lỗi là ngữ cảnh cho user đọc, nên viết clear tí 
			
		func này với func isRoleIDExisted nên đưa vô func  func này với func isRoleIDExisted nên đưa vô func `payload.validate()`, gom tất cả validate trước khi xử lý về 1 chỗ 
			
		bỏ dấu space sau Create bỏ dấu space sau Create 
			
		password do module này hash, xem link này: password do module này hash, xem link này:
https://gowebexamples.com/password-hashing/ 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file 
			
		nên là  note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được nên là `string`, nếu client không dùng mongodb thì phải cài thêm thư viện
note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được 
			
		done done 
			
		done done 
			
		 | 
			||||
		return fmt.Errorf("error when create user: %s", err.Error())
 | 
			
		||||
| 
					
 boolean thì: 
 trên sửa lại  boolean thì:
- check existed dùng prefix `is`
- check có value, field nào đó dùng prefix `has`
trên sửa lại `isNameOrPhoneExisted` 
			
		have name or phone existed -> phone number or email already existed have name or phone existed -> phone number or email already existed 
			
		thiếu check roleId trong db thiếu check roleId trong db 
			
		done done 
			
		done done  
			
		done done 
			
		password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword 
			
		isRoleIDAlreadyExisted -> isRoleIDExisted isRoleIDAlreadyExisted -> isRoleIDExisted 
			
		roleID does not exist -> role id does not exist lỗi là ngữ cảnh cho user đọc, nên viết clear tí roleID does not exist -> role id does not exist
lỗi là ngữ cảnh cho user đọc, nên viết clear tí 
			
		func này với func isRoleIDExisted nên đưa vô func  func này với func isRoleIDExisted nên đưa vô func `payload.validate()`, gom tất cả validate trước khi xử lý về 1 chỗ 
			
		bỏ dấu space sau Create bỏ dấu space sau Create 
			
		password do module này hash, xem link này: password do module này hash, xem link này:
https://gowebexamples.com/password-hashing/ 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file 
			
		nên là  note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được nên là `string`, nếu client không dùng mongodb thì phải cài thêm thư viện
note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được 
			
		done done 
			
		done done 
			
		 | 
			||||
		return err
 | 
			
		||||
| 
					
 boolean thì: 
 trên sửa lại  boolean thì:
- check existed dùng prefix `is`
- check có value, field nào đó dùng prefix `has`
trên sửa lại `isNameOrPhoneExisted` 
			
		have name or phone existed -> phone number or email already existed have name or phone existed -> phone number or email already existed 
			
		thiếu check roleId trong db thiếu check roleId trong db 
			
		done done 
			
		done done  
			
		done done 
			
		password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword 
			
		isRoleIDAlreadyExisted -> isRoleIDExisted isRoleIDAlreadyExisted -> isRoleIDExisted 
			
		roleID does not exist -> role id does not exist lỗi là ngữ cảnh cho user đọc, nên viết clear tí roleID does not exist -> role id does not exist
lỗi là ngữ cảnh cho user đọc, nên viết clear tí 
			
		func này với func isRoleIDExisted nên đưa vô func  func này với func isRoleIDExisted nên đưa vô func `payload.validate()`, gom tất cả validate trước khi xử lý về 1 chỗ 
			
		bỏ dấu space sau Create bỏ dấu space sau Create 
			
		password do module này hash, xem link này: password do module này hash, xem link này:
https://gowebexamples.com/password-hashing/ 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file 
			
		nên là  note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được nên là `string`, nếu client không dùng mongodb thì phải cài thêm thư viện
note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được 
			
		done done 
			
		done done 
			
		 | 
			||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
| 
						 | 
				
			
			@ -54,6 +46,7 @@ func (s Service) Create(payload CreateOptions) error {
 | 
			
		|||
| 
					
 boolean thì: 
 trên sửa lại  boolean thì:
- check existed dùng prefix `is`
- check có value, field nào đó dùng prefix `has`
trên sửa lại `isNameOrPhoneExisted` 
			
		boolean thì: 
 trên sửa lại  boolean thì:
- check existed dùng prefix `is`
- check có value, field nào đó dùng prefix `has`
trên sửa lại `isNameOrPhoneExisted` 
			
		have name or phone existed -> phone number or email already existed have name or phone existed -> phone number or email already existed 
			
		have name or phone existed -> phone number or email already existed have name or phone existed -> phone number or email already existed 
			
		thiếu check roleId trong db thiếu check roleId trong db 
			
		thiếu check roleId trong db thiếu check roleId trong db 
			
		done done 
			
		done done 
			
		done done  
			
		done done  
			
		done done 
			
		done done 
			
		password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword 
			
		password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword 
			
		isRoleIDAlreadyExisted -> isRoleIDExisted isRoleIDAlreadyExisted -> isRoleIDExisted 
			
		isRoleIDAlreadyExisted -> isRoleIDExisted isRoleIDAlreadyExisted -> isRoleIDExisted 
			
		roleID does not exist -> role id does not exist lỗi là ngữ cảnh cho user đọc, nên viết clear tí roleID does not exist -> role id does not exist
lỗi là ngữ cảnh cho user đọc, nên viết clear tí 
			
		roleID does not exist -> role id does not exist lỗi là ngữ cảnh cho user đọc, nên viết clear tí roleID does not exist -> role id does not exist
lỗi là ngữ cảnh cho user đọc, nên viết clear tí 
			
		func này với func isRoleIDExisted nên đưa vô func  func này với func isRoleIDExisted nên đưa vô func `payload.validate()`, gom tất cả validate trước khi xử lý về 1 chỗ 
			
		func này với func isRoleIDExisted nên đưa vô func  func này với func isRoleIDExisted nên đưa vô func `payload.validate()`, gom tất cả validate trước khi xử lý về 1 chỗ 
			
		bỏ dấu space sau Create bỏ dấu space sau Create 
			
		bỏ dấu space sau Create bỏ dấu space sau Create 
			
		password do module này hash, xem link này: password do module này hash, xem link này:
https://gowebexamples.com/password-hashing/ 
			
		password do module này hash, xem link này: password do module này hash, xem link này:
https://gowebexamples.com/password-hashing/ 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file 
			
		đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file 
			
		nên là  note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được nên là `string`, nếu client không dùng mongodb thì phải cài thêm thư viện
note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được 
			
		nên là  note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được nên là `string`, nếu client không dùng mongodb thì phải cài thêm thư viện
note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		 | 
			||||
 | 
			
		||||
func (payload CreateOptions) newUser() (result User, err error) {
 | 
			
		||||
	timeNow := now()
 | 
			
		||||
	roleID, _ := mongodb.NewIDFromString(payload.RoleID)
 | 
			
		||||
| 
					
 boolean thì: 
 trên sửa lại  boolean thì:
- check existed dùng prefix `is`
- check có value, field nào đó dùng prefix `has`
trên sửa lại `isNameOrPhoneExisted` 
			
		have name or phone existed -> phone number or email already existed have name or phone existed -> phone number or email already existed 
			
		thiếu check roleId trong db thiếu check roleId trong db 
			
		done done 
			
		done done  
			
		done done 
			
		password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword 
			
		isRoleIDAlreadyExisted -> isRoleIDExisted isRoleIDAlreadyExisted -> isRoleIDExisted 
			
		roleID does not exist -> role id does not exist lỗi là ngữ cảnh cho user đọc, nên viết clear tí roleID does not exist -> role id does not exist
lỗi là ngữ cảnh cho user đọc, nên viết clear tí 
			
		func này với func isRoleIDExisted nên đưa vô func  func này với func isRoleIDExisted nên đưa vô func `payload.validate()`, gom tất cả validate trước khi xử lý về 1 chỗ 
			
		bỏ dấu space sau Create bỏ dấu space sau Create 
			
		password do module này hash, xem link này: password do module này hash, xem link này:
https://gowebexamples.com/password-hashing/ 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file 
			
		nên là  note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được nên là `string`, nếu client không dùng mongodb thì phải cài thêm thư viện
note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được 
			
		done done 
			
		done done 
			
		 | 
			||||
	return User{
 | 
			
		||||
		ID:             mongodb.NewObjectID(),
 | 
			
		||||
		Name:           payload.Name,
 | 
			
		||||
| 
						 | 
				
			
			@ -61,7 +54,7 @@ func (payload CreateOptions) newUser() (result User, err error) {
 | 
			
		|||
| 
					
 boolean thì: 
 trên sửa lại  boolean thì:
- check existed dùng prefix `is`
- check có value, field nào đó dùng prefix `has`
trên sửa lại `isNameOrPhoneExisted` 
			
		boolean thì: 
 trên sửa lại  boolean thì:
- check existed dùng prefix `is`
- check có value, field nào đó dùng prefix `has`
trên sửa lại `isNameOrPhoneExisted` 
			
		have name or phone existed -> phone number or email already existed have name or phone existed -> phone number or email already existed 
			
		have name or phone existed -> phone number or email already existed have name or phone existed -> phone number or email already existed 
			
		thiếu check roleId trong db thiếu check roleId trong db 
			
		thiếu check roleId trong db thiếu check roleId trong db 
			
		done done 
			
		done done 
			
		done done  
			
		done done  
			
		done done 
			
		done done 
			
		password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword 
			
		password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword 
			
		isRoleIDAlreadyExisted -> isRoleIDExisted isRoleIDAlreadyExisted -> isRoleIDExisted 
			
		isRoleIDAlreadyExisted -> isRoleIDExisted isRoleIDAlreadyExisted -> isRoleIDExisted 
			
		roleID does not exist -> role id does not exist lỗi là ngữ cảnh cho user đọc, nên viết clear tí roleID does not exist -> role id does not exist
lỗi là ngữ cảnh cho user đọc, nên viết clear tí 
			
		roleID does not exist -> role id does not exist lỗi là ngữ cảnh cho user đọc, nên viết clear tí roleID does not exist -> role id does not exist
lỗi là ngữ cảnh cho user đọc, nên viết clear tí 
			
		func này với func isRoleIDExisted nên đưa vô func  func này với func isRoleIDExisted nên đưa vô func `payload.validate()`, gom tất cả validate trước khi xử lý về 1 chỗ 
			
		func này với func isRoleIDExisted nên đưa vô func  func này với func isRoleIDExisted nên đưa vô func `payload.validate()`, gom tất cả validate trước khi xử lý về 1 chỗ 
			
		bỏ dấu space sau Create bỏ dấu space sau Create 
			
		bỏ dấu space sau Create bỏ dấu space sau Create 
			
		password do module này hash, xem link này: password do module này hash, xem link này:
https://gowebexamples.com/password-hashing/ 
			
		password do module này hash, xem link này: password do module này hash, xem link này:
https://gowebexamples.com/password-hashing/ 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file 
			
		đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file 
			
		nên là  note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được nên là `string`, nếu client không dùng mongodb thì phải cài thêm thư viện
note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được 
			
		nên là  note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được nên là `string`, nếu client không dùng mongodb thì phải cài thêm thư viện
note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		 | 
			||||
		Email:          payload.Email,
 | 
			
		||||
		HashedPassword: hashPassword(payload.Password),
 | 
			
		||||
		Status:         payload.Status,
 | 
			
		||||
		RoleID:         payload.RoleID,
 | 
			
		||||
| 
					
 boolean thì: 
 trên sửa lại  boolean thì:
- check existed dùng prefix `is`
- check có value, field nào đó dùng prefix `has`
trên sửa lại `isNameOrPhoneExisted` 
			
		have name or phone existed -> phone number or email already existed have name or phone existed -> phone number or email already existed 
			
		thiếu check roleId trong db thiếu check roleId trong db 
			
		done done 
			
		done done  
			
		done done 
			
		password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword 
			
		isRoleIDAlreadyExisted -> isRoleIDExisted isRoleIDAlreadyExisted -> isRoleIDExisted 
			
		roleID does not exist -> role id does not exist lỗi là ngữ cảnh cho user đọc, nên viết clear tí roleID does not exist -> role id does not exist
lỗi là ngữ cảnh cho user đọc, nên viết clear tí 
			
		func này với func isRoleIDExisted nên đưa vô func  func này với func isRoleIDExisted nên đưa vô func `payload.validate()`, gom tất cả validate trước khi xử lý về 1 chỗ 
			
		bỏ dấu space sau Create bỏ dấu space sau Create 
			
		password do module này hash, xem link này: password do module này hash, xem link này:
https://gowebexamples.com/password-hashing/ 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file 
			
		nên là  note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được nên là `string`, nếu client không dùng mongodb thì phải cài thêm thư viện
note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được 
			
		done done 
			
		done done 
			
		 | 
			||||
		RoleID:         roleID,
 | 
			
		||||
| 
					
 boolean thì: 
 trên sửa lại  boolean thì:
- check existed dùng prefix `is`
- check có value, field nào đó dùng prefix `has`
trên sửa lại `isNameOrPhoneExisted` 
			
		have name or phone existed -> phone number or email already existed have name or phone existed -> phone number or email already existed 
			
		thiếu check roleId trong db thiếu check roleId trong db 
			
		done done 
			
		done done  
			
		done done 
			
		password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword 
			
		isRoleIDAlreadyExisted -> isRoleIDExisted isRoleIDAlreadyExisted -> isRoleIDExisted 
			
		roleID does not exist -> role id does not exist lỗi là ngữ cảnh cho user đọc, nên viết clear tí roleID does not exist -> role id does not exist
lỗi là ngữ cảnh cho user đọc, nên viết clear tí 
			
		func này với func isRoleIDExisted nên đưa vô func  func này với func isRoleIDExisted nên đưa vô func `payload.validate()`, gom tất cả validate trước khi xử lý về 1 chỗ 
			
		bỏ dấu space sau Create bỏ dấu space sau Create 
			
		password do module này hash, xem link này: password do module này hash, xem link này:
https://gowebexamples.com/password-hashing/ 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file 
			
		nên là  note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được nên là `string`, nếu client không dùng mongodb thì phải cài thêm thư viện
note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được 
			
		done done 
			
		done done 
			
		 | 
			||||
		Other:          payload.Other,
 | 
			
		||||
		CreatedAt:      timeNow,
 | 
			
		||||
		UpdatedAt:      timeNow,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
					
 boolean thì: 
 trên sửa lại  boolean thì:
- check existed dùng prefix `is`
- check có value, field nào đó dùng prefix `has`
trên sửa lại `isNameOrPhoneExisted` 
			
		boolean thì: 
 trên sửa lại  boolean thì:
- check existed dùng prefix `is`
- check có value, field nào đó dùng prefix `has`
trên sửa lại `isNameOrPhoneExisted` 
			
		have name or phone existed -> phone number or email already existed have name or phone existed -> phone number or email already existed 
			
		have name or phone existed -> phone number or email already existed have name or phone existed -> phone number or email already existed 
			
		thiếu check roleId trong db thiếu check roleId trong db 
			
		thiếu check roleId trong db thiếu check roleId trong db 
			
		done done 
			
		done done 
			
		done done  
			
		done done  
			
		done done 
			
		done done 
			
		password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword 
			
		password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword 
			
		isRoleIDAlreadyExisted -> isRoleIDExisted isRoleIDAlreadyExisted -> isRoleIDExisted 
			
		isRoleIDAlreadyExisted -> isRoleIDExisted isRoleIDAlreadyExisted -> isRoleIDExisted 
			
		roleID does not exist -> role id does not exist lỗi là ngữ cảnh cho user đọc, nên viết clear tí roleID does not exist -> role id does not exist
lỗi là ngữ cảnh cho user đọc, nên viết clear tí 
			
		roleID does not exist -> role id does not exist lỗi là ngữ cảnh cho user đọc, nên viết clear tí roleID does not exist -> role id does not exist
lỗi là ngữ cảnh cho user đọc, nên viết clear tí 
			
		func này với func isRoleIDExisted nên đưa vô func  func này với func isRoleIDExisted nên đưa vô func `payload.validate()`, gom tất cả validate trước khi xử lý về 1 chỗ 
			
		func này với func isRoleIDExisted nên đưa vô func  func này với func isRoleIDExisted nên đưa vô func `payload.validate()`, gom tất cả validate trước khi xử lý về 1 chỗ 
			
		bỏ dấu space sau Create bỏ dấu space sau Create 
			
		bỏ dấu space sau Create bỏ dấu space sau Create 
			
		password do module này hash, xem link này: password do module này hash, xem link này:
https://gowebexamples.com/password-hashing/ 
			
		password do module này hash, xem link này: password do module này hash, xem link này:
https://gowebexamples.com/password-hashing/ 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file 
			
		đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file 
			
		nên là  note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được nên là `string`, nếu client không dùng mongodb thì phải cài thêm thư viện
note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được 
			
		nên là  note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được nên là `string`, nếu client không dùng mongodb thì phải cài thêm thư viện
note: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được 
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		 | 
			||||
| 
						 | 
				
			
			@ -4,6 +4,7 @@ package usermngmt
 | 
			
		|||
const (
 | 
			
		||||
	tableUser          = "users"
 | 
			
		||||
	tableRole          = "roles"
 | 
			
		||||
	tablePrefixDefault = "usermngmt"
 | 
			
		||||
 | 
			
		||||
	timezoneHCM = "Asia/Ho_Chi_Minh"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										25
									
								
								db.go
								
								
								
								
							
							
						
						| 
						 | 
				
			
			@ -12,18 +12,12 @@ import (
 | 
			
		|||
| 
					
 isPhoneNumberOrPhoneExisted isPhoneNumberOrPhoneExisted 
			
		isPhoneNumberOrPhoneExisted isPhoneNumberOrPhoneExisted 
			
		chỗ này count là được chớ cần gì find chỗ này count là được chớ cần gì find 
			
		chỗ này count là được chớ cần gì find chỗ này count là được chớ cần gì find 
			
		count luôn count luôn 
			
		count luôn count luôn 
			
		done done  
			
		done done  
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		set default rồi, bỏ cái này đi set default rồi, bỏ cái này đi 
			
		set default rồi, bỏ cái này đi set default rồi, bỏ cái này đi 
			
		done done 
			
		done done 
			
		 | 
			||||
 | 
			
		||||
//  getUserCollection ...
 | 
			
		||||
func (s Service) getUserCollection() *mongo.Collection {
 | 
			
		||||
	if s.TablePrefix != "" {
 | 
			
		||||
| 
					
 isPhoneNumberOrPhoneExisted isPhoneNumberOrPhoneExisted 
			
		chỗ này count là được chớ cần gì find chỗ này count là được chớ cần gì find 
			
		count luôn count luôn 
			
		done done  
			
		done done 
			
		done done 
			
		set default rồi, bỏ cái này đi set default rồi, bỏ cái này đi 
			
		done done 
			
		 | 
			||||
	return s.DB.Collection(fmt.Sprintf("%s-%s", s.TablePrefix, tableUser))
 | 
			
		||||
	}
 | 
			
		||||
| 
					
 isPhoneNumberOrPhoneExisted isPhoneNumberOrPhoneExisted 
			
		chỗ này count là được chớ cần gì find chỗ này count là được chớ cần gì find 
			
		count luôn count luôn 
			
		done done  
			
		done done 
			
		done done 
			
		set default rồi, bỏ cái này đi set default rồi, bỏ cái này đi 
			
		done done 
			
		 | 
			||||
	return s.DB.Collection(tableUser)
 | 
			
		||||
| 
					
 isPhoneNumberOrPhoneExisted isPhoneNumberOrPhoneExisted 
			
		chỗ này count là được chớ cần gì find chỗ này count là được chớ cần gì find 
			
		count luôn count luôn 
			
		done done  
			
		done done 
			
		done done 
			
		set default rồi, bỏ cái này đi set default rồi, bỏ cái này đi 
			
		done done 
			
		 | 
			||||
}
 | 
			
		||||
 | 
			
		||||
//  getRoleCollection ...
 | 
			
		||||
func (s Service) getRoleCollection() *mongo.Collection {
 | 
			
		||||
	if s.TablePrefix != "" {
 | 
			
		||||
| 
					
 isPhoneNumberOrPhoneExisted isPhoneNumberOrPhoneExisted 
			
		chỗ này count là được chớ cần gì find chỗ này count là được chớ cần gì find 
			
		count luôn count luôn 
			
		done done  
			
		done done 
			
		done done 
			
		set default rồi, bỏ cái này đi set default rồi, bỏ cái này đi 
			
		done done 
			
		 | 
			||||
		s.DB.Collection(fmt.Sprintf("%s-%s", s.TablePrefix, tableRole))
 | 
			
		||||
| 
					
 isPhoneNumberOrPhoneExisted isPhoneNumberOrPhoneExisted 
			
		chỗ này count là được chớ cần gì find chỗ này count là được chớ cần gì find 
			
		count luôn count luôn 
			
		done done  
			
		done done 
			
		done done 
			
		set default rồi, bỏ cái này đi set default rồi, bỏ cái này đi 
			
		done done 
			
		 | 
			||||
	}
 | 
			
		||||
| 
					
 isPhoneNumberOrPhoneExisted isPhoneNumberOrPhoneExisted 
			
		chỗ này count là được chớ cần gì find chỗ này count là được chớ cần gì find 
			
		count luôn count luôn 
			
		done done  
			
		done done 
			
		done done 
			
		set default rồi, bỏ cái này đi set default rồi, bỏ cái này đi 
			
		done done 
			
		 | 
			||||
	return s.DB.Collection(tableRole)
 | 
			
		||||
| 
					
 isPhoneNumberOrPhoneExisted isPhoneNumberOrPhoneExisted 
			
		chỗ này count là được chớ cần gì find chỗ này count là được chớ cần gì find 
			
		count luôn count luôn 
			
		done done  
			
		done done 
			
		done done 
			
		set default rồi, bỏ cái này đi set default rồi, bỏ cái này đi 
			
		done done 
			
		 | 
			||||
	return s.DB.Collection(fmt.Sprintf("%s-%s", s.TablePrefix, tableRole))
 | 
			
		||||
| 
					
 isPhoneNumberOrPhoneExisted isPhoneNumberOrPhoneExisted 
			
		chỗ này count là được chớ cần gì find chỗ này count là được chớ cần gì find 
			
		count luôn count luôn 
			
		done done  
			
		done done 
			
		done done 
			
		set default rồi, bỏ cái này đi set default rồi, bỏ cái này đi 
			
		done done 
			
		 | 
			||||
}
 | 
			
		||||
 | 
			
		||||
func (s Service) isPhoneNumberOrEmailExisted(ctx context.Context, phone, email string) bool {
 | 
			
		||||
| 
						 | 
				
			
			@ -72,3 +66,20 @@ func (s Service) isRoleIDExisted(ctx context.Context, roleID primitive.ObjectID)
 | 
			
		|||
| 
					
 isPhoneNumberOrPhoneExisted isPhoneNumberOrPhoneExisted 
			
		isPhoneNumberOrPhoneExisted isPhoneNumberOrPhoneExisted 
			
		chỗ này count là được chớ cần gì find chỗ này count là được chớ cần gì find 
			
		chỗ này count là được chớ cần gì find chỗ này count là được chớ cần gì find 
			
		count luôn count luôn 
			
		count luôn count luôn 
			
		done done  
			
		done done  
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		set default rồi, bỏ cái này đi set default rồi, bỏ cái này đi 
			
		set default rồi, bỏ cái này đi set default rồi, bỏ cái này đi 
			
		done done 
			
		done done 
			
		 | 
			||||
	}
 | 
			
		||||
	return total != 0
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
					
 isPhoneNumberOrPhoneExisted isPhoneNumberOrPhoneExisted 
			
		chỗ này count là được chớ cần gì find chỗ này count là được chớ cần gì find 
			
		count luôn count luôn 
			
		done done  
			
		done done 
			
		done done 
			
		set default rồi, bỏ cái này đi set default rồi, bỏ cái này đi 
			
		done done 
			
		 | 
			||||
func (s Service) userCreate(ctx context.Context, doc User) error {
 | 
			
		||||
| 
					
 isPhoneNumberOrPhoneExisted isPhoneNumberOrPhoneExisted 
			
		chỗ này count là được chớ cần gì find chỗ này count là được chớ cần gì find 
			
		count luôn count luôn 
			
		done done  
			
		done done 
			
		done done 
			
		set default rồi, bỏ cái này đi set default rồi, bỏ cái này đi 
			
		done done 
			
		 | 
			||||
	var (
 | 
			
		||||
| 
					
 isPhoneNumberOrPhoneExisted isPhoneNumberOrPhoneExisted 
			
		chỗ này count là được chớ cần gì find chỗ này count là được chớ cần gì find 
			
		count luôn count luôn 
			
		done done  
			
		done done 
			
		done done 
			
		set default rồi, bỏ cái này đi set default rồi, bỏ cái này đi 
			
		done done 
			
		 | 
			||||
		col = s.getUserCollection()
 | 
			
		||||
| 
					
 isPhoneNumberOrPhoneExisted isPhoneNumberOrPhoneExisted 
			
		chỗ này count là được chớ cần gì find chỗ này count là được chớ cần gì find 
			
		count luôn count luôn 
			
		done done  
			
		done done 
			
		done done 
			
		set default rồi, bỏ cái này đi set default rồi, bỏ cái này đi 
			
		done done 
			
		 | 
			||||
	)
 | 
			
		||||
| 
					
 isPhoneNumberOrPhoneExisted isPhoneNumberOrPhoneExisted 
			
		chỗ này count là được chớ cần gì find chỗ này count là được chớ cần gì find 
			
		count luôn count luôn 
			
		done done  
			
		done done 
			
		done done 
			
		set default rồi, bỏ cái này đi set default rồi, bỏ cái này đi 
			
		done done 
			
		 | 
			||||
 | 
			
		||||
| 
					
 isPhoneNumberOrPhoneExisted isPhoneNumberOrPhoneExisted 
			
		chỗ này count là được chớ cần gì find chỗ này count là được chớ cần gì find 
			
		count luôn count luôn 
			
		done done  
			
		done done 
			
		done done 
			
		set default rồi, bỏ cái này đi set default rồi, bỏ cái này đi 
			
		done done 
			
		 | 
			||||
	_, err := col.InsertOne(ctx, doc)
 | 
			
		||||
| 
					
 isPhoneNumberOrPhoneExisted isPhoneNumberOrPhoneExisted 
			
		chỗ này count là được chớ cần gì find chỗ này count là được chớ cần gì find 
			
		count luôn count luôn 
			
		done done  
			
		done done 
			
		done done 
			
		set default rồi, bỏ cái này đi set default rồi, bỏ cái này đi 
			
		done done 
			
		 | 
			||||
	if err != nil {
 | 
			
		||||
| 
					
 isPhoneNumberOrPhoneExisted isPhoneNumberOrPhoneExisted 
			
		chỗ này count là được chớ cần gì find chỗ này count là được chớ cần gì find 
			
		count luôn count luôn 
			
		done done  
			
		done done 
			
		done done 
			
		set default rồi, bỏ cái này đi set default rồi, bỏ cái này đi 
			
		done done 
			
		 | 
			||||
		logger.Error("usermngmt - Create", logger.LogData{
 | 
			
		||||
| 
					
 isPhoneNumberOrPhoneExisted isPhoneNumberOrPhoneExisted 
			
		chỗ này count là được chớ cần gì find chỗ này count là được chớ cần gì find 
			
		count luôn count luôn 
			
		done done  
			
		done done 
			
		done done 
			
		set default rồi, bỏ cái này đi set default rồi, bỏ cái này đi 
			
		done done 
			
		 | 
			||||
			"doc": doc,
 | 
			
		||||
| 
					
 isPhoneNumberOrPhoneExisted isPhoneNumberOrPhoneExisted 
			
		chỗ này count là được chớ cần gì find chỗ này count là được chớ cần gì find 
			
		count luôn count luôn 
			
		done done  
			
		done done 
			
		done done 
			
		set default rồi, bỏ cái này đi set default rồi, bỏ cái này đi 
			
		done done 
			
		 | 
			||||
			"err": err.Error(),
 | 
			
		||||
| 
					
 isPhoneNumberOrPhoneExisted isPhoneNumberOrPhoneExisted 
			
		chỗ này count là được chớ cần gì find chỗ này count là được chớ cần gì find 
			
		count luôn count luôn 
			
		done done  
			
		done done 
			
		done done 
			
		set default rồi, bỏ cái này đi set default rồi, bỏ cái này đi 
			
		done done 
			
		 | 
			||||
		})
 | 
			
		||||
| 
					
 isPhoneNumberOrPhoneExisted isPhoneNumberOrPhoneExisted 
			
		chỗ này count là được chớ cần gì find chỗ này count là được chớ cần gì find 
			
		count luôn count luôn 
			
		done done  
			
		done done 
			
		done done 
			
		set default rồi, bỏ cái này đi set default rồi, bỏ cái này đi 
			
		done done 
			
		 | 
			||||
		return fmt.Errorf("error when create user: %s", err.Error())
 | 
			
		||||
| 
					
 isPhoneNumberOrPhoneExisted isPhoneNumberOrPhoneExisted 
			
		chỗ này count là được chớ cần gì find chỗ này count là được chớ cần gì find 
			
		count luôn count luôn 
			
		done done  
			
		done done 
			
		done done 
			
		set default rồi, bỏ cái này đi set default rồi, bỏ cái này đi 
			
		done done 
			
		 | 
			||||
	}
 | 
			
		||||
| 
					
 isPhoneNumberOrPhoneExisted isPhoneNumberOrPhoneExisted 
			
		chỗ này count là được chớ cần gì find chỗ này count là được chớ cần gì find 
			
		count luôn count luôn 
			
		done done  
			
		done done 
			
		done done 
			
		set default rồi, bỏ cái này đi set default rồi, bỏ cái này đi 
			
		done done 
			
		 | 
			||||
 | 
			
		||||
| 
					
 isPhoneNumberOrPhoneExisted isPhoneNumberOrPhoneExisted 
			
		chỗ này count là được chớ cần gì find chỗ này count là được chớ cần gì find 
			
		count luôn count luôn 
			
		done done  
			
		done done 
			
		done done 
			
		set default rồi, bỏ cái này đi set default rồi, bỏ cái này đi 
			
		done done 
			
		 | 
			||||
	return nil
 | 
			
		||||
| 
					
 isPhoneNumberOrPhoneExisted isPhoneNumberOrPhoneExisted 
			
		chỗ này count là được chớ cần gì find chỗ này count là được chớ cần gì find 
			
		count luôn count luôn 
			
		done done  
			
		done done 
			
		done done 
			
		set default rồi, bỏ cái này đi set default rồi, bỏ cái này đi 
			
		done done 
			
		 | 
			||||
}
 | 
			
		||||
| 
					
 isPhoneNumberOrPhoneExisted isPhoneNumberOrPhoneExisted 
			
		chỗ này count là được chớ cần gì find chỗ này count là được chớ cần gì find 
			
		count luôn count luôn 
			
		done done  
			
		done done 
			
		done done 
			
		set default rồi, bỏ cái này đi set default rồi, bỏ cái này đi 
			
		done done 
			
		 | 
			||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
					
 isPhoneNumberOrPhoneExisted isPhoneNumberOrPhoneExisted 
			
		isPhoneNumberOrPhoneExisted isPhoneNumberOrPhoneExisted 
			
		chỗ này count là được chớ cần gì find chỗ này count là được chớ cần gì find 
			
		chỗ này count là được chớ cần gì find chỗ này count là được chớ cần gì find 
			
		count luôn count luôn 
			
		count luôn count luôn 
			
		done done  
			
		done done  
			
		done done 
			
		done done 
			
		done done 
			
		done done 
			
		set default rồi, bỏ cái này đi set default rồi, bỏ cái này đi 
			
		set default rồi, bỏ cái này đi set default rồi, bỏ cái này đi 
			
		done done 
			
		done done 
			
		 | 
			||||
| 
						 | 
				
			
			@ -35,6 +35,11 @@ func Init(config Config) (*Service, error) {
 | 
			
		|||
| 
					
 TablePrefix không require, nếu không có thì để default là  TablePrefix không require, nếu không có thì để default là `usermngmt` 
			
		TablePrefix không require, nếu không có thì để default là  TablePrefix không require, nếu không có thì để default là `usermngmt` 
			
		done done 
			
		done done 
			
		chỗ này chưa thấy check default bên func get collection không cần check gì nữa chỗ này chưa thấy check default
```go
if config.TablePrefix == "" {
  config.TablePrefix = ... // set trong config, default `usermngmt `
}
```
bên func get collection không cần check gì nữa 
			
		chỗ này chưa thấy check default bên func get collection không cần check gì nữa chỗ này chưa thấy check default
```go
if config.TablePrefix == "" {
  config.TablePrefix = ... // set trong config, default `usermngmt `
}
```
bên func get collection không cần check gì nữa 
			
		done done 
			
		done done 
			
		 | 
			||||
		return nil, errors.New("please provide all necessary information for init user")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// If prefixTable is empty then it is usermngmt
 | 
			
		||||
| 
					
 TablePrefix không require, nếu không có thì để default là  TablePrefix không require, nếu không có thì để default là `usermngmt` 
			
		done done 
			
		chỗ này chưa thấy check default bên func get collection không cần check gì nữa chỗ này chưa thấy check default
```go
if config.TablePrefix == "" {
  config.TablePrefix = ... // set trong config, default `usermngmt `
}
```
bên func get collection không cần check gì nữa 
			
		done done 
			
		 | 
			||||
	if config.TablePrefix == "" {
 | 
			
		||||
| 
					
 TablePrefix không require, nếu không có thì để default là  TablePrefix không require, nếu không có thì để default là `usermngmt` 
			
		done done 
			
		chỗ này chưa thấy check default bên func get collection không cần check gì nữa chỗ này chưa thấy check default
```go
if config.TablePrefix == "" {
  config.TablePrefix = ... // set trong config, default `usermngmt `
}
```
bên func get collection không cần check gì nữa 
			
		done done 
			
		 | 
			||||
		config.TablePrefix = tablePrefixDefault
 | 
			
		||||
| 
					
 TablePrefix không require, nếu không có thì để default là  TablePrefix không require, nếu không có thì để default là `usermngmt` 
			
		done done 
			
		chỗ này chưa thấy check default bên func get collection không cần check gì nữa chỗ này chưa thấy check default
```go
if config.TablePrefix == "" {
  config.TablePrefix = ... // set trong config, default `usermngmt `
}
```
bên func get collection không cần check gì nữa 
			
		done done 
			
		 | 
			||||
	}
 | 
			
		||||
| 
					
 TablePrefix không require, nếu không có thì để default là  TablePrefix không require, nếu không có thì để default là `usermngmt` 
			
		done done 
			
		chỗ này chưa thấy check default bên func get collection không cần check gì nữa chỗ này chưa thấy check default
```go
if config.TablePrefix == "" {
  config.TablePrefix = ... // set trong config, default `usermngmt `
}
```
bên func get collection không cần check gì nữa 
			
		done done 
			
		 | 
			||||
 | 
			
		||||
| 
					
 TablePrefix không require, nếu không có thì để default là  TablePrefix không require, nếu không có thì để default là `usermngmt` 
			
		done done 
			
		chỗ này chưa thấy check default bên func get collection không cần check gì nữa chỗ này chưa thấy check default
```go
if config.TablePrefix == "" {
  config.TablePrefix = ... // set trong config, default `usermngmt `
}
```
bên func get collection không cần check gì nữa 
			
		done done 
			
		 | 
			||||
	// Connect MongoDB
 | 
			
		||||
	db, err := mongodb.Connect(
 | 
			
		||||
		config.MongoDB.Host,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
					
 TablePrefix không require, nếu không có thì để default là  TablePrefix không require, nếu không có thì để default là `usermngmt` 
			
		TablePrefix không require, nếu không có thì để default là  TablePrefix không require, nếu không có thì để default là `usermngmt` 
			
		done done 
			
		done done 
			
		chỗ này chưa thấy check default bên func get collection không cần check gì nữa chỗ này chưa thấy check default
```go
if config.TablePrefix == "" {
  config.TablePrefix = ... // set trong config, default `usermngmt `
}
```
bên func get collection không cần check gì nữa 
			
		chỗ này chưa thấy check default bên func get collection không cần check gì nữa chỗ này chưa thấy check default
```go
if config.TablePrefix == "" {
  config.TablePrefix = ... // set trong config, default `usermngmt `
}
```
bên func get collection không cần check gì nữa 
			
		done done 
			
		done done 
			
		 | 
			||||
							
								
								
									
										13
									
								
								validate.go
								
								
								
								
							
							
						
						| 
						 | 
				
			
			@ -5,6 +5,7 @@ import (
 | 
			
		|||
| 
					
 check plain password check plain password 
			
		check plain password check plain password 
			
		done done 
			
		done done 
			
		 | 
			||||
	"errors"
 | 
			
		||||
 | 
			
		||||
	"github.com/Selly-Modules/logger"
 | 
			
		||||
	"github.com/Selly-Modules/mongodb"
 | 
			
		||||
| 
					
 check plain password check plain password 
			
		done done 
			
		 | 
			||||
)
 | 
			
		||||
 | 
			
		||||
func (co CreateOptions) validate(ctx context.Context) error {
 | 
			
		||||
| 
						 | 
				
			
			@ -49,15 +50,19 @@ func (co CreateOptions) validate(ctx context.Context) error {
 | 
			
		|||
| 
					
 check plain password check plain password 
			
		check plain password check plain password 
			
		done done 
			
		done done 
			
		 | 
			||||
	}
 | 
			
		||||
 | 
			
		||||
	// RoleID
 | 
			
		||||
	if co.RoleID.IsZero() {
 | 
			
		||||
| 
					
 check plain password check plain password 
			
		done done 
			
		 | 
			||||
		logger.Error("usermngmt - Create: invalid roleID data", logger.LogData{
 | 
			
		||||
| 
					
 check plain password check plain password 
			
		done done 
			
		 | 
			||||
	if co.RoleID == "" {
 | 
			
		||||
| 
					
 check plain password check plain password 
			
		done done 
			
		 | 
			||||
		logger.Error("usermngmt - Create: no roleID data", logger.LogData{
 | 
			
		||||
| 
					
 check plain password check plain password 
			
		done done 
			
		 | 
			||||
			"payload": co,
 | 
			
		||||
		})
 | 
			
		||||
		return errors.New("invalid roleID data")
 | 
			
		||||
| 
					
 check plain password check plain password 
			
		done done 
			
		 | 
			||||
		return errors.New("no role id data")
 | 
			
		||||
| 
					
 check plain password check plain password 
			
		done done 
			
		 | 
			||||
	}
 | 
			
		||||
 | 
			
		||||
	//  Find roleID exists or not
 | 
			
		||||
	if !s.isRoleIDExisted(ctx, co.RoleID) {
 | 
			
		||||
| 
					
 check plain password check plain password 
			
		done done 
			
		 | 
			||||
	roleID, isValid := mongodb.NewIDFromString(co.RoleID)
 | 
			
		||||
| 
					
 check plain password check plain password 
			
		done done 
			
		 | 
			||||
	if !isValid {
 | 
			
		||||
| 
					
 check plain password check plain password 
			
		done done 
			
		 | 
			||||
		return errors.New("invalid role id data")
 | 
			
		||||
| 
					
 check plain password check plain password 
			
		done done 
			
		 | 
			||||
	}
 | 
			
		||||
| 
					
 check plain password check plain password 
			
		done done 
			
		 | 
			||||
	if !s.isRoleIDExisted(ctx, roleID) {
 | 
			
		||||
| 
					
 check plain password check plain password 
			
		done done 
			
		 | 
			||||
		return errors.New("role id does not exist")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
					
 check plain password check plain password 
			
		check plain password check plain password 
			
		done done 
			
		done done 
			
		 | 
			||||
boolean thì:
ishastrên sửa lại
isNameOrPhoneExistedboolean thì:
ishastrên sửa lại
isNameOrPhoneExistedhave name or phone existed -> phone number or email already existed
have name or phone existed -> phone number or email already existed
thiếu check roleId trong db
thiếu check roleId trong db
done
done
done
done
done
done
password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword
password client truyền vào là plain text, module này mới convert qua hash, đặt là hashedPassword
isRoleIDAlreadyExisted -> isRoleIDExisted
isRoleIDAlreadyExisted -> isRoleIDExisted
roleID does not exist -> role id does not exist
lỗi là ngữ cảnh cho user đọc, nên viết clear tí
roleID does not exist -> role id does not exist
lỗi là ngữ cảnh cho user đọc, nên viết clear tí
func này với func isRoleIDExisted nên đưa vô func
payload.validate(), gom tất cả validate trước khi xử lý về 1 chỗfunc này với func isRoleIDExisted nên đưa vô func
payload.validate(), gom tất cả validate trước khi xử lý về 1 chỗbỏ dấu space sau Create
bỏ dấu space sau Create
password do module này hash, xem link này:
https://gowebexamples.com/password-hashing/
password do module này hash, xem link này:
https://gowebexamples.com/password-hashing/
done
done
done
done
done
done
done
done
done
done
done
done
đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file
đoạn này move qua db.go luôn, phân tách ra để gọn hàm, và đúng file
nên là
string, nếu client không dùng mongodb thì phải cài thêm thư việnnote: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được
nên là
string, nếu client không dùng mongodb thì phải cài thêm thư việnnote: xử lý làm sao chỉ dùng type của go và của module, client chỉ cần cài 1 module này là sử dụng được
done
done
done
done