59 lines
2.0 KiB
Go
Raw Normal View History

2025-03-15 15:51:18 +08:00
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)
}
2025-05-03 10:50:41 +07:00
type CryptoSvc interface {
GenerateJWTCustomer(user *entity.Customer) (string, error)
}
2025-03-15 15:51:18 +08:00
type memberSvc struct {
repo Repository
notification NotificationService
customerSvc CustomerService
2025-05-03 10:50:41 +07:00
crypt CryptoSvc
2025-03-15 15:51:18 +08:00
}
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,
2025-05-03 10:50:41 +07:00
crypt CryptoSvc,
2025-03-15 15:51:18 +08:00
) RegistrationService {
return &memberSvc{
repo: repo,
notification: notification,
customerSvc: customerSvc,
2025-05-03 10:50:41 +07:00
crypt: crypt,
2025-03-15 15:51:18 +08:00
}
}