Documentation ¶
Index ¶
- Variables
- func NewDB() *dbutil.DB
- func NewHTTP(svc Service, auth model.Auth, eg *echo.Group)
- type Country
- func (s *Country) Create(ctx context.Context, authUsr *model.AuthUser, data CreationData) (*model.Country, error)
- func (s *Country) Delete(ctx context.Context, authUsr *model.AuthUser, id int) error
- func (s *Country) List(ctx context.Context, authUsr *model.AuthUser, lq *dbutil.ListQueryCondition, ...) ([]*model.Country, error)
- func (s *Country) Update(ctx context.Context, authUsr *model.AuthUser, id int, data UpdateData) (*model.Country, error)
- func (s *Country) View(ctx context.Context, authUsr *model.AuthUser, id int) (*model.Country, error)
- type CreationData
- type HTTP
- type ListResp
- type Service
- type UpdateData
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrCountryNotFound = server.NewHTTPError(http.StatusBadRequest, "COUNTRY_NOTFOUND", "Country not found") ErrCountryNameExisted = server.NewHTTPValidationError("Country name already exists") )
Custom errors
Functions ¶
Types ¶
type Country ¶
type Country struct {
// contains filtered or unexported fields
}
Country represents country application service
func (*Country) Create ¶
func (s *Country) Create(ctx context.Context, authUsr *model.AuthUser, data CreationData) (*model.Country, error)
Create creates a new country
func (*Country) List ¶
func (s *Country) List(ctx context.Context, authUsr *model.AuthUser, lq *dbutil.ListQueryCondition, count *int64) ([]*model.Country, error)
List returns list of countrys
type CreationData ¶
type CreationData struct { // example: Vietnam Name string `json:"name" validate:"required,min=3"` // example: vn Code string `json:"code" validate:"required,min=2,max=10"` // example: +84 PhoneCode string `json:"phone_code" validate:"required,min=2,max=10"` }
CreationData contains country data from json request
type HTTP ¶
type HTTP struct {
// contains filtered or unexported fields
}
HTTP represents country http service
type ListResp ¶
type ListResp struct { // example: [{"id": 1, "created_at": "2020-01-14T10:03:41Z", "updated_at": "2020-01-14T10:03:41Z", "name": "Singapore", "code": "SG", "phone_code": "+65"}] Data []*model.Country `json:"data"` // example: 1 TotalCount int64 `json:"total_count"` }
ListResp contains list of paginated countries and total numbers of countries
type Service ¶
type Service interface { Create(context.Context, *model.AuthUser, CreationData) (*model.Country, error) View(context.Context, *model.AuthUser, int) (*model.Country, error) List(context.Context, *model.AuthUser, *dbutil.ListQueryCondition, *int64) ([]*model.Country, error) Update(context.Context, *model.AuthUser, int, UpdateData) (*model.Country, error) Delete(context.Context, *model.AuthUser, int) error }
Service represents country application interface
type UpdateData ¶
type UpdateData struct { // example: Vietnam Name *string `json:"name,omitempty" validate:"omitempty,min=3"` // example: vn Code *string `json:"code,omitempty" validate:"omitempty,min=2,max=10"` // example: +84 PhoneCode *string `json:"phone_code,omitempty" validate:"omitempty,min=2,max=10"` }
UpdateData contains country data from json request
Click to show internal directories.
Click to hide internal directories.