package message_records

import (
	"net/http"

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

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

// swagger:route post /message_records/list message_records GetMessageRecordsList
//
// Get message records list | 获取MessageRecords列表
//
// Get message records list | 获取MessageRecords列表
//
// Parameters:
//  + name: body
//    require: true
//    in: body
//    type: MessageRecordsListReq
//
// Responses:
//  200: MessageRecordsListResp

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

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