models

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 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 AdminMenu

type AdminMenu struct {
	Model

	Icon  *string `gorm:"type:string;comment:图标"`
	Name  string  `gorm:"type:string;not null;comment:菜单名称"`
	Path  *string `gorm:"type:string;comment:菜单路由"`
	Order uint    `gorm:"type:uint;default:0;not null;commit:排序"`

	ParentID *uint
	Parent   *AdminMenu `gorm:"foreignKey:ParentID"`

	Children []AdminMenu `gorm:"foreignKey:ParentID"`

	Roles []*AdminRole `gorm:"many2many:admin_menu_roles;joinForeignKey:menu_id;joinReferences:role_id"`
}

type AdminPermission

type AdminPermission struct {
	Model

	Name   *string `gorm:"type:string;comment:权限名称"`
	Flag   string  `gorm:"type:string;not null;comment:权限标识"`
	Method string  `gorm:"type:string;default:'ANY';comment:请求方法"`
	Path   string  `gorm:"type:string;not null;comment:请求路由"`
	Order  uint    `gorm:"type:uint;default:0;not null;commit:排序"`

	ParentID *uint
	Parent   *AdminPermission `gorm:"foreignKey:ParentID"`

	Children []AdminPermission `gorm:"foreignKey:ParentID"`

	Roles []*AdminRole `gorm:"many2many:admin_permission_roles;joinForeignKey:permission_id;joinReferences:role_id"`
}

type AdminRole

type AdminRole struct {
	Model

	Name *string `gorm:"type:string;comment:角色名称"`
	Flag string  `gorm:"type:string;not null;comment:角色标记"`

	Users []*AdminUser `gorm:"many2many:admin_role_users;joinForeignKey:role_id;joinReferences:user_id"`

	Menus []*AdminMenu `gorm:"many2many:admin_menu_roles;joinForeignKey:role_id;joinReferences:menu_id"`

	Permissions []*AdminPermission `gorm:"many2many:admin_permission_roles;joinForeignKey:role_id;joinReferences:permission_id"`
}

type AdminUser

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:头像"`

	Roles []*AdminRole `gorm:"many2many:admin_role_users;joinForeignKey:user_id;joinReferences:role_id"`
}

func (*AdminUser) From

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

From 从用户名获取数据

func (*AdminUser) Login

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