package credit_balance

import (
	"net/http"

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

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

// swagger:route post /credit_balance/list credit_balance GetCreditBalanceList
//
// Get credit balance list | 获取CreditBalance列表
//
// Get credit balance list | 获取CreditBalance列表
//
// Parameters:
//  + name: body
//    require: true
//    in: body
//    type: CreditBalanceListReq
//
// Responses:
//  200: CreditBalanceListResp

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

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