model

package
v1.6.7 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	ID          uint       `gorm:"primary_key" json:"id"`
	Name        string     `json:"name"`
	Password    string     `json:"-"`
	AuthorityID uint       `json:"authority_id"`
	Authority   *Authority `json:"authority"`
}

Account defines struct of account data.

func NewAccount

func NewAccount(name string, password string, authorityID uint) *Account

NewAccount is constructor.

func NewAccountWithPlainPassword

func NewAccountWithPlainPassword(name string, password string, authorityID uint) *Account

NewAccountWithPlainPassword is constructor. And it is encoded plain text password by using bcrypt.

func (*Account) Create

func (a *Account) Create(rep repository.Repository) (*Account, error)

Create persists this account data.

func (*Account) FindByName

func (a *Account) FindByName(rep repository.Repository, name string) (*Account, error)

FindByName returns accounts full matched given account name.

func (Account) TableName

func (Account) TableName() string

TableName returns the table name of account struct and it is used by gorm.

func (*Account) ToString

func (a *Account) ToString() (string, error)

ToString is return string of object

type Authority

type Authority struct {
	ID   uint   `gorm:"primary_key" json:"id"`
	Name string `json:"name"`
}

Authority defines struct of authority data.

func NewAuthority

func NewAuthority(name string) *Authority

NewAuthority is constructor.

func (*Authority) Create

func (a *Authority) Create(rep repository.Repository) (*Authority, error)

Create persists this authority data.

func (Authority) TableName

func (Authority) TableName() string

TableName returns the table name of authority struct and it is used by gorm.

func (*Authority) ToString

func (a *Authority) ToString() (string, error)

ToString is return string of object

type Book

type Book struct {
	ID         uint      `gorm:"primary_key" json:"id"`
	Title      string    `json:"title"`
	Isbn       string    `json:"isbn"`
	CategoryID uint      `json:"categoryId"`
	Category   *Category `json:"category"`
	FormatID   uint      `json:"formatId"`
	Format     *Format   `json:"format"`
}

Book defines struct of book data.

func NewBook

func NewBook(title string, isbn string, categoryID uint, formatID uint) *Book

NewBook is constructor

func (*Book) Create

func (b *Book) Create(rep repository.Repository) (*Book, error)

Create persists this book data.

func (*Book) Delete

func (b *Book) Delete(rep repository.Repository) (*Book, error)

Delete deletes this book data.

func (*Book) FindAll

func (b *Book) FindAll(rep repository.Repository) (*[]Book, error)

FindAll returns all books of the book table.

func (*Book) FindAllByPage

func (b *Book) FindAllByPage(rep repository.Repository, page int, size int) (*Page, error)

FindAllByPage returns the page object of all books.

func (*Book) FindByID

func (b *Book) FindByID(rep repository.Repository, id uint) (*Book, error)

FindByID returns a book full matched given book's ID.

func (*Book) FindByTitle

func (b *Book) FindByTitle(rep repository.Repository, title string, page int, size int) (*Page, error)

FindByTitle returns the page object of books partially matched given book title.

func (*Book) Save

func (b *Book) Save(rep repository.Repository) (*Book, error)

Save persists this book data.

func (Book) TableName

func (Book) TableName() string

TableName returns the table name of book struct and it is used by gorm.

func (*Book) ToString

func (b *Book) ToString() (string, error)

ToString is return string of object

func (*Book) Update

func (b *Book) Update(rep repository.Repository) (*Book, error)

Update updates this book data.

type Category

type Category struct {
	ID   uint   `gorm:"primary_key" json:"id"`
	Name string `validate:"required" json:"name"`
}

Category defines struct of category data.

func NewCategory

func NewCategory(name string) *Category

NewCategory is constructor

func (*Category) Create

func (c *Category) Create(rep repository.Repository) (*Category, error)

Create persists this category data.

func (*Category) FindAll

func (c *Category) FindAll(rep repository.Repository) (*[]Category, error)

FindAll returns all categories of the category table.

func (*Category) FindByID

func (c *Category) FindByID(rep repository.Repository, id uint) (*Category, error)

FindByID returns a category full matched given category's ID.

func (Category) TableName

func (Category) TableName() string

TableName returns the table name of category struct and it is used by gorm.

func (*Category) ToString

func (c *Category) ToString() (string, error)

ToString is return string of object

type Format

type Format struct {
	ID   uint   `gorm:"primary_key" json:"id"`
	Name string `validate:"required" json:"name"`
}

Format defines struct of format data.

func NewFormat

func NewFormat(name string) *Format

NewFormat is constructor

func (*Format) Create

func (f *Format) Create(rep repository.Repository) (*Format, error)

Create persists this category data.

func (*Format) FindAll

func (f *Format) FindAll(rep repository.Repository) (*[]Format, error)

FindAll returns all formats of the format table.

func (*Format) FindByID

func (f *Format) FindByID(rep repository.Repository, id uint) (*Format, error)

FindByID returns a format full matched given format's ID.

func (Format) TableName

func (Format) TableName() string

TableName returns the table name of format struct and it is used by gorm.

func (*Format) ToString

func (f *Format) ToString() (string, error)

ToString is return string of object

type Page

type Page struct {
	Content          *[]Book `json:"content"`
	Last             bool    `json:"last"`
	TotalElements    int     `json:"totalElements"`
	TotalPages       int     `json:"totalPages"`
	Size             int     `json:"size"`
	Page             int     `json:"page"`
	NumberOfElements int     `json:"numberOfElements"`
}

Page defines struct of pagination data.

func NewPage

func NewPage() *Page

NewPage is constructor

type RecordAccount

type RecordAccount struct {
	ID            uint
	Name          string
	Password      string
	AuthorityID   uint
	AuthorityName string
}

RecordAccount defines struct represents the record of the database.

type RecordBook

type RecordBook struct {
	ID           uint
	Title        string
	Isbn         string
	CategoryID   uint
	CategoryName string
	FormatID     uint
	FormatName   string
}

RecordBook defines struct represents the record of the database.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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