package User

import (
	"net/http"

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

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

// swagger:route post /gpts/user/login User DoGptsUserLogin
//
// Get user basic information | 获取用户基本信息
//
// Get user basic information | 获取用户基本信息
//
// Parameters:
//  + name: body
//    require: true
//    in: body
//    type: GptsUserLoginReq
//
// Responses:
//  200: GptsUserLoginResp

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

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