Yimaru-BackEnd/internal/services/user/direct.go
2025-04-10 14:59:31 +03:00

54 lines
1.2 KiB
Go

package user
import (
"context"
"github.com/SamuelTariku/FortuneBet-Backend/internal/domain"
)
func (s *Service) CreateUser(ctx context.Context, User domain.CreateUserReq) (domain.User, error) {
// Create User
// creator, err := s.userStore.GetUserByID(ctx, createrUserId)
// if err != nil {
// return domain.User{}, err
// }
// if creator.Role != domain.RoleAdmin {
// User.BranchID = creator.BranchID
// User.Role = string(domain.RoleCashier)
// } else {
// User.BranchID = branchId
// User.Role = string(domain.RoleBranchManager)
// }
return s.userStore.CreateUserWithoutOtp(ctx, User)
}
func (s *Service) DeleteUser(ctx context.Context, id int64) error {
// Delete User
return s.userStore.DeleteUser(ctx, id)
}
type Filter struct {
Role string
BranchId ValidBranchId
Page int
PageSize int
}
type ValidRole struct {
Value domain.Role
Valid bool
}
type ValidBranchId struct {
Value int64
Valid bool
}
func (s *Service) GetAllUsers(ctx context.Context, filter Filter) ([]domain.User, error) {
// Get all Users
return s.userStore.GetAllUsers(ctx, filter)
}
func (s *Service) GetUserById(ctx context.Context, id int64) (domain.User, error) {
return s.userStore.GetUserByID(ctx, id)
}