app

package
v0.0.0-...-e5cd8ee Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2023 License: Unlicense Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefunctAd = errors.New("there is no ad with this ID")
View Source
var DefunctUser = errors.New("there is no user with this ID")
View Source
var PermissionDenied = errors.New("the user does not have enough permission to edit the ad")

Functions

This section is empty.

Types

type AdService

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

func (*AdService) ChangeAdStatus

func (a *AdService) ChangeAdStatus(adId int64, userId int64, published bool) (ads.Ad, error)

func (*AdService) CreateAd

func (a *AdService) CreateAd(title string, text string, userId int64) (ads.Ad, error)

func (*AdService) CreateUser

func (a *AdService) CreateUser(name string, email string) (users.User, error)

func (*AdService) DeleteAd

func (a *AdService) DeleteAd(adId int64, userId int64) error

func (*AdService) DeleteUser

func (a *AdService) DeleteUser(userId int64) error

func (*AdService) GetAd

func (a *AdService) GetAd(adId int64) (ads.Ad, error)

func (*AdService) GetUser

func (a *AdService) GetUser(userId int64) (users.User, error)

func (*AdService) ListAds

func (a *AdService) ListAds(pubFilter bool, userFilter int64, timeFilter time.Time) ([]ads.Ad, error)

func (*AdService) SearchAds

func (a *AdService) SearchAds(pattern string) ([]ads.Ad, error)

func (*AdService) UpdateAd

func (a *AdService) UpdateAd(adId int64, userId int64, title string, text string) (ads.Ad, error)

func (*AdService) UpdateUser

func (a *AdService) UpdateUser(userId int64, name string, email string) (users.User, error)

type App

type App interface {
	CreateAd(title string, text string, userId int64) (ads.Ad, error)
	ChangeAdStatus(adId int64, userId int64, published bool) (ads.Ad, error)
	UpdateAd(adId int64, userId int64, title string, text string) (ads.Ad, error)
	GetAd(adId int64) (ads.Ad, error)
	DeleteAd(adId int64, userId int64) error
	ListAds(pubFilter bool, userFilter int64, timeFilter time.Time) ([]ads.Ad, error)
	SearchAds(pattern string) ([]ads.Ad, error)

	CreateUser(name string, email string) (users.User, error)
	UpdateUser(userId int64, name string, email string) (users.User, error)
	GetUser(userId int64) (users.User, error)
	DeleteUser(userId int64) error
}

func NewApp

func NewApp(adRepo Repository, userRepo Repository) App

type Repository

type Repository interface {
	Add(e interface{}) error
	Update(id int64, ad interface{}) error
	Get(id int64) (interface{}, error)
	Delete(id int64) error
	CheckIdExist(id int64) bool
	GetNextId() int64
	GetArray() []interface{}
}

Jump to

Keyboard shortcuts

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