models

package
v0.0.0-...-2726815 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hash

func Hash(password string) ([]byte, error)

Hash : password hashing

func VerifyPassword

func VerifyPassword(hashedPassword, password string) error

VerifyPassword : check password validity

Types

type Event

type Event struct {
	ID        uint64    `gorm:"primary_key;auto_increment" json:"id"`
	Title     string    `gorm:"size:255;not null;unique" json:"title"`
	Content   string    `gorm:"size:255;not null;" json:"content"`
	Author    User      `json:"author"`
	AuthorID  uint32    `gorm:"not null" json:"author_id"`
	CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"updated_at"`
}

Event : event entity

func (*Event) DeleteAEvent

func (p *Event) DeleteAEvent(db *gorm.DB, eid uint64, uid uint32) (int64, error)

DeleteAEvent : delete one event

func (*Event) FindEventByID

func (p *Event) FindEventByID(db *gorm.DB, eid uint64) (*Event, error)

FindEventByID : find one event by id

func (*Event) Prepare

func (p *Event) Prepare(Title, Content string, AuthorID int32)

Prepare : prepare Event entity

func (*Event) SaveEvent

func (p *Event) SaveEvent(db *gorm.DB) (*Event, error)

SaveEvent : save one event

func (*Event) UpdateAEvent

func (p *Event) UpdateAEvent(db *gorm.DB, eid uint64) (*Event, error)

UpdateAEvent : update one event

func (*Event) Validate

func (p *Event) Validate() error

Validate : validate field for one event

type User

type User struct {
	ID        uint32    `gorm:"primary_key;auto_increment" json:"id"`
	Nickname  string    `gorm:"size:255;not null;unique" json:"nickname"`
	Email     string    `gorm:"size:100;not null;unique" json:"email"`
	Password  string    `gorm:"size:100;not null;" json:"password"`
	CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"updated_at"`
}

User : user entity model database

func (*User) BeforeSave

func (u *User) BeforeSave() error

BeforeSave : hash password before saving

func (*User) DeleteAUser

func (u *User) DeleteAUser(db *gorm.DB, uid uint32) (int64, error)

DeleteAUser : delete user

func (*User) FindAllEvents

func (u *User) FindAllEvents(db *gorm.DB, srv pbEvent.EventService_ListEventsServer) error

FindAllEvents : retrieve all events in database

func (*User) FindAllUsers

func (u *User) FindAllUsers(db *gorm.DB, srv pbUser.UserService_ListUsersServer) error

FindAllUsers : retrieve all users in database

func (*User) FindUserByID

func (u *User) FindUserByID(db *gorm.DB, uid uint32) (*User, error)

FindUserByID : find one user by id

func (*User) Prepare

func (u *User) Prepare(Nickname, Email, Password string)

Prepare : prepare user entity

func (*User) SaveUser

func (u *User) SaveUser(db *gorm.DB) (*User, error)

SaveUser : create user in database

func (*User) UpdateAUser

func (u *User) UpdateAUser(db *gorm.DB, uid uint32) (*User, error)

UpdateAUser : update one user fields

func (*User) Validate

func (u *User) Validate(action string) error

Validate : validate user fields

Jump to

Keyboard shortcuts

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