package contact_field_template

import (
	"net/http"

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

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

// swagger:route post /contact_field_template/create contact_field_template CreateContactFieldTemplate
//
// Create contact_field_template information | 创建 ContactFieldTemplate
//
// Create contact_field_template information | 创建 ContactFieldTemplate
//
// Parameters:
//  + name: body
//    require: true
//    in: body
//    type: ContactFieldTemplateInfo
//
// Responses:
//  200: BaseMsgResp

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

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