syntax = "v1"

info (
	title:   "聚玩打手服务"
	desc:    "聚玩用户服务处理打手信息管理、服务发布及订单相关接口。ID 字段（int64）以 string 传输"
	author:  "Asadz"
	version: "1.0"
)

import "common.api"

type (
	PlayerService {
		Id           int64    `json:"id,string,optional"`
		PlayerId     int64    `json:"playerId,string"`
		GameId       int64    `json:"gameId,string"`
		GameName     string   `json:"gameName"`
		Title        string   `json:"title"`
		Description  string   `json:"description"`
		Price        float64  `json:"price"`
		Unit         string   `json:"unit"`
		RankRange    string   `json:"rankRange,optional"`
		Availability []string `json:"availability"`
	}
	PlayerServiceListResp {
		Items []PlayerService `json:"items"`
		Meta  PageMeta        `json:"meta"`
	}
	CreateServiceReq {
		GameId       int64    `json:"gameId,string,optional"`
		Title        string   `json:"title,optional"`
		Description  string   `json:"description,optional"`
		Price        float64  `json:"price"`
		Unit         string   `json:"unit"`
		RankRange    string   `json:"rankRange,optional"`
		Availability []string `json:"availability,optional"`
	}
	UpdateServiceReq {
		Id           int64    `path:"id"`
		GameId       *int64   `json:"gameId,string,optional"`
		Title        *string  `json:"title,optional"`
		Description  *string  `json:"description,optional"`
		Price        *float64 `json:"price,optional"`
		Unit         *string  `json:"unit,optional"`
		RankRange    *string  `json:"rankRange,optional"`
		Availability []string `json:"availability"`
	}
	PlayerProfile {
		Id             int64           `json:"id,string"`
		User           UserProfile     `json:"user"`
		Rating         float64         `json:"rating"`
		TotalOrders    int64           `json:"totalOrders"`
		CompletionRate float64         `json:"completionRate"`
		Status         string          `json:"status"`
		Games          []string        `json:"games"`
		Services       []PlayerService `json:"services"`
		ShopId         string          `json:"shopId,optional"`
		ShopName       string          `json:"shopName,optional"`
		Gender         bool            `json:"gender"`
		Tags           []string        `json:"tags"`
	}
	PlayerListReq {
		PageReq
		GameId int64 `form:"gameId,optional"`
		Gender int64 `form:"gender,optional"`
	}
	PlayerListResp {
		Items []PlayerProfile `json:"items"`
		Meta  PageMeta        `json:"meta"`
	}
	UpdatePlayerStatusReq {
		Status string `json:"status"`
	}
)

type (
	GetServiceReq {
		Id int64 `path:"id"`
	}
	GetPlayerReq {
		Id int64 `path:"id"`
	}
	ListPlayerServicesReq {
		PageReq
		Id int64 `path:"id"`
	}
)

@server (
	prefix: api/v1
	group:  player
)
service player-api {
	@doc "获取打手列表"
	@handler ListPlayers
	get /players (PlayerListReq) returns (PlayerListResp)

	@doc "获取打手详情"
	@handler GetPlayer
	get /players/:id (GetPlayerReq) returns (PlayerProfile)

	@doc "获取所有服务列表"
	@handler ListServices
	get /services (PageReq) returns (PlayerServiceListResp)

	@doc "获取服务详情"
	@handler GetService
	get /services/:id (GetServiceReq) returns (PlayerService)

	@doc "获取指定打手的服务列表"
	@handler ListPlayerServices
	get /players/:id/services (ListPlayerServicesReq) returns (PlayerServiceListResp)
}

type (
	DeleteServiceReq {
		Id int64 `path:"id"`
	}
)

@server (
	prefix: api/v1
	group:  player
)
service player-api {
	@doc "初始化当前用户的打手资料"
	@handler InitPlayer
	post /players/me (EmptyResp) returns (PlayerProfile)

	@doc "获取当前用户的打手资料"
	@handler GetMyPlayer
	get /players/me (EmptyResp) returns (PlayerProfile)

	@doc "更新接单状态"
	@handler UpdatePlayerStatus
	put /players/me/status (UpdatePlayerStatusReq) returns (EmptyResp)

	@doc "创建服务"
	@handler CreateService
	post /services (CreateServiceReq) returns (PlayerService)

	@doc "更新服务"
	@handler UpdateService
	put /services/:id (UpdateServiceReq) returns (PlayerService)

	@doc "删除服务"
	@handler DeleteService
	delete /services/:id (DeleteServiceReq) returns (EmptyResp)
}

