81 lines
2.4 KiB
Go
81 lines
2.4 KiB
Go
package mappers
|
|
|
|
import (
|
|
"apskel-pos-be/internal/contract"
|
|
"apskel-pos-be/internal/models"
|
|
)
|
|
|
|
// SpinGameRequestContractToModel converts spin game request from contract to model
|
|
func SpinGameRequestContractToModel(req *contract.SpinGameRequest) *models.SpinGameRequest {
|
|
if req == nil {
|
|
return nil
|
|
}
|
|
|
|
return &models.SpinGameRequest{
|
|
SpinID: req.SpinID,
|
|
}
|
|
}
|
|
|
|
// SpinGameResponseModelToContract converts spin game response from model to contract
|
|
func SpinGameResponseModelToContract(resp *models.SpinGameResponse) *contract.SpinGameResponse {
|
|
if resp == nil {
|
|
return nil
|
|
}
|
|
|
|
return &contract.SpinGameResponse{
|
|
Status: resp.Status,
|
|
Message: resp.Message,
|
|
Data: SpinGameResponseDataModelToContract(resp.Data),
|
|
}
|
|
}
|
|
|
|
// SpinGameResponseDataModelToContract converts spin game response data from model to contract
|
|
func SpinGameResponseDataModelToContract(data *models.SpinGameResponseData) *contract.SpinGameResponseData {
|
|
if data == nil {
|
|
return nil
|
|
}
|
|
|
|
return &contract.SpinGameResponseData{
|
|
GamePlay: GamePlayResponseModelToContract(&data.GamePlay),
|
|
PrizeWon: CustomerGamePrizeResponseModelToContract(data.PrizeWon),
|
|
TokensRemaining: data.TokensRemaining,
|
|
}
|
|
}
|
|
|
|
// GamePlayResponseModelToContract converts game play response from model to contract
|
|
func GamePlayResponseModelToContract(resp *models.GamePlayResponse) contract.GamePlayResponse {
|
|
if resp == nil {
|
|
return contract.GamePlayResponse{}
|
|
}
|
|
|
|
return contract.GamePlayResponse{
|
|
ID: resp.ID,
|
|
GameID: resp.GameID,
|
|
CustomerID: resp.CustomerID,
|
|
PrizeID: resp.PrizeID,
|
|
TokenUsed: resp.TokenUsed,
|
|
RandomSeed: resp.RandomSeed,
|
|
CreatedAt: resp.CreatedAt,
|
|
Game: nil, // Optional field - can be populated separately if needed
|
|
Customer: nil, // Optional field - can be populated separately if needed
|
|
Prize: nil, // Optional field - can be populated separately if needed
|
|
}
|
|
}
|
|
|
|
// CustomerGamePrizeResponseModelToContract converts customer game prize response from model to contract
|
|
func CustomerGamePrizeResponseModelToContract(resp *models.CustomerGamePrizeResponse) *contract.CustomerGamePrizeResponse {
|
|
if resp == nil {
|
|
return nil
|
|
}
|
|
|
|
return &contract.CustomerGamePrizeResponse{
|
|
ID: resp.ID,
|
|
GameID: resp.GameID,
|
|
Name: resp.Name,
|
|
Image: resp.Image,
|
|
Metadata: resp.Metadata,
|
|
CreatedAt: resp.CreatedAt,
|
|
UpdatedAt: resp.UpdatedAt,
|
|
}
|
|
}
|