package vehiclehist

import (
	"net/http"

	e "simrs-vx/internal/domain/main-entities/vehicle-hist"
	u "simrs-vx/internal/use-case/main-use-case/vehicle-hist"

	rw "github.com/karincake/risoles"
	sf "github.com/karincake/semprit"
)

type myBase struct{}

var O myBase

func (obj myBase) Create(w http.ResponseWriter, r *http.Request) {}

func (obj myBase) GetList(w http.ResponseWriter, r *http.Request) {
	dto := e.ReadListDto{}
	sf.UrlQueryParam(&dto, *r.URL)
	res, err := u.ReadList(dto)
	rw.DataResponse(w, res, err)
}

func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) {
	id := rw.ValidateInt(w, "id", r.PathValue("id"))
	if id <= 0 {
		return
	}

	dto := e.ReadDetailDto{}
	sf.UrlQueryParam(&dto, *r.URL)

	dto.Id = uint16(id)
	res, err := u.ReadDetail(dto)
	rw.DataResponse(w, res, err)
}

func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {}

func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {}
