EnakGame phase 10 of docs/tasks-enakgame.md (EG-1001 to EG-1003). Spin (EG-1001) - PROBABILITY entries take an optional label (a wheel segment). The customer game list shows a PROBABILITY game's prizes (entry, label, amount, never weights), and completing returns the drawn prize, so the client can draw the wheel and stop it on the server's draw. - docs/enakgame-spin.md: the admin steps to set up spin per organization (no seeder) and the customer app flow. An HTTP test plays it end to end. Old game flow removed (EG-1002) - Routes POST /customer/spin, GET /customer/games, GET /customer/ferris-wheel, and admin /marketing/games, /marketing/game-prizes, /marketing/rewards, with their handlers, services, processors, repositories, validators, models, contracts, mappers and tests (GamePlayProcessor, SpinGameService, rewards, ...). This also closes RFC ยง15 findings 1 and 2 (double charge, spinning another org's game). - Tables games, game_prizes, game_plays and rewards stay for ledger history. entities.StringSlice moves to its own file; the omset tracker (unrouted) keeps game_id but no longer embeds the old game response. games.is_active dropped (EG-1003) - Migration 000115; nothing reads metadata.coin_cost any more. The EnakPoint integration docs now point at /customer/enakgame. The Postgres tests were not run: no test database here. Migration 000115 has not been run anywhere. The customer app must stop calling the removed endpoints before this is deployed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
64 lines
2.0 KiB
Go
64 lines
2.0 KiB
Go
package mappers
|
|
|
|
import (
|
|
"apskel-pos-be/internal/entities"
|
|
"apskel-pos-be/internal/models"
|
|
)
|
|
|
|
// ToOmsetTrackerResponse converts an omset tracker entity to an omset tracker response
|
|
func ToOmsetTrackerResponse(omsetTracker *entities.OmsetTracker) *models.OmsetTrackerResponse {
|
|
if omsetTracker == nil {
|
|
return nil
|
|
}
|
|
|
|
return &models.OmsetTrackerResponse{
|
|
ID: omsetTracker.ID,
|
|
PeriodType: string(omsetTracker.PeriodType),
|
|
PeriodStart: omsetTracker.PeriodStart,
|
|
PeriodEnd: omsetTracker.PeriodEnd,
|
|
Total: omsetTracker.Total,
|
|
GameID: omsetTracker.GameID,
|
|
CreatedAt: omsetTracker.CreatedAt,
|
|
UpdatedAt: omsetTracker.UpdatedAt,
|
|
}
|
|
}
|
|
|
|
// ToOmsetTrackerResponses converts a slice of omset tracker entities to omset tracker responses
|
|
func ToOmsetTrackerResponses(omsetTrackers []entities.OmsetTracker) []models.OmsetTrackerResponse {
|
|
responses := make([]models.OmsetTrackerResponse, len(omsetTrackers))
|
|
for i, ot := range omsetTrackers {
|
|
responses[i] = *ToOmsetTrackerResponse(&ot)
|
|
}
|
|
return responses
|
|
}
|
|
|
|
// ToOmsetTrackerEntity converts a create omset tracker request to an omset tracker entity
|
|
func ToOmsetTrackerEntity(req *models.CreateOmsetTrackerRequest) *entities.OmsetTracker {
|
|
return &entities.OmsetTracker{
|
|
PeriodType: entities.PeriodType(req.PeriodType),
|
|
PeriodStart: req.PeriodStart,
|
|
PeriodEnd: req.PeriodEnd,
|
|
Total: req.Total,
|
|
GameID: req.GameID,
|
|
}
|
|
}
|
|
|
|
// UpdateOmsetTrackerEntity updates an omset tracker entity with update request data
|
|
func UpdateOmsetTrackerEntity(omsetTracker *entities.OmsetTracker, req *models.UpdateOmsetTrackerRequest) {
|
|
if req.PeriodType != nil {
|
|
omsetTracker.PeriodType = entities.PeriodType(*req.PeriodType)
|
|
}
|
|
if req.PeriodStart != nil {
|
|
omsetTracker.PeriodStart = *req.PeriodStart
|
|
}
|
|
if req.PeriodEnd != nil {
|
|
omsetTracker.PeriodEnd = *req.PeriodEnd
|
|
}
|
|
if req.Total != nil {
|
|
omsetTracker.Total = *req.Total
|
|
}
|
|
if req.GameID != nil {
|
|
omsetTracker.GameID = req.GameID
|
|
}
|
|
}
|