syntax = "v1"

info (
	title:   "Console API"
	desc:    "API for ppanel"
	author:  "Tension"
	email:   "tension@ppanel.com"
	version: "0.0.1"
)

type (
	ServerTrafficData {
		ServerId int64  `json:"server_id"`
		Name     string `json:"name"`
		Upload   int64  `json:"upload"`
		Download int64  `json:"download"`
	}
	UserTrafficData {
		SID      int64 `json:"sid"`
		Upload   int64 `json:"upload"`
		Download int64 `json:"download"`
	}
	ServerTotalDataResponse {
		OnlineUserIPs                 int64               `json:"online_user_ips"`
		OnlineServers                 int64               `json:"online_servers"`
		OfflineServers                int64               `json:"offline_servers"`
		TodayUpload                   int64               `json:"today_upload"`
		TodayDownload                 int64               `json:"today_download"`
		MonthlyUpload                 int64               `json:"monthly_upload"`
		MonthlyDownload               int64               `json:"monthly_download"`
		UpdatedAt                     int64               `json:"updated_at"`
		ServerTrafficRankingToday     []ServerTrafficData `json:"server_traffic_ranking_today"`
		ServerTrafficRankingYesterday []ServerTrafficData `json:"server_traffic_ranking_yesterday"`
		UserTrafficRankingToday       []UserTrafficData   `json:"user_traffic_ranking_today"`
		UserTrafficRankingYesterday   []UserTrafficData   `json:"user_traffic_ranking_yesterday"`
	}
	UserStatistics {
		Date              string           `json:"date,omitempty"`
		Register          int64            `json:"register"`
		NewOrderUsers     int64            `json:"new_order_users"`
		RenewalOrderUsers int64            `json:"renewal_order_users"`
		List              []UserStatistics `json:"list,omitempty"`
	}
	OrdersStatistics {
		Date               string             `json:"date,omitempty"`
		AmountTotal        int64              `json:"amount_total"`
		NewOrderAmount     int64              `json:"new_order_amount"`
		RenewalOrderAmount int64              `json:"renewal_order_amount"`
		List               []OrdersStatistics `json:"list,omitempty"`
	}
	RevenueStatisticsResponse {
		Today   OrdersStatistics `json:"today"`
		Monthly OrdersStatistics `json:"monthly"`
		All     OrdersStatistics `json:"all"`
	}
	UserStatisticsResponse {
		Today   UserStatistics `json:"today"`
		Monthly UserStatistics `json:"monthly"`
		All     UserStatistics `json:"all"`
	}
	TicketWaitRelpyResponse {
		Count int64 `json:"count"`
	}
)

@server (
	prefix:     v1/admin/console
	group:      admin/console
	middleware: AuthMiddleware
)
service ppanel {
	@doc "Query server total data"
	@handler QueryServerTotalData
	get /server returns (ServerTotalDataResponse)

	@doc "Query revenue statistics"
	@handler QueryRevenueStatistics
	get /revenue returns (RevenueStatisticsResponse)

	@doc "Query user statistics"
	@handler QueryUserStatistics
	get /user returns (UserStatisticsResponse)

	@doc "Query ticket wait reply"
	@handler QueryTicketWaitReply
	get /ticket returns (TicketWaitRelpyResponse)
}

