package Wx

import (
	"net/http"

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

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

// swagger:route post /wx/refreshLoginQR Wx RefreshLoginQR
//
// Refresh login QR code | 刷新登陆二维码
//
// Refresh login QR code | 刷新登陆二维码
//
// Parameters:
//  + name: body
//    require: true
//    in: body
//    type: RefreshLoginQRReq
//
// Responses:
//  200: RefreshLoginQRResp

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

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