package agent_base

import (
	"net/http"

	"github.com/zeromicro/go-zero/rest/httpx"

	"wechat-api/internal/logic/agent_base"
	"wechat-api/internal/svc"
	"wechat-api/internal/types"
)

// swagger:route post /agent_base/list agent_base GetAgentBaseList
//
// Get agent base list | 获取AgentBase列表
//
// Get agent base list | 获取AgentBase列表
//
// Parameters:
//  + name: body
//    require: true
//    in: body
//    type: DataListReq
//
// Responses:
//  200: DataListResp

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

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