models

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdminUser added in v0.3.0

type AdminUser struct {
	Model
	Username *string `gorm:"type:string;uniqueIndex;comment:用户名"`
	Password string  `gorm:"type:string;comment:密码"`
	Email    *string `gorm:"type:string;uniqueIndex;comment:邮箱"`
	Nickname *string `gorm:"type:string;default:'';comment:昵称"`
	Avatar   *string `gorm:"type:string;default:'';comment:头像"`
}

func (*AdminUser) From added in v0.3.0

func (u *AdminUser) From(account string) error

From 从用户名获取数据

func (*AdminUser) Login added in v0.3.0

func (u *AdminUser) Login(aud ...string) (string, error)

Login 登录

type Auth

type Auth struct {
	User
	AdminUser
}

type Model

type Model struct {
	app.ModelHandle `gorm:"-"`
	gorm.Model
}

func (*Model) IDString

func (m *Model) IDString() string

IDString 获取 ID 字符串

type TestArticle

type TestArticle struct {
	Model
	Title      string  `gorm:"type:string;default:'';not null;commit:标题"`
	Content    *string `gorm:"type:text;commit:内容"`
	CategoryID *uint
	Category   *TestCategory `gorm:"foreignKey:CategoryID"`
	UserID     *uint
	User       *TestUser     `gorm:"foreignKey:UserID"`
	Comments   []TestComment `gorm:"foreignKey:ArticleID"`
}

type TestCategory

type TestCategory struct {
	Model
	Name     string `gorm:"type:string;default:'';not null;comment:类别名称"`
	Order    uint   `gorm:"type:uint;default:0;not null;commit:排序"`
	ParentID *uint
	Parent   *TestCategory  `gorm:"foreignKey:ParentID"`
	Children []TestCategory `gorm:"foreignKey:ParentID"`
	UserID   *uint
	User     *TestUser     `gorm:"foreignKey:UserID"`
	Articles []TestArticle `gorm:"foreignKey:CategoryID"`
}

type TestComment

type TestComment struct {
	Model
	Content   *string `gorm:"type:text;comment:评论内容"`
	UserID    *uint
	User      *TestUser `gorm:"foreignKey:UserID"`
	ArticleID *uint
	Article   *TestArticle `gorm:"foreignKey:ArticleID"`
	ParentID  *uint
	Parent    *TestComment  `gorm:"foreignKey:ParentID"`
	Children  []TestComment `gorm:"foreignKey:ParentID"`
}

type TestUser

type TestUser struct {
	Model
	Username   *string        `gorm:"type:string;uniqueIndex;comment:用户名"`
	Password   string         `gorm:"type:string;comment:密码"`
	Email      *string        `gorm:"type:string;uniqueIndex;comment:邮箱"`
	UserInfo   TestUserInfo   `gorm:"foreignKey:UserID"`
	Categories []TestCategory `gorm:"foreignKey:UserID"`
	Articles   []TestArticle  `gorm:"foreignKey:UserID"`
	Comments   []TestComment  `gorm:"foreignKey:UserID"`
}

type TestUserInfo

type TestUserInfo struct {
	Model
	Nickname *string `gorm:"type:string;default:'';comment:昵称"`
	Avatar   *string `gorm:"type:string;default:'';comment:头像"`
	UserID   *uint
	User     *TestUser `gorm:"foreignKey:UserID"`
}

type User

type User struct {
	Model
	Username *string `gorm:"type:string;uniqueIndex;comment:用户名"`
	Password string  `gorm:"type:string;comment:密码"`
	Email    *string `gorm:"type:string;uniqueIndex;comment:邮箱"`
	Nickname *string `gorm:"type:string;default:'';comment:昵称"`
	Avatar   *string `gorm:"type:string;default:'';comment:头像"`
}

func (*User) From

func (u *User) From(account string) error

From 从用户名获取数据

func (*User) Login

func (u *User) Login(aud ...string) (string, error)

Login 登录

func (*User) Register

func (u *User) Register() error

Register 注册

Jump to

Keyboard shortcuts

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