country.go 742 Bytes
Newer Older
kzkzzzz's avatar
kzkzzzz committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
package handler

import (
	"context"
	"hilo/api/service/country"
	"hilo/app/service/country/internal/service"
)

// CountryHandler is a country handler.
type CountryHandler struct {
	country.UnimplementedCountryServer
	svc *service.CountryService
}

func (h *CountryHandler) GetCountryByShortName(ctx context.Context, req *country.GetCountryByShortNameReq) (*country.GetCountryByShortNameRep, error) {
	m, err := h.svc.GetCountryByShortName(ctx, req.ShortName)
	if err != nil {
		return nil, err
	}
	return CountryModelToShortNameRep(m), nil
}

// NewCountryHandler new a country handler.
func NewCountryHandler(uc *service.CountryService) *CountryHandler {
	return &CountryHandler{svc: uc}
}

var _ country.CountryServer = &CountryHandler{}