package mkt_part_time_user

import (
	"git.i2edu.net/i2/i2-bill-api/internal/logic/mkt_part_time_user"
	"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 MktPartTimeUserUpdateHandler(ctx *svc.ServiceContext) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		var req types.PartTimeUserAddRequest
		if err := httpx.Parse(r, &req); err != nil {
			httpx.Error(w, err)
			return
		}

		l := mkt_part_time_user.NewPartTimeUserUpdateLogic(r.Context(), ctx)
		resp, err := l.PartTimeUserUpdate(req)
		if err != nil {
			httpx.Error(w, err)
		} else {
			httpx.OkJson(w, resp)
		}
	}
}
