advert

package
v0.0.0-...-e100621 Latest Latest
Warning

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

Go to latest
Published: May 31, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is used when a specific User is requested but does not exist.
	ErrNotFound = errors.New("not found")

	// ErrInvalidID occurs when an ID is not in a valid form.
	ErrInvalidID = errors.New("ID is not in its proper form")
)

Functions

This section is empty.

Types

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

Advert ...

func New

func New(log *log.Logger, db *sqlx.DB) Advert

New ...

func (Advert) Activate

func (a Advert) Activate(ctx context.Context, traceID string, id string) (AdvertInfo, error)

Activate deactivate advert.

func (Advert) Create

func (a Advert) Create(ctx context.Context, traceID string, na NewAdvert, now time.Time) (Info, error)

Create creates new advert

func (Advert) Deactivate

func (a Advert) Deactivate(ctx context.Context, traceID string, id string) (AdvertInfo, error)

Deactivate deactivate advert.

func (Advert) Query

func (a Advert) Query(ctx context.Context, traceID string, limit int, offset int, filters map[string][]string) ([]AdvertInfo, error)

Query retrieves a list of existing categories from the database.

func (Advert) QueryByID

func (a Advert) QueryByID(ctx context.Context, traceID string, advertID string) (AdvertInfo, error)

QueryByID gets the specified advert from the database.

func (Advert) TotalActive

func (a Advert) TotalActive(ctx context.Context, traceID string) (int, error)

Query retrieves a total count of adverts from the database.

type AdvertInfo

type AdvertInfo struct {
	ID          string `db:"uuid" json:"id"`
	UserID      string `db:"user_uuid" json:"user_uuid"`
	CategoryID  string `db:"category_uuid" json:"category_uuid"`
	Title       string `db:"title" json:"title"`
	Description string `db:"description" json:"description"`
	Location    string `db:"location" json:"location"`
	Price       int    `db:"price" json:"price"`
	IsActive    bool   `db:"is_active" json:"is_active"`

	Created      time.Time             `db:"created" json:"created"`
	Updated      time.Time             `db:"updated" json:"updated"`
	UserInfo     user.UserInfo         `db:"user" json:"user"`
	CategoryInfo category.CategoryInfo `db:"category" json:"category"`
}

AdvertInfo represent an individual advert.

type Info

type Info struct {
	ID          string `db:"uuid" json:"id"`
	UserID      string `db:"user_uuid" json:"user_uuid"`
	CategoryID  string `db:"category_uuid" json:"category_uuid"`
	Title       string `db:"title" json:"title"`
	Description string `db:"description" json:"description"`
	Location    string `db:"location" json:"location"`
	Price       int    `db:"price" json:"price"`
	IsActive    bool   `db:"is_active" json:"is_active"`

	Created time.Time `db:"created" json:"created"`
	Updated time.Time `db:"updated" json:"updated"`
}

Info represent an individual advert.

type NewAdvert

type NewAdvert struct {
	UserID      string `db:"user_uuid" json:"user_uuid"`
	CategoryID  string `db:"category_uuid" json:"category_uuid"`
	Title       string `db:"title" json:"title"`
	Description string `db:"description" json:"description"`
	Location    string `db:"location" json:"location"`
	Price       int    `db:"price" json:"price"`
}

NewAdvert represent an individual advert.

Jump to

Keyboard shortcuts

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