services

package
v0.0.0-...-808fada Latest Latest
Warning

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

Go to latest
Published: May 11, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitSessionStore

func InitSessionStore(secret string, db *gorm.DB, shouldCleanup bool) *gormstore.Store

InitSessionStore initializes the session storeage mechanism

func Markdown

func Markdown(s string) template.HTML

Markdown returns rendered markdown

func NewRenderer

func NewRenderer(config RendererConfig) *echoview.ViewEngine

NewRenderer build and return a new renderer

Types

type FileService

type FileService struct {
	DB *gorm.DB
}

FileService a service for managing files

func NewFileService

func NewFileService(db *gorm.DB) *FileService

NewFileService returns a new file service

type MenuService struct {
	DB *gorm.DB
}

MenuService a service to get the menus

func NewMenuService

func NewMenuService(db *gorm.DB) *MenuService

NewMenuService returns a new menu service

func (s *MenuService) Create(menu *models.Menu) error

Create creates a menu

func (s *MenuService) CreateItem(menuItem *models.MenuItem) error

CreateItem creates a menu item

func (s *MenuService) Delete(id uint) error

Delete delete's the menu

func (s *MenuService) DeleteItem(id uint) error

DeleteItem delete's the menu item

func (s *MenuService) Find(id uint) (models.Menu, error)

Find attempts to find a menu and it's items by the menu id

func (s *MenuService) FindItem(id uint) (*models.MenuItem, error)

FindItem attempts to find a menu item by it's ID

func (s *MenuService) GetAll() (map[string]models.Menu, error)

GetAll get's all the menus

func (s *MenuService) GetAllForView() (*models.ViewMenus, error)

GetAllForView get's all menus in ViewMenus form

func (s *MenuService) Update(menu *models.Menu) error

Update updates a menu

func (s *MenuService) UpdateItem(menuItem *models.MenuItem) error

UpdateItem updates a menu item

type PostService

type PostService struct {
	DB *gorm.DB
}

PostService a service for getting, creating, and updating posts

func NewPostService

func NewPostService(db *gorm.DB) *PostService

NewPostService builds a new PostService

func (*PostService) Create

func (s *PostService) Create(post *models.Post) error

Create creates a new post in the database

func (*PostService) Delete

func (s *PostService) Delete(post *models.Post) error

Delete delete's a post

func (*PostService) GetBySlug

func (s *PostService) GetBySlug(slug string) (*models.Post, error)

GetBySlug attempts to get a post by slug

func (*PostService) GetList

func (s *PostService) GetList(page, limit int) ([]models.Post, error)

GetList gets a list of posts

func (*PostService) Update

func (s *PostService) Update(post *models.Post) error

Update saves the post

type ProfileService

type ProfileService struct {
	DB *gorm.DB
}

ProfileService a service to manage profiles

func NewProfileService

func NewProfileService(db *gorm.DB) *ProfileService

NewProfileService returns a new ProfileService

func (*ProfileService) Create

func (s *ProfileService) Create(profile *models.Profile) error

Create saves a new profile to the database

func (*ProfileService) GetByUserID

func (s *ProfileService) GetByUserID(userID int) (*models.Profile, error)

GetByUserID gets a profile by user

func (*ProfileService) GetFirst

func (s *ProfileService) GetFirst() (*models.Profile, error)

GetFirst gets the first profile from the db (there should only be one)

func (*ProfileService) Update

func (s *ProfileService) Update(profile *models.Profile) error

Update updates a profile

type RendererConfig

type RendererConfig struct {
	Root         string   `default:"views"`
	Extension    string   `default:".html"`
	Master       string   `default:"layouts/master"`
	Partials     []string `required:"true"`
	DisableCache bool     `default:"true"`
}

RendererConfig configuration for our renderer

type Session

type Session struct {
	Name     string
	Internal *sessions.Session
	Context  echo.Context
}

Session a session that holds an internal session storage mechanism

func GetSession

func GetSession(name string, ctx echo.Context) (*Session, error)

GetSession gets a session

func (*Session) ClearAll

func (s *Session) ClearAll() error

ClearAll clears all values from the session

func (*Session) ClearValue

func (s *Session) ClearValue(key interface{}) error

ClearValue clears a single value from the session

func (*Session) GetValue

func (s *Session) GetValue(key string) interface{}

GetValue gets a value from the session

func (*Session) LoggedIn

func (s *Session) LoggedIn() bool

LoggedIn checks the session to see if the user is logged in

func (*Session) Save

func (s *Session) Save() error

Save saves a session

func (*Session) SetValue

func (s *Session) SetValue(key, value interface{}, shouldSave bool) error

SetValue sets a value in the session

func (*Session) UserID

func (s *Session) UserID() int

UserID attempts to get the userID from session

type UserService

type UserService struct {
	DB *gorm.DB
}

UserService a service to handle dealing with Users

func NewUserService

func NewUserService(db *gorm.DB) *UserService

NewUserService returns a new UserService

func (*UserService) CheckPassword

func (s *UserService) CheckPassword(password string, user *models.User) (bool, error)

CheckPassword checks if a given password is correct for a user

func (*UserService) Create

func (s *UserService) Create(user *models.User) error

Create creates a user using the given model

func (*UserService) GetByEmail

func (s *UserService) GetByEmail(email string) (*models.User, error)

GetByEmail gets a user by email

Jump to

Keyboard shortcuts

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