Documentation ¶
Index ¶
Constants ¶
View Source
const ( Persian CatRace = "Persian" MaineCoon CatRace = "Maine Coon" Siamese CatRace = "Siamese" Ragdoll CatRace = "Ragdoll" Bengal CatRace = "Bengal" Sphynx CatRace = "Sphynx" BritishShorthair CatRace = "British Shorthair" Abyssinian CatRace = "Abyssinian" ScottishFold CatRace = "Scottish Fold" Birman CatRace = "Birman" Male CatSex = "male" Female CatSex = "female" )
Variables ¶
View Source
var ( CatRacesInterface []interface{} = []interface{}{Persian, MaineCoon, Siamese, Ragdoll, Bengal, Sphynx, BritishShorthair, Abyssinian, ScottishFold, Birman} CatSexesInterface []interface{} = []interface{}{Male, Female} CatRaces []CatRace = []CatRace{Persian, MaineCoon, Siamese, Ragdoll, Bengal, Sphynx, BritishShorthair, Abyssinian, ScottishFold, Birman} CatSexes []CatSex = []CatSex{Male, Female} )
View Source
var ( ErrCatNotFound = errors.New("cat not found") ErrCatHasMatched = errors.New("cat has matched befor") ErrValidationFailed = errors.New("validation failed") )
View Source
var (
AgeRegex = regexp.MustCompile("[<>]*\\d+")
)
Functions ¶
This section is empty.
Types ¶
type AgeSearchType ¶
type AgeSearchType int
const ( MoreThan AgeSearchType = iota LessThan EqualTo IgnoreAge )
type CatResponse ¶
type CatResponse struct { ID string `json:"id"` Name string `json:"name"` Race string `json:"race"` Sex string `json:"sex"` AgeInMonth int `json:"ageInMonth"` ImageUrls []string `json:"imageUrls"` Description string `json:"description"` HasMatched bool `json:"hasMatched"` CreatedAt time.Time `json:"createdAt"` }
type CreateCatResponse ¶
type CreateUpdateCatPayload ¶
type CreateUpdateCatPayload struct { Name string `json:"name"` Race CatRace `json:"race"` Sex CatSex `json:"sex"` AgeInMonth int `json:"ageInMonth"` Description string `json:"description"` ImageURLS []string `json:"imageUrls"` }
func (CreateUpdateCatPayload) Validate ¶
func (p CreateUpdateCatPayload) Validate() error
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewHandler ¶
func (*Handler) GetCatList ¶
func (h *Handler) GetCatList(w http.ResponseWriter, r *http.Request)
type HasMatchedSearchType ¶
type HasMatchedSearchType int
const ( HasMatched HasMatchedSearchType = iota HasNotMatched IgnoreHasMatched )
type ListCatPayload ¶
type ListCatPayload struct { ID string `schema:"id" binding:"omitempty"` Limit int `schema:"limit" binding:"omitempty"` Offset int `schema:"offset" binding:"omitempty"` Race string `schema:"race" binding:"omitempty"` Sex string `schema:"sex" binding:"omitempty"` HasMatched string `schema:"hasMatched" binding:"omitempty"` AgeInMonth string `schema:"ageInMonth" binding:"omitempty"` Owned bool `schema:"owned" binding:"omitempty"` Search string `schema:"search" binding:"omitempty"` Age int AgeSearchType AgeSearchType HasMatchedType HasMatchedSearchType }
type Repository ¶
type Repository interface { List(ctx context.Context, req ListCatPayload, userID int64) ([]*Cat, error) GetByUIDAndUserID(ctx context.Context, id string, userID int64) (*Cat, error) GetByIDAndUserID(ctx context.Context, id int64, userID int64) (*Cat, error) GetByUID(ctx context.Context, uid string) (*Cat, error) Create(ctx context.Context, cat *Cat) (*Cat, error) Update(ctx context.Context, cat *Cat) error Delete(ctx context.Context, id string, userID int64) error }
func NewRepository ¶
func NewRepository(db *db.DB) Repository
type Service ¶
type Service interface { List(ctx context.Context, req ListCatPayload, userID int64) ([]CatResponse, error) Create(ctx context.Context, req CreateUpdateCatPayload, userID int64) (*CreateCatResponse, error) Update(ctx context.Context, req CreateUpdateCatPayload, id string, userID int64) error Delete(ctx context.Context, id string, userID int64) error }
func NewService ¶
func NewService(repository Repository) Service
Click to show internal directories.
Click to hide internal directories.