package ChatRoomMember

import (
	"net/http"

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

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

// swagger:route post /chatroom_member/list ChatRoomMember GetChatroomMemberList
//
// Get chatroom member list | 获取ChatroomMember列表
//
// Get chatroom member list | 获取ChatroomMember列表
//
// Parameters:
//  + name: body
//    require: true
//    in: body
//    type: ChatroomMemberListReq
//
// Responses:
//  200: ChatroomMemberListResp

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

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