2025-05-03 10:50:41 +07:00

59 lines
2.0 KiB
Go

package member
import (
"context"
"enaklo-pos-be/internal/common/mycontext"
"enaklo-pos-be/internal/constants"
"enaklo-pos-be/internal/entity"
"time"
)
type RegistrationService interface {
InitiateRegistration(ctx mycontext.Context, request *entity.MemberRegistrationRequest) (*entity.MemberRegistrationResponse, error)
VerifyOTP(ctx mycontext.Context, token string, otp string) (*entity.MemberVerificationResponse, error)
GetRegistrationStatus(ctx mycontext.Context, token string) (*entity.MemberRegistrationStatus, error)
ResendOTP(ctx mycontext.Context, token string) (*entity.ResendOTPResponse, error)
}
type CryptoSvc interface {
GenerateJWTCustomer(user *entity.Customer) (string, error)
}
type memberSvc struct {
repo Repository
notification NotificationService
customerSvc CustomerService
crypt CryptoSvc
}
type Repository interface {
CreateRegistration(ctx mycontext.Context, registration *entity.MemberRegistration) (*entity.MemberRegistration, error)
GetRegistrationByToken(ctx mycontext.Context, token string) (*entity.MemberRegistration, error)
UpdateRegistrationStatus(ctx mycontext.Context, token string, status constants.RegistrationStatus) error
UpdateRegistrationOTP(ctx mycontext.Context, token string, otp string, expiresAt time.Time) error
}
type NotificationService interface {
SendEmailTransactional(ctx context.Context, param entity.SendEmailNotificationParam) error
}
type CustomerService interface {
ResolveCustomer(ctx mycontext.Context, req *entity.CustomerResolutionRequest) (int64, error)
GetCustomer(ctx mycontext.Context, id int64) (*entity.Customer, error)
CustomerCheck(ctx mycontext.Context, req *entity.CustomerResolutionRequest) (*entity.CustomerCheckResponse, error)
}
func NewMemberRegistrationService(
repo Repository,
notification NotificationService,
customerSvc CustomerService,
crypt CryptoSvc,
) RegistrationService {
return &memberSvc{
repo: repo,
notification: notification,
customerSvc: customerSvc,
crypt: crypt,
}
}