diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-02-21 10:29:21 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-02-21 10:29:21 +0900 |
| commit | e8db174d3e464a5764a9f4bfd82172261bd50519 (patch) | |
| tree | 68cb8f0713fcc1f960a650d879232cb4c20ca6cd /backend/gen/api | |
| parent | 1be106ac53caa019a8912af932a43570fa8c052d (diff) | |
| download | phperkaigi-2026-albatross-e8db174d3e464a5764a9f4bfd82172261bd50519.tar.gz phperkaigi-2026-albatross-e8db174d3e464a5764a9f4bfd82172261bd50519.tar.zst phperkaigi-2026-albatross-e8db174d3e464a5764a9f4bfd82172261bd50519.zip | |
refactor(api): separate business logic into game, tournament, session packages
Extract business logic from api/handler.go into dedicated service packages:
- session: context helpers (resolves admin → api import dependency)
- game: game state, code submission, ranking, watch logic
- tournament: bracket construction and seed ordering
- api/convert.go: domain → API type conversion functions
api/handler.go is now a thin adapter that delegates to services and
maps domain errors to HTTP status codes.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'backend/gen/api')
| -rw-r--r-- | backend/gen/api/handler_wrapper_gen.go | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/backend/gen/api/handler_wrapper_gen.go b/backend/gen/api/handler_wrapper_gen.go index 88f55c6..ef2baa1 100644 --- a/backend/gen/api/handler_wrapper_gen.go +++ b/backend/gen/api/handler_wrapper_gen.go @@ -117,6 +117,9 @@ import ( "albatross-2026-backend/config" "albatross-2026-backend/db" + "albatross-2026-backend/game" + "albatross-2026-backend/session" + "albatross-2026-backend/tournament" ) var _ StrictServerInterface = (*HandlerWrapper)(nil) @@ -125,14 +128,14 @@ type HandlerWrapper struct { impl Handler } -func NewHandler(queries db.Querier, txm db.TxManager, hub GameHubInterface, auth AuthenticatorInterface, conf *config.Config) *HandlerWrapper { +func NewHandler(gameSvc *game.Service, tournamentSvc *tournament.Service, auth AuthenticatorInterface, queries db.Querier, conf *config.Config) *HandlerWrapper { return &HandlerWrapper{ impl: Handler{ - q: queries, - txm: txm, - hub: hub, - auth: auth, - conf: conf, + gameSvc: gameSvc, + tournamentSvc: tournamentSvc, + auth: auth, + conf: conf, + q: queries, }, } } @@ -140,7 +143,7 @@ func NewHandler(queries db.Querier, txm db.TxManager, hub GameHubInterface, auth {{ range . }} func (h *HandlerWrapper) {{ .Name }}(ctx context.Context, request {{ .Name }}RequestObject) ({{ .Name }}ResponseObject, error) { {{ if .RequiresLogin -}} - user, ok := GetUserFromContext(ctx) + user, ok := session.GetUserFromContext(ctx) if !ok { return {{ .Name }}401JSONResponse{ Message: "Unauthorized", @@ -155,7 +158,7 @@ func NewHandler(queries db.Querier, txm db.TxManager, hub GameHubInterface, auth {{ end -}} return h.impl.{{ .Name }}(ctx, request, user) {{ else if .LoginOptional -}} - user, _ := GetUserFromContext(ctx) + user, _ := session.GetUserFromContext(ctx) return h.impl.{{ .Name }}(ctx, request, user) {{ else -}} return h.impl.{{ .Name }}(ctx, request) |
