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

84 lines
2.6 KiB
Go

package entity
import (
"enaklo-pos-be/internal/constants"
"golang.org/x/crypto/bcrypt"
"time"
)
type MemberRegistrationRequest struct {
Name string `json:"name" validate:"required"`
Email string `json:"email" validate:"required,email"`
Phone string `json:"phone" validate:"required"`
BirthDate time.Time `json:"birth_date"`
BranchID int64 `json:"branch_id" validate:"required"`
CashierID int64 `json:"cashier_id" validate:"required"`
Password string `json:"password"`
}
func (m *MemberRegistrationRequest) GetHashPassword() string {
hashedPassword, err := bcrypt.GenerateFromPassword([]byte(m.Password), bcrypt.DefaultCost)
if err != nil {
return ""
}
return string(hashedPassword)
}
type MemberRegistrationResponse struct {
Token string `json:"token"`
Status string `json:"status"`
ExpiresAt time.Time `json:"expires_at"`
Message string `json:"message"`
}
type MemberRegistration struct {
ID string `json:"id"`
Token string `json:"token"`
Name string `json:"name"`
Email string `json:"email"`
Phone string `json:"phone"`
BirthDate time.Time `json:"birth_date"`
OTP string `json:"-"` // Not exposed in JSON responses
Status constants.RegistrationStatus `json:"status"`
ExpiresAt time.Time `json:"expires_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
BranchID int64 `json:"branch_id"`
CashierID int64 `json:"cashier_id"`
Password string `json:"password"`
}
type MemberVerificationRequest struct {
Token string `json:"token" validate:"required"`
OTP string `json:"otp" validate:"required"`
}
type MemberVerificationResponse struct {
Auth *AuthenticateUser
CustomerID int64 `json:"customer_id"`
Name string `json:"name"`
Email string `json:"email"`
Phone string `json:"phone"`
Points int `json:"points"`
Status string `json:"status"`
}
type MemberRegistrationStatus struct {
Token string `json:"token"`
Status string `json:"status"`
ExpiresAt time.Time `json:"expires_at"`
IsExpired bool `json:"is_expired"`
CreatedAt time.Time `json:"created_at"`
}
type ResendOTPRequest struct {
Token string `json:"token" validate:"required"`
}
type ResendOTPResponse struct {
Token string `json:"token"`
ExpiresAt time.Time `json:"expires_at"`
Message string `json:"message"`
}