model

package
v0.0.0-...-03e7feb Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2017 License: GPL-3.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data struct {
	ID        uint       `json:"-" gorm:"primary_key"`
	CreatedAt time.Time  `json:"-"`
	UpdatedAt time.Time  `json:"updated_at"`
	DeletedAt *time.Time `json:"-" sql:"index"`

	TagID      uint   `json:"-" gorm:"not null"`
	RemoteAddr string `json:"remote_addr" gorm:"not null"`
	Hostname   string `json:"hostname" gorm:"not null"`
	Payload    string `json:"payload" gorm:"not null" sql:"type:text;"`
}

func FindDataByTagID

func FindDataByTagID(db *gorm.DB, param FindDataParam) ([]Data, error)

type FindDataParam

type FindDataParam struct {
	ID, Page, Limit      uint
	Span, StartAt, EndAt string
	Asc                  bool
}

type Tag

type Tag struct {
	gorm.Model
	UserID   uint   `gorm:"not null"`
	Name     string `gorm:"not null;index:idx_name"`
	SomeData []Data `gorm:"ForeignKey:TagID"`
}

func FindTagByID

func FindTagByID(db *gorm.DB, id uint) (*Tag, error)

func (*Tag) AddData

func (t *Tag) AddData(db *gorm.DB, data Data) error

type User

type User struct {
	gorm.Model
	Admin    bool   `gorm:"not null"`
	Name     string `gorm:"not null;index:idx_name"`
	Password string `gorm:"not null"`
	Salt     string `gorm:"not null"`
	Token    string `gorm:"not null"`
	Tags     []Tag  `gorm:"ForeignKey:UserID"`
}

func BasicAuth

func BasicAuth(db *gorm.DB, name, pass string) (*User, error)

func CreateUser

func CreateUser(db *gorm.DB, name, password string, isAdmin bool) (*User, error)

func DeleteUser

func DeleteUser(db *gorm.DB, userID string) (*User, error)

func EditUser

func EditUser(db *gorm.DB, userID string, isAdmin bool, resetPassword string) (*User, error)

func FindUserByName

func FindUserByName(db *gorm.DB, name string) (*User, error)

func GetUsers

func GetUsers(db *gorm.DB) ([]*User, error)

func TokenAuth

func TokenAuth(db *gorm.DB, uuid string) (*User, error)

func (*User) AddTag

func (u *User) AddTag(db *gorm.DB, name string) error

func (*User) AlreadyExist

func (u *User) AlreadyExist(db *gorm.DB, name string) bool

func (*User) FindByTagName

func (u *User) FindByTagName(db *gorm.DB, name string) (*Tag, error)

func (*User) ReGenerateUserToken

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

func (*User) RemoveTag

func (u *User) RemoveTag(db *gorm.DB, name string) error

func (*User) UpdatePassword

func (u *User) UpdatePassword(db *gorm.DB, password string) (*User, error)

type Users

type Users []*User

Jump to

Keyboard shortcuts

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