package admin_agent

import (
	"net/http"

	"github.com/zeromicro/go-zero/rest/httpx"
	"sim-server/app/main/api/internal/logic/admin_agent"
	"sim-server/app/main/api/internal/svc"
	"sim-server/app/main/api/internal/types"
)

func AdminGetAgentRankingHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		var req types.AdminGetAgentRankingReq
		if err := httpx.Parse(r, &req); err != nil {
			httpx.ErrorCtx(r.Context(), w, err)
			return
		}

		l := admin_agent.NewAdminGetAgentRankingLogic(r.Context(), svcCtx)
		resp, err := l.AdminGetAgentRanking(&req)
		if err != nil {
			httpx.ErrorCtx(r.Context(), w, err)
		} else {
			httpx.OkJsonCtx(r.Context(), w, resp)
		}
	}
}
