Update Member
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package response
|
||||
|
||||
import (
|
||||
"enaklo-pos-be/internal/entity"
|
||||
)
|
||||
|
||||
func MapToCustomerResponse(customer *entity.Customer) CustomerResponse {
|
||||
if customer == nil {
|
||||
return CustomerResponse{}
|
||||
}
|
||||
|
||||
return CustomerResponse{
|
||||
ID: customer.ID,
|
||||
Name: customer.Name,
|
||||
Email: customer.Email,
|
||||
Phone: customer.Phone,
|
||||
Points: customer.Points,
|
||||
CustomerID: customer.CustomerID,
|
||||
CreatedAt: customer.CreatedAt.Format("2006-01-02"),
|
||||
BirthDate: customer.BirthDate.Format("2006-01-02"),
|
||||
}
|
||||
}
|
||||
|
||||
func MapToCustomerListResponse(customers *entity.MemberList) []CustomerResponse {
|
||||
if customers == nil {
|
||||
return []CustomerResponse{}
|
||||
}
|
||||
|
||||
responseList := []CustomerResponse{}
|
||||
for _, customer := range *customers {
|
||||
responseList = append(responseList, MapToCustomerResponse(customer))
|
||||
}
|
||||
|
||||
return responseList
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package response
|
||||
|
||||
import (
|
||||
"enaklo-pos-be/internal/entity"
|
||||
"time"
|
||||
)
|
||||
|
||||
type MemberRegistrationResponse struct {
|
||||
Token string `json:"token"`
|
||||
Status string `json:"status"`
|
||||
ExpiresAt time.Time `json:"expires_at"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
type MemberVerificationResponse struct {
|
||||
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 ResendOTPResponse struct {
|
||||
Token string `json:"token"`
|
||||
ExpiresAt time.Time `json:"expires_at"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
type CustomerCheckResponse struct {
|
||||
Exists bool `json:"exists"`
|
||||
Customer *CustomerResponse `json:"customer,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
type CustomerResponse struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Email string `json:"email"`
|
||||
Phone string `json:"phone"`
|
||||
BirthDate string `json:"birth_date,omitempty"`
|
||||
Points int `json:"points"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
CustomerID string `json:"customer_id"`
|
||||
}
|
||||
|
||||
func MapToMemberRegistrationResponse(entity *entity.MemberRegistrationResponse) MemberRegistrationResponse {
|
||||
return MemberRegistrationResponse{
|
||||
Token: entity.Token,
|
||||
Status: entity.Status,
|
||||
ExpiresAt: entity.ExpiresAt,
|
||||
Message: entity.Message,
|
||||
}
|
||||
}
|
||||
|
||||
func MapToMemberVerificationResponse(entity *entity.MemberVerificationResponse) MemberVerificationResponse {
|
||||
return MemberVerificationResponse{
|
||||
CustomerID: entity.CustomerID,
|
||||
Name: entity.Name,
|
||||
Email: entity.Email,
|
||||
Phone: entity.Phone,
|
||||
Points: entity.Points,
|
||||
Status: entity.Status,
|
||||
}
|
||||
}
|
||||
|
||||
func MapToMemberRegistrationStatus(entity *entity.MemberRegistrationStatus) MemberRegistrationStatus {
|
||||
return MemberRegistrationStatus{
|
||||
Token: entity.Token,
|
||||
Status: entity.Status,
|
||||
ExpiresAt: entity.ExpiresAt,
|
||||
IsExpired: entity.IsExpired,
|
||||
CreatedAt: entity.CreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func MapToResendOTPResponse(entity *entity.ResendOTPResponse) ResendOTPResponse {
|
||||
return ResendOTPResponse{
|
||||
Token: entity.Token,
|
||||
ExpiresAt: entity.ExpiresAt,
|
||||
Message: entity.Message,
|
||||
}
|
||||
}
|
||||
|
||||
func MapToCustomerCheckResponse(entity *entity.CustomerCheckResponse) CustomerCheckResponse {
|
||||
response := CustomerCheckResponse{
|
||||
Exists: entity.Exists,
|
||||
Message: entity.Message,
|
||||
}
|
||||
|
||||
if entity.Customer != nil {
|
||||
customer := &CustomerResponse{
|
||||
ID: entity.Customer.ID,
|
||||
Name: entity.Customer.Name,
|
||||
Email: entity.Customer.Email,
|
||||
Phone: entity.Customer.Phone,
|
||||
CreatedAt: entity.Customer.CreatedAt.Format("2006-01-02"),
|
||||
}
|
||||
response.Customer = customer
|
||||
}
|
||||
|
||||
return response
|
||||
}
|
||||
Reference in New Issue
Block a user