models

package
v0.0.0-...-52d5632 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Deserialize

func Deserialize[T SerializableItem](dbField string, hint Hint) ([]T, error)

func Parse

func Parse[T SerializableItem](item string, hint Hint) (interface{}, bool)

should I use generic? SerializableItem needs to be a concrete type however I am not too sure how to make it fit the requirement of both String()

func Serialize

func Serialize[T SerializableItem](items []T) string

Types

type Country

type Country int
const (
	Japan Country = iota
	Taiwan
	USA
	Brazil
	SouthAfrica
	France
)

func (Country) MarshalJSON

func (c Country) MarshalJSON() ([]byte, error)

func (Country) String

func (c Country) String() string

func (*Country) UnmarshalJSON

func (c *Country) UnmarshalJSON(data []byte) error

type Gender

type Gender int
const (
	MALE Gender = iota
	FEMALE
)

func (Gender) MarshalJSON

func (g Gender) MarshalJSON() ([]byte, error)

func (Gender) String

func (g Gender) String() string

func (*Gender) UnmarshalJSON

func (g *Gender) UnmarshalJSON(data []byte) error

type Hint

type Hint int
const (
	PlatformHint Hint = iota
	CountryHint
	GenderHint
)

type InsertedPost

type InsertedPost struct {
	ID   int64
	Post *SponsoredPost
}

type Platform

type Platform int
const (
	ANDROID Platform = iota
	IOS
	WEB
)

func (Platform) MarshalJSON

func (p Platform) MarshalJSON() ([]byte, error)

func (Platform) String

func (p Platform) String() string

func (*Platform) UnmarshalJSON

func (p *Platform) UnmarshalJSON(data []byte) error

type QueryCache

type QueryCache struct {
	Parameters string
	Items      []QueryItems
}

type QueryItems

type QueryItems struct {
	Title string    `json:"title" validate:"required"`
	EndAt time.Time `json:"endAt" validate:"required"`
}

type SerializableItem

type SerializableItem interface {
	// Platform | Gender | Country
	String() string
}

type Settings

type Settings struct {
	AgeStart       uint64     `json:"ageStart" validate:"gte=1,lte=125,ltecsfield=AgeEnd"`
	AgeEnd         uint64     `json:"ageEnd" validate:"gte=1,lte=125,gtecsfield=AgeStart"`
	TargetGender   []Gender   `json:"gender"`
	TargetCountry  []Country  `json:"country"`
	TargetPlatform []Platform `json:"platform"`
}

func (*Settings) Validate

func (s *Settings) Validate() error

type SponsoredPost

type SponsoredPost struct {
	Title      string    `json:"title" validate:"required"`
	StartAt    time.Time `json:"startAt" validate:"required,ltecsfield=EndAt"`
	EndAt      time.Time `json:"endAt" validate:"required,gtecsfield=StartAt"`
	Conditions Settings  `json:"conditions,omitempty" validate:"omitempty"`
}

func (*SponsoredPost) Validate

func (sp *SponsoredPost) Validate() error

Jump to

Keyboard shortcuts

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