models

package
v0.0.0-...-9116ad2 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2015 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func GenerateAnonymousUser

func GenerateAnonymousUser() sessionauth.User

func InitSeed

func InitSeed()

Types

type Category

type Category struct {
	Model

	Name   string `sql:"type:varchar(255);not null"` // gin index
	Yomi   string `sql:"type:varchar(255);"`         // gin index
	Romaji string `sql:"type:varchar(128)"`
	Gyou   string `sql:"type:varchar(6);index"`

	Prefix string `sql:"type:varchar(16);unique;not null"`

	Image   *Image
	ImageID sql.NullInt64 `sql:"index"`

	Dicts []*Dict
}

func (*Category) LatestDicts

func (m *Category) LatestDicts(limit int)

func (*Category) ModifiedDicts

func (m *Category) ModifiedDicts(limit int)

type Comment

type Comment struct {
	Model

	Title       string `sql:"type:varchar(64)" form:"title"`                        // gin index
	Comment     string `sql:"type:text;not null" form:"comment" binding:"required"` // gin index
	CommentHTML string `sql:"type:text;not null" form:"-"`

	Role string `sql:"type:varchar(32);index;default:'public'" form:"-"`

	ObjectID   int64  `sql:"index" form:"-"`
	ObjectType string `sql:"index" form:"-"`

	User   *User
	UserID sql.NullInt64 `sql:"index" form:"-"`
}

func (*Comment) BeforeSave

func (m *Comment) BeforeSave() error

type Dict

type Dict struct {
	Model

	Name   string `sql:"type:varchar(255);unique;not null"` // gin index
	Yomi   string `sql:"type:varchar(255);"`                // gin index
	Romaji string `sql:"type:varchar(128)"`
	Gyou   string `sql:"type:varchar(6);index"`

	Content     string `sql:"type:text"` // gin index
	ContentHTML string `sql:"type:text"` // gin index

	Prefix string `sql:"type:varchar(16);index;not null"`

	Image   *Image
	ImageID sql.NullInt64 `sql:"index"`

	Category   *Category
	CategoryID sql.NullInt64 `sql:"index"`

	Tags     []*Tag     `gorm:"many2many:dict_tags"`
	Comments []*Comment `gorm:"polymorphic:Object;"`
}

func (*Dict) AfterCreate

func (m *Dict) AfterCreate() error

func (*Dict) BeforeCreate

func (m *Dict) BeforeCreate() error

func (*Dict) BeforeSave

func (m *Dict) BeforeSave() error

func (*Dict) GetPrefix

func (m *Dict) GetPrefix() string

func (*Dict) TagsLoader

func (m *Dict) TagsLoader()

type Image

type Image struct {
	Model

	Name string `sql:"type:varchar(255);not null"`
	Src  string `sql:"type:varchar(255);not null"`

	Ext    string
	Mime   string
	Width  int
	Height int
}

func NewImageByIMG

func NewImageByIMG(img *funcmaps.Img) *Image

type Model

type Model struct {
	ID        int64      `gorm:"primary_key"`
	CreatedAt time.Time  `sql:"index"`
	UpdatedAt time.Time  `sql:"index"`
	DeletedAt *time.Time `sql:"index"`
}

type Tag

type Tag struct {
	Model

	Name   string `sql:"type:varchar(255);unique;not null"` // gin index
	Yomi   string `sql:"type:varchar(255);"`                // gin index
	Romaji string `sql:"type:varchar(128)"`
	Gyou   string `sql:"type:varchar(6);index"`

	Image   *Image
	ImageID sql.NullInt64 `sql:"index"`

	Dicts []*Dict `gorm:"many2many:dict_tags;"`
}

type User

type User struct {
	Model

	Email    string `sql:"type:varchar(128);not null;unique" form:"email"  binding:"required"`
	Password string `sql:"type:varchar(128);not null" form:"password"  binding:"required"`

	LoggedAt time.Time `form:"-" `

	Image   *Image
	ImageID sql.NullInt64 `sql:"index"`

	Repassword string `sql:"-" form:"repassword"`
	// contains filtered or unexported fields
}

func (*User) GetById

func (m *User) GetById(id interface{}) error

func (*User) IsAuthenticated

func (m *User) IsAuthenticated() bool

func (*User) Login

func (m *User) Login()

func (*User) Logout

func (m *User) Logout()

func (*User) UniqueId

func (m *User) UniqueId() interface{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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