feat(enakgame): spin as an EnakGame game; remove the old game flow
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>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
296708244e
commit
18e87398bb
@@ -19,29 +19,6 @@ type GamificationService interface {
|
||||
DeleteTier(ctx context.Context, id uuid.UUID) error
|
||||
GetTierByPoints(ctx context.Context, points int64) (*contract.TierResponse, error)
|
||||
|
||||
// Games
|
||||
CreateGame(ctx context.Context, req *contract.CreateGameRequest) (*contract.GameResponse, error)
|
||||
GetGame(ctx context.Context, id uuid.UUID) (*contract.GameResponse, error)
|
||||
ListGames(ctx context.Context, query *contract.ListGamesRequest) (*contract.PaginatedGamesResponse, error)
|
||||
UpdateGame(ctx context.Context, id uuid.UUID, req *contract.UpdateGameRequest) (*contract.GameResponse, error)
|
||||
DeleteGame(ctx context.Context, id uuid.UUID) error
|
||||
GetActiveGames(ctx context.Context) ([]contract.GameResponse, error)
|
||||
|
||||
// Game Prizes
|
||||
CreateGamePrize(ctx context.Context, req *contract.CreateGamePrizeRequest) (*contract.GamePrizeResponse, error)
|
||||
GetGamePrize(ctx context.Context, id uuid.UUID) (*contract.GamePrizeResponse, error)
|
||||
GetGamePrizesByGameID(ctx context.Context, gameID uuid.UUID) ([]contract.GamePrizeResponse, error)
|
||||
ListGamePrizes(ctx context.Context, query *contract.ListGamePrizesRequest) (*contract.PaginatedGamePrizesResponse, error)
|
||||
UpdateGamePrize(ctx context.Context, id uuid.UUID, req *contract.UpdateGamePrizeRequest) (*contract.GamePrizeResponse, error)
|
||||
DeleteGamePrize(ctx context.Context, id uuid.UUID) error
|
||||
GetAvailablePrizes(ctx context.Context, gameID uuid.UUID) ([]contract.GamePrizeResponse, error)
|
||||
|
||||
// Game Plays
|
||||
CreateGamePlay(ctx context.Context, req *contract.CreateGamePlayRequest) (*contract.GamePlayResponse, error)
|
||||
GetGamePlay(ctx context.Context, id uuid.UUID) (*contract.GamePlayResponse, error)
|
||||
ListGamePlays(ctx context.Context, query *contract.ListGamePlaysRequest) (*contract.PaginatedGamePlaysResponse, error)
|
||||
PlayGame(ctx context.Context, req *contract.PlayGameRequest) (*contract.PlayGameResponse, error)
|
||||
|
||||
// Omset Tracker
|
||||
CreateOmsetTracker(ctx context.Context, req *contract.CreateOmsetTrackerRequest) (*contract.OmsetTrackerResponse, error)
|
||||
GetOmsetTracker(ctx context.Context, id uuid.UUID) (*contract.OmsetTrackerResponse, error)
|
||||
@@ -53,24 +30,15 @@ type GamificationService interface {
|
||||
|
||||
type GamificationServiceImpl struct {
|
||||
tierProcessor *processor.TierProcessor
|
||||
gameProcessor *processor.GameProcessor
|
||||
gamePrizeProcessor *processor.GamePrizeProcessor
|
||||
gamePlayProcessor *processor.GamePlayProcessor
|
||||
omsetTrackerProcessor *processor.OmsetTrackerProcessor
|
||||
}
|
||||
|
||||
func NewGamificationService(
|
||||
tierProcessor *processor.TierProcessor,
|
||||
gameProcessor *processor.GameProcessor,
|
||||
gamePrizeProcessor *processor.GamePrizeProcessor,
|
||||
gamePlayProcessor *processor.GamePlayProcessor,
|
||||
omsetTrackerProcessor *processor.OmsetTrackerProcessor,
|
||||
) *GamificationServiceImpl {
|
||||
return &GamificationServiceImpl{
|
||||
tierProcessor: tierProcessor,
|
||||
gameProcessor: gameProcessor,
|
||||
gamePrizeProcessor: gamePrizeProcessor,
|
||||
gamePlayProcessor: gamePlayProcessor,
|
||||
omsetTrackerProcessor: omsetTrackerProcessor,
|
||||
}
|
||||
}
|
||||
@@ -123,146 +91,6 @@ func (s *GamificationServiceImpl) GetTierByPoints(ctx context.Context, points in
|
||||
return transformer.TierModelToResponse(response), nil
|
||||
}
|
||||
|
||||
// Game Service Methods
|
||||
func (s *GamificationServiceImpl) CreateGame(ctx context.Context, req *contract.CreateGameRequest) (*contract.GameResponse, error) {
|
||||
modelReq := transformer.CreateGameRequestToModel(req)
|
||||
response, err := s.gameProcessor.CreateGame(ctx, modelReq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return transformer.GameModelToResponse(response), nil
|
||||
}
|
||||
|
||||
func (s *GamificationServiceImpl) GetGame(ctx context.Context, id uuid.UUID) (*contract.GameResponse, error) {
|
||||
response, err := s.gameProcessor.GetGame(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return transformer.GameModelToResponse(response), nil
|
||||
}
|
||||
|
||||
func (s *GamificationServiceImpl) ListGames(ctx context.Context, query *contract.ListGamesRequest) (*contract.PaginatedGamesResponse, error) {
|
||||
modelQuery := transformer.ListGamesRequestToModel(query)
|
||||
response, err := s.gameProcessor.ListGames(ctx, modelQuery)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return transformer.PaginatedGamesResponseToContract(response), nil
|
||||
}
|
||||
|
||||
func (s *GamificationServiceImpl) UpdateGame(ctx context.Context, id uuid.UUID, req *contract.UpdateGameRequest) (*contract.GameResponse, error) {
|
||||
modelReq := transformer.UpdateGameRequestToModel(req)
|
||||
response, err := s.gameProcessor.UpdateGame(ctx, id, modelReq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return transformer.GameModelToResponse(response), nil
|
||||
}
|
||||
|
||||
func (s *GamificationServiceImpl) DeleteGame(ctx context.Context, id uuid.UUID) error {
|
||||
return s.gameProcessor.DeleteGame(ctx, id)
|
||||
}
|
||||
|
||||
func (s *GamificationServiceImpl) GetActiveGames(ctx context.Context) ([]contract.GameResponse, error) {
|
||||
response, err := s.gameProcessor.GetActiveGames(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return transformer.GameModelsToResponses(response), nil
|
||||
}
|
||||
|
||||
// Game Prize Service Methods
|
||||
func (s *GamificationServiceImpl) CreateGamePrize(ctx context.Context, req *contract.CreateGamePrizeRequest) (*contract.GamePrizeResponse, error) {
|
||||
modelReq := transformer.CreateGamePrizeRequestToModel(req)
|
||||
response, err := s.gamePrizeProcessor.CreateGamePrize(ctx, modelReq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return transformer.GamePrizeModelToResponse(response), nil
|
||||
}
|
||||
|
||||
func (s *GamificationServiceImpl) GetGamePrize(ctx context.Context, id uuid.UUID) (*contract.GamePrizeResponse, error) {
|
||||
response, err := s.gamePrizeProcessor.GetGamePrize(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return transformer.GamePrizeModelToResponse(response), nil
|
||||
}
|
||||
|
||||
func (s *GamificationServiceImpl) GetGamePrizesByGameID(ctx context.Context, gameID uuid.UUID) ([]contract.GamePrizeResponse, error) {
|
||||
response, err := s.gamePrizeProcessor.GetGamePrizesByGameID(ctx, gameID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return transformer.GamePrizeModelsToResponses(response), nil
|
||||
}
|
||||
|
||||
func (s *GamificationServiceImpl) ListGamePrizes(ctx context.Context, query *contract.ListGamePrizesRequest) (*contract.PaginatedGamePrizesResponse, error) {
|
||||
modelQuery := transformer.ListGamePrizesRequestToModel(query)
|
||||
response, err := s.gamePrizeProcessor.ListGamePrizes(ctx, modelQuery)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return transformer.PaginatedGamePrizesResponseToContract(response), nil
|
||||
}
|
||||
|
||||
func (s *GamificationServiceImpl) UpdateGamePrize(ctx context.Context, id uuid.UUID, req *contract.UpdateGamePrizeRequest) (*contract.GamePrizeResponse, error) {
|
||||
modelReq := transformer.UpdateGamePrizeRequestToModel(req)
|
||||
response, err := s.gamePrizeProcessor.UpdateGamePrize(ctx, id, modelReq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return transformer.GamePrizeModelToResponse(response), nil
|
||||
}
|
||||
|
||||
func (s *GamificationServiceImpl) DeleteGamePrize(ctx context.Context, id uuid.UUID) error {
|
||||
return s.gamePrizeProcessor.DeleteGamePrize(ctx, id)
|
||||
}
|
||||
|
||||
func (s *GamificationServiceImpl) GetAvailablePrizes(ctx context.Context, gameID uuid.UUID) ([]contract.GamePrizeResponse, error) {
|
||||
response, err := s.gamePrizeProcessor.GetAvailablePrizes(ctx, gameID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return transformer.GamePrizeModelsToResponses(response), nil
|
||||
}
|
||||
|
||||
// Game Play Service Methods
|
||||
func (s *GamificationServiceImpl) CreateGamePlay(ctx context.Context, req *contract.CreateGamePlayRequest) (*contract.GamePlayResponse, error) {
|
||||
modelReq := transformer.CreateGamePlayRequestToModel(req)
|
||||
response, err := s.gamePlayProcessor.CreateGamePlay(ctx, modelReq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return transformer.GamePlayModelToResponse(response), nil
|
||||
}
|
||||
|
||||
func (s *GamificationServiceImpl) GetGamePlay(ctx context.Context, id uuid.UUID) (*contract.GamePlayResponse, error) {
|
||||
response, err := s.gamePlayProcessor.GetGamePlay(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return transformer.GamePlayModelToResponse(response), nil
|
||||
}
|
||||
|
||||
func (s *GamificationServiceImpl) ListGamePlays(ctx context.Context, query *contract.ListGamePlaysRequest) (*contract.PaginatedGamePlaysResponse, error) {
|
||||
modelQuery := transformer.ListGamePlaysRequestToModel(query)
|
||||
response, err := s.gamePlayProcessor.ListGamePlays(ctx, modelQuery)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return transformer.PaginatedGamePlaysResponseToContract(response), nil
|
||||
}
|
||||
|
||||
func (s *GamificationServiceImpl) PlayGame(ctx context.Context, req *contract.PlayGameRequest) (*contract.PlayGameResponse, error) {
|
||||
modelReq := transformer.PlayGameRequestToModel(req)
|
||||
response, err := s.gamePlayProcessor.PlayGame(ctx, modelReq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return transformer.PlayGameModelToResponse(response), nil
|
||||
}
|
||||
|
||||
// Omset Tracker Service Methods
|
||||
func (s *GamificationServiceImpl) CreateOmsetTracker(ctx context.Context, req *contract.CreateOmsetTrackerRequest) (*contract.OmsetTrackerResponse, error) {
|
||||
modelReq := transformer.CreateOmsetTrackerRequestToModel(req)
|
||||
|
||||
Reference in New Issue
Block a user