diff --git a/internal/bossraid/handler.go b/internal/bossraid/handler.go index 31a4ac6..02d1cf3 100644 --- a/internal/bossraid/handler.go +++ b/internal/bossraid/handler.go @@ -168,103 +168,6 @@ func (h *Handler) FailRaid(c *fiber.Ctx) error { }) } -// RequestEntryAuth godoc -// @Summary 보스 레이드 입장 요청 -// @Description 게임 클라이언트에서 보스 레이드 입장을 요청합니다. 인증된 유저가 입장 목록에 포함되어야 합니다. -// @Tags Boss Raid -// @Accept json -// @Produce json -// @Security BearerAuth -// @Param body body docs.RequestEntryAuthRequest true "입장 정보" -// @Success 201 {object} docs.RequestEntryResponse -// @Failure 400 {object} docs.ErrorResponse -// @Failure 401 {object} docs.ErrorResponse -// @Failure 403 {object} docs.ErrorResponse -// @Failure 409 {object} docs.ErrorResponse -// @Router /api/bossraid/entry [post] -func (h *Handler) RequestEntryAuth(c *fiber.Ctx) error { - var req struct { - Usernames []string `json:"usernames"` - BossID int `json:"bossId"` - } - if err := c.BodyParser(&req); err != nil { - return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{"error": "잘못된 요청입니다"}) - } - - // 인증된 유저의 username - authUsername, _ := c.Locals("username").(string) - if authUsername == "" { - return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{"error": "인증 정보가 없습니다"}) - } - - // 빈 usernames이면 솔로 입장 — 본인만 포함 - if len(req.Usernames) == 0 { - req.Usernames = []string{authUsername} - } - if req.BossID <= 0 { - return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{"error": "bossId는 필수입니다"}) - } - - // 인증된 유저가 요청 목록에 포함되어 있는지 검증 - found := false - for _, u := range req.Usernames { - if u == authUsername { - found = true - break - } - } - if !found { - return c.Status(fiber.StatusForbidden).JSON(fiber.Map{"error": "본인이 입장 목록에 포함되어야 합니다"}) - } - - for _, u := range req.Usernames { - if len(u) == 0 || len(u) > 50 { - return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{"error": "유효하지 않은 username입니다"}) - } - } - - room, tokens, err := h.svc.RequestEntryWithTokens(req.Usernames, req.BossID) - if err != nil { - return bossError(c, fiber.StatusConflict, "보스 레이드 입장에 실패했습니다", err) - } - - return c.Status(fiber.StatusCreated).JSON(fiber.Map{ - "roomId": room.ID, - "sessionName": room.SessionName, - "bossId": room.BossID, - "players": req.Usernames, - "status": room.Status, - "entryToken": tokens[authUsername], - }) -} - -// GetMyEntryToken godoc -// @Summary 내 입장 토큰 조회 -// @Description 현재 유저의 대기 중인 입장 토큰을 조회합니다 -// @Tags Boss Raid -// @Produce json -// @Security BearerAuth -// @Success 200 {object} docs.MyEntryTokenResponse -// @Failure 401 {object} docs.ErrorResponse -// @Failure 404 {object} docs.ErrorResponse -// @Router /api/bossraid/my-entry-token [get] -func (h *Handler) GetMyEntryToken(c *fiber.Ctx) error { - username, _ := c.Locals("username").(string) - if username == "" { - return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{"error": "인증 정보가 없습니다"}) - } - - sessionName, entryToken, err := h.svc.GetMyEntryToken(username) - if err != nil { - return c.Status(fiber.StatusNotFound).JSON(fiber.Map{"error": err.Error()}) - } - - return c.JSON(fiber.Map{ - "sessionName": sessionName, - "entryToken": entryToken, - }) -} - // ValidateEntryToken godoc // @Summary 입장 토큰 검증 (내부 API) // @Description 데디케이티드 서버에서 플레이어의 입장 토큰을 검증합니다. 일회성 소모. diff --git a/routes/routes.go b/routes/routes.go index 3b5973f..9af9493 100644 --- a/routes/routes.go +++ b/routes/routes.go @@ -131,11 +131,6 @@ func Register( chainAdmin.Post("/reward", middleware.IdempotencyRequired, chainH.GrantReward) chainAdmin.Post("/template", middleware.IdempotencyRequired, chainH.RegisterTemplate) - // Boss Raid - Client entry (JWT authenticated) - bossRaid := api.Group("/bossraid", middleware.Auth) - bossRaid.Post("/entry", brH.RequestEntryAuth) - bossRaid.Get("/my-entry-token", brH.GetMyEntryToken) - // Player Profile (authenticated) p := api.Group("/player", middleware.Auth) p.Get("/profile", playerH.GetProfile)