96 lines
2.5 KiB
Go
96 lines
2.5 KiB
Go
package user
|
|
|
|
import (
|
|
"Yimaru-Backend/internal/domain"
|
|
"context"
|
|
"strconv"
|
|
)
|
|
|
|
func (s *Service) GetUserByEmailPhone(
|
|
ctx context.Context,
|
|
email string,
|
|
phone string,
|
|
) (domain.User, error) {
|
|
return s.userStore.GetUserByEmailPhone(ctx, email, phone)
|
|
}
|
|
|
|
func (s *Service) IsUserPending(ctx context.Context, userID int64) (bool, error) {
|
|
return s.userStore.IsUserPending(ctx, userID)
|
|
}
|
|
|
|
func (s *Service) IsProfileCompleted(ctx context.Context, userId int64) (bool, error) {
|
|
return s.userStore.IsProfileCompleted(ctx, userId)
|
|
}
|
|
|
|
// func (s *Service) IsUserNameUnique(ctx context.Context, userID int64) (bool, error) {
|
|
// return s.userStore.IsUserNameUnique(ctx, userID)
|
|
// }
|
|
|
|
// func (s *Service) GetUserByUserName(
|
|
// ctx context.Context,
|
|
// userName string,
|
|
// ) (domain.User, error) {
|
|
// return s.userStore.GetUserByUserName(ctx, userName)
|
|
// }
|
|
|
|
func (s *Service) SearchUserByNameOrPhone(ctx context.Context, searchString string, role *int64) ([]domain.User, error) {
|
|
// Search user
|
|
var roleStr *string
|
|
if role != nil {
|
|
tmp := strconv.FormatInt(*role, 10)
|
|
roleStr = &tmp
|
|
}
|
|
return s.userStore.SearchUserByNameOrPhone(ctx, searchString, roleStr)
|
|
|
|
}
|
|
|
|
func (s *Service) UpdateUser(ctx context.Context, req domain.UpdateUserReq) error {
|
|
// Update user in the store
|
|
return s.userStore.UpdateUser(ctx, req)
|
|
}
|
|
|
|
// func (s *Service) UpdateUserSuspend(ctx context.Context, id int64, status bool) error {
|
|
// // update user
|
|
// return s.userStore.UpdateUserSuspend(ctx, id, status)
|
|
// }
|
|
func (s *Service) GetUserByID(ctx context.Context, id int64) (domain.User, error) {
|
|
return s.userStore.GetUserByID(ctx, id)
|
|
}
|
|
|
|
// GetAllUsers retrieves users based on the provided filter
|
|
// func (s *Service) GetAllUsers(ctx context.Context, filter domain.UserFilter) ([]domain.User, int64, error) {
|
|
// var role *string
|
|
// if filter.Role != "" {
|
|
// role = &filter.Role
|
|
// }
|
|
|
|
// var query *string
|
|
// if filter.Query.Valid {
|
|
// q := filter.Query
|
|
// query = &q
|
|
// }
|
|
|
|
// var createdBefore *time.Time
|
|
// if filter.CreatedBefore.Valid {
|
|
// b := filter.CreatedBefore
|
|
// createdBefore = &b
|
|
// }
|
|
|
|
// var createdAfter *time.Time
|
|
// if filter.CreatedAfter.Valid {
|
|
// a := filter.CreatedAfter
|
|
// createdAfter = &a
|
|
// }
|
|
|
|
// var limit int32 = 10
|
|
// var offset int32 = 0
|
|
// if filter.PageSize.Valid {
|
|
// limit = int32(filter.PageSize)
|
|
// }
|
|
// if filter.Page.Valid && filter.PageSize.Valid {
|
|
// offset = int32(filter.Page * filter.PageSize)
|
|
// }
|
|
|
|
// return s.userStore.GetAllUsers(ctx, role, query, createdBefore, createdAfter, limit, offset)
|
|
// }
|