feat: Swagger API 문서 추가 + 보스레이드/플레이어 레벨 시스템
- swaggo/swag 기반 전체 API 엔드포인트 Swagger 어노테이션 (59개) - /swagger/ 경로에 Swagger UI 제공 - 보스레이드 데디서버 관리 (등록, 하트비트, 슬롯 리셋) - 플레이어 레벨/경험치 시스템 및 스탯 성장 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -16,7 +16,16 @@ func NewHandler(svc *Service) *Handler {
|
||||
return &Handler{svc: svc}
|
||||
}
|
||||
|
||||
// GetProfile 자신의 프로필 조회 (JWT 인증)
|
||||
// GetProfile godoc
|
||||
// @Summary 내 프로필 조회
|
||||
// @Description 현재 유저의 플레이어 프로필을 조회합니다
|
||||
// @Tags Player
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Success 200 {object} docs.PlayerProfileResponse
|
||||
// @Failure 401 {object} docs.ErrorResponse
|
||||
// @Failure 404 {object} docs.ErrorResponse
|
||||
// @Router /api/player/profile [get]
|
||||
func (h *Handler) GetProfile(c *fiber.Ctx) error {
|
||||
userID, ok := c.Locals("userID").(uint)
|
||||
if !ok {
|
||||
@@ -28,10 +37,22 @@ func (h *Handler) GetProfile(c *fiber.Ctx) error {
|
||||
return c.Status(fiber.StatusNotFound).JSON(fiber.Map{"error": err.Error()})
|
||||
}
|
||||
|
||||
return c.JSON(profile)
|
||||
return c.JSON(profileWithNextExp(profile))
|
||||
}
|
||||
|
||||
// UpdateProfile 자신의 프로필 수정 (JWT 인증)
|
||||
// UpdateProfile godoc
|
||||
// @Summary 프로필 수정
|
||||
// @Description 현재 유저의 닉네임을 수정합니다
|
||||
// @Tags Player
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param body body docs.UpdateProfileRequest true "수정할 프로필"
|
||||
// @Success 200 {object} player.PlayerProfile
|
||||
// @Failure 400 {object} docs.ErrorResponse
|
||||
// @Failure 401 {object} docs.ErrorResponse
|
||||
// @Failure 500 {object} docs.ErrorResponse
|
||||
// @Router /api/player/profile [put]
|
||||
func (h *Handler) UpdateProfile(c *fiber.Ctx) error {
|
||||
userID, ok := c.Locals("userID").(uint)
|
||||
if !ok {
|
||||
@@ -67,7 +88,17 @@ func (h *Handler) UpdateProfile(c *fiber.Ctx) error {
|
||||
return c.JSON(profile)
|
||||
}
|
||||
|
||||
// InternalGetProfile 내부 API: username 쿼리 파라미터로 프로필 조회
|
||||
// InternalGetProfile godoc
|
||||
// @Summary 프로필 조회 (내부 API)
|
||||
// @Description username으로 플레이어 프로필을 조회합니다 (게임 서버용)
|
||||
// @Tags Internal - Player
|
||||
// @Produce json
|
||||
// @Security ApiKeyAuth
|
||||
// @Param username query string true "유저명"
|
||||
// @Success 200 {object} docs.PlayerProfileResponse
|
||||
// @Failure 400 {object} docs.ErrorResponse
|
||||
// @Failure 404 {object} docs.ErrorResponse
|
||||
// @Router /api/internal/player/profile [get]
|
||||
func (h *Handler) InternalGetProfile(c *fiber.Ctx) error {
|
||||
username := c.Query("username")
|
||||
if username == "" {
|
||||
@@ -79,10 +110,50 @@ func (h *Handler) InternalGetProfile(c *fiber.Ctx) error {
|
||||
return c.Status(fiber.StatusNotFound).JSON(fiber.Map{"error": err.Error()})
|
||||
}
|
||||
|
||||
return c.JSON(profile)
|
||||
return c.JSON(profileWithNextExp(profile))
|
||||
}
|
||||
|
||||
// InternalSaveGameData 내부 API: username 쿼리 파라미터로 게임 데이터 저장
|
||||
// profileWithNextExp wraps a PlayerProfile with nextExp for JSON response.
|
||||
func profileWithNextExp(p *PlayerProfile) fiber.Map {
|
||||
nextExp := 0
|
||||
if p.Level < MaxLevel {
|
||||
nextExp = RequiredExp(p.Level)
|
||||
}
|
||||
return fiber.Map{
|
||||
"id": p.ID,
|
||||
"createdAt": p.CreatedAt,
|
||||
"updatedAt": p.UpdatedAt,
|
||||
"userId": p.UserID,
|
||||
"nickname": p.Nickname,
|
||||
"level": p.Level,
|
||||
"experience": p.Experience,
|
||||
"nextExp": nextExp,
|
||||
"maxHp": p.MaxHP,
|
||||
"maxMp": p.MaxMP,
|
||||
"attackPower": p.AttackPower,
|
||||
"attackRange": p.AttackRange,
|
||||
"sprintMultiplier": p.SprintMultiplier,
|
||||
"lastPosX": p.LastPosX,
|
||||
"lastPosY": p.LastPosY,
|
||||
"lastPosZ": p.LastPosZ,
|
||||
"lastRotY": p.LastRotY,
|
||||
"totalPlayTime": p.TotalPlayTime,
|
||||
}
|
||||
}
|
||||
|
||||
// InternalSaveGameData godoc
|
||||
// @Summary 게임 데이터 저장 (내부 API)
|
||||
// @Description username으로 게임 데이터를 저장합니다 (게임 서버용)
|
||||
// @Tags Internal - Player
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security ApiKeyAuth
|
||||
// @Param username query string true "유저명"
|
||||
// @Param body body docs.GameDataRequest true "게임 데이터"
|
||||
// @Success 200 {object} docs.MessageResponse
|
||||
// @Failure 400 {object} docs.ErrorResponse
|
||||
// @Failure 500 {object} docs.ErrorResponse
|
||||
// @Router /api/internal/player/save [post]
|
||||
func (h *Handler) InternalSaveGameData(c *fiber.Ctx) error {
|
||||
username := c.Query("username")
|
||||
if username == "" {
|
||||
|
||||
Reference in New Issue
Block a user