package controllers_join

import (
	"encoding/json"
	"kkscrap-go/locals"
	models_join "kkscrap-go/models/join"
	"net/http"

	"github.com/dabory/abango-rest"
	"github.com/labstack/echo"
)

type ListType1InsertReq struct {
	InsertVars locals.InsertVars
}

func ListType1Insert(c echo.Context) error {

	v := c.Get("receiver").(ListType1InsertReq)
	y := c.Get("abango").(abango.Controller)

	var vRet models_join.ListTypeInsertRet

	var cnt int
	var err error

	vRet.InsertVars = v.InsertVars

	if cnt, err = vRet.Lt1Insert(&y); err != nil {
		return c.String(607, err.Error())
	}

	vRet.InsertCnt = cnt

	ret, _ := json.Marshal(vRet)
	return c.JSONBlob(http.StatusOK, ret)
}
