catmatch

package
v0.0.0-...-b329bd3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCatMatchNotFound      = errors.New("cat match not found")
	ErrCatMatchNoLongerValid = errors.New("cat match no longer valid")
	ErrCatHasMatched         = errors.New("cat has matched before")
	ErrCatSameSex            = errors.New("cat has same sex")
	ErrCatSameUser           = errors.New("cat has same user")
	ErrValidationFailed      = errors.New("validation failed")
)

Functions

This section is empty.

Types

type ApproveOrRejectMatch

type ApproveOrRejectMatch struct {
	MatchUID string `json:"matchId"`
}

func (ApproveOrRejectMatch) Validate

func (p ApproveOrRejectMatch) Validate() error

type CatMatchList

type CatMatchList struct {
	ID        string
	IssuedBy  Issuer
	MatchCat  cat.CatResponse
	IssuerCat cat.CatResponse
	Message   string
	CreatedAt time.Time
}

type CatMatchResponse

type CatMatchResponse struct {
	ID             string          `json:"id"`
	IssuedBy       Issuer          `json:"issuedBy"`
	MatchCatDetail cat.CatResponse `json:"matchCatDetail"`
	UserCatDetail  cat.CatResponse `json:"userCatDetail"`
	Message        string          `json:"message"`
	CreatedAt      time.Time       `json:"createdAt"`
}

func MakeCatMatchResponse

func MakeCatMatchResponse(list []CatMatchList, userId int64) []CatMatchResponse

type CatMatches

type CatMatches struct {
	ID             int64       `json:"id"`
	UID            string      `json:"uid"`
	IssuerCatId    int64       `json:"issuer_cat_id"`
	IssueUserId    int64       `json:"issue_user_id"`
	MatchCatId     int64       `json:"match_cat_id"`
	MatchUserId    int64       `json:"match_user_id"`
	Message        string      `json:"message"`
	ApprovalStatus MatchStatus `json:"approval_status"`
	CreatedAt      *time.Time  `json:"created_at"`
}

type DeleteMatch

type DeleteMatch struct {
	MatchUID string `schema:"id" binding:"omitempty"`
}

func (DeleteMatch) Validate

func (p DeleteMatch) Validate() error

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(service Service) *Handler

func (*Handler) Approve

func (h *Handler) Approve(w http.ResponseWriter, r *http.Request)

func (*Handler) Create

func (h *Handler) Create(w http.ResponseWriter, r *http.Request)

func (*Handler) Delete

func (h *Handler) Delete(w http.ResponseWriter, r *http.Request)

func (*Handler) GetCatMatchList

func (h *Handler) GetCatMatchList(w http.ResponseWriter, r *http.Request)

func (*Handler) Reject

func (h *Handler) Reject(w http.ResponseWriter, r *http.Request)

type Issuer

type Issuer struct {
	ID        int64     `json:"-"`
	Name      string    `json:"name"`
	Email     string    `json:"email"`
	CreatedAt time.Time `json:"createdAt"`
}

type MatchStatus

type MatchStatus string
const (
	Pending  MatchStatus = "pending"
	Approved MatchStatus = "approved"
	Rejected MatchStatus = "rejected"
)

type PostCatMatch

type PostCatMatch struct {
	MatchCatId string `json:"matchCatId"`
	UserCatId  string `json:"userCatId"`
	Message    string `json:"message"`
}

func (PostCatMatch) Validate

func (p PostCatMatch) Validate() error

type Repository

type Repository interface {
	Create(ctx context.Context, catMatch *CatMatches) error
	Approve(ctx context.Context, catMatch *CatMatches) error
	Reject(ctx context.Context, catMatch *CatMatches) error
	Delete(ctx context.Context, id int64, userId int64) error
	// GetByCatID(ctx context.Context, catID int64) (*CatMatches, error)
	GetByUIDAndUserID(ctx context.Context, uid string, userID int64, filter map[string]interface{}) (*CatMatches, error)
	// GetMatchingCats(ctx context.Context, matchUid string) (*CatMatchAndCats, error)
	List(ctx context.Context, userID int64, filter map[string]interface{}) ([]CatMatchList, error)
}

func NewRepository

func NewRepository(db *db.DB) Repository

type Service

type Service interface {
	Create(ctx context.Context, req PostCatMatch, userID int64) error
	Approve(ctx context.Context, req ApproveOrRejectMatch, userId int64) error
	Reject(ctx context.Context, req ApproveOrRejectMatch, userId int64) error
	Delete(ctx context.Context, id string, userId int64) error
	List(ctx context.Context, userID int64) ([]CatMatchResponse, error)
}

func NewService

func NewService(repository Repository, catRepository cat.Repository) Service

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL