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/update agent_base UpdateAgentBase
//
// Update agent base information | 更新AgentBase
//
// Update agent base information | 更新AgentBase
//
// Parameters:
//  + name: body
//    require: true
//    in: body
//    type: UpdateDataInfoReq
//
// Responses:
//  200: BaseDataInfo

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

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