models

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Article

type Article struct {
	Id       int       // 文章ID
	Title    string    // 文章标题
	Tags     []*Tag    `orm:"reverse(many)"` // 文章标签 多对多 一篇文章可能有多个标签,一个标签对应多篇文章
	Category *Category `orm:"rel(fk)"`       // 文章分类,一对多
	Content  string    `orm:"size(10000)"`   // 文章内容
	Status   bool      // 状态 草稿/发布
	CreateAt time.Time `orm:"auto_now_add;type(datetime)"` // 创建时间
}

func (*Article) Delete

func (a *Article) Delete() error

func (*Article) Insert

func (a *Article) Insert() error

func (*Article) Query

func (a *Article) Query() orm.QuerySeter

func (*Article) Read

func (a *Article) Read(fields ...string) error

func (*Article) TableName

func (a *Article) TableName() string

func (*Article) Update

func (a *Article) Update(fields ...string) error

type Category

type Category struct {
	Id           int
	CategoryName string     `orm:"unique"` // 分类名称
	Order        int        // 排序
	Status       bool       // 启动或禁用
	Article      []*Article `orm:"reverse(many)"`               // 分类下面的文章
	CreateAt     time.Time  `orm:"auto_now_add;type(datetime)"` // 添加时间
}

Category 分类表

func (*Category) Delete

func (c *Category) Delete() error

func (*Category) Insert

func (c *Category) Insert() error

func (*Category) Query

func (c *Category) Query() orm.QuerySeter

func (*Category) Read

func (c *Category) Read(fields ...string) error

func (*Category) TableName

func (c *Category) TableName() string

func (*Category) Update

func (c *Category) Update(fields ...string) error

type Tag

type Tag struct {
	Id       int
	TagName  string     // 标签名称
	Article  []*Article `orm:"rel(m2m)"`                    // 对应的文章
	CreateAt time.Time  `orm:"auto_now_add;type(datetime)"` // 添加时间
}

Tag 标签

func (*Tag) Delete

func (t *Tag) Delete() error

func (*Tag) Insert

func (t *Tag) Insert() error

func (*Tag) Query

func (t *Tag) Query() orm.QuerySeter

func (*Tag) Read

func (t *Tag) Read(fields ...string) error

func (*Tag) TableName

func (t *Tag) TableName() string

func (*Tag) Update

func (t *Tag) Update(fields ...string) error

type User

type User struct {
	Id         int       // 自增Id
	UserName   string    `orm:"unique;size(32)"`         // 用户名
	Password   string    `orm:"size(32)"`                // 密码
	Email      string    `orm:"size(50)"`                // Email
	LastLogin  time.Time `orm:"auto_now;type(datetime)"` // 上次登录时间
	LoginCount int       // 登录次数
	LastIp     string    `orm:"size(32)"` // 上次登录IP
	Active     int8      // 激活状态
}

User 用户表结构体

func (*User) Delete

func (u *User) Delete() error

func (*User) Insert

func (u *User) Insert() error

func (*User) Query

func (u *User) Query() orm.QuerySeter

func (*User) Read

func (u *User) Read(fields ...string) error

func (*User) ReadOrCreate

func (u *User) ReadOrCreate(field string, fields ...string) (bool, int64, error)

func (*User) TableName

func (m *User) TableName() string

指定表名 user

func (*User) Update

func (u *User) Update(fields ...string) error

Jump to

Keyboard shortcuts

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