package acquirer_student

import (
	"git.i2edu.net/i2/i2-bill-api/internal/logic/acquirer_student"
	"net/http"

	"git.i2edu.net/i2/i2-bill-api/internal/svc"
	"git.i2edu.net/i2/i2-bill-api/internal/types"

	"git.i2edu.net/i2/go-zero/rest/httpx"
)

func AcquirerStudentAddHandler(ctx *svc.ServiceContext) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		var req types.EnrollAddReq
		if err := httpx.Parse(r, &req); err != nil {
			httpx.Error(w, err)
			return
		}

		l := acquirer_student.NewAcquirerStudentAddLogic(r.Context(), ctx)
		resp, err := l.AcquirerStudentAdd(req)
		if err != nil {
			httpx.Error(w, err)
		} else {
			httpx.OkJson(w, resp)
		}
	}
}
