schema

package
v0.0.0-...-8f419a9 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: MIT, MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Permission

type Permission struct {
	db.BaseModel
	Name      string `gorm:"column:name;type:varchar(255)  comment '权限名称';not null;default:''"`
	Memo      string `gorm:"column:memo;type:varchar(255)  comment '备注';not null;default:''"`
	Path      string `gorm:"column:path;type:varchar(255)  comment '路径';not null;default:''"`
	Method    string `gorm:"column:method;type:varchar(255)  comment '方法';not null;default:''"`
	ParentID  uint64 `gorm:"column:parent_id;type:int comment '父级ID'; index:parent_id;not null; default:0"`
	ParentIDS string `gorm:"column:parent_ids;type:varchar(255)  comment '父级路径';not null;default:''"`
}

func (*Permission) BeforeSave

func (model *Permission) BeforeSave(tx *gorm.DB) (err error)

BeforeSave 保存前模型事件

func (*Permission) ToBizPermission

func (model *Permission) ToBizPermission() *biz.Permission

ToBizPermission 转换为biz层权限实体

type Role

type Role struct {
	db.BaseModel
	Name            string            `gorm:"index:,unique uniqueIndex unique;column:name;type:varchar(255)  comment '角色名称';not null;default:''"` //定义唯一索引要按当前格式,否则会重复创建,参考issue:https://github.com/go-gorm/gorm/issues/5752
	Memo            string            `gorm:"column:memo;type:varchar(255)  comment '备注';not null;default:''"`
	RolePermissions []*RolePermission `gorm:"foreignKey:RoleID;references:ID"`
}

Role 角色模型

func (*Role) ToBizRole

func (model *Role) ToBizRole() *biz.Role

ToBizRole 转换为biz层角色实体

type RolePermission

type RolePermission struct {
	db.BaseModel        // 唯一标识
	RoleID       uint64 `gorm:"column:role_id;type:int comment '角色ID'; index;not null; default:0"`
	Role         *Role
	PermissionID uint64 `gorm:"column:permission_id;type:int comment '权限ID'; index;not null; default:0"`
	Permission   *Permission
}

RolePermission 角色权限

type User

type User struct {
	db.BaseModel
	Name      string      `gorm:"column:name;type:varchar(255)  comment '用户名';not null;default:''"`
	Email     string      `gorm:"index:,unique uniqueIndex unique;column:email;type:varchar(50) comment '邮箱';not null;default:''"`
	Password  string      `gorm:"column:password;type:varchar(255) comment '密码';not null;default:''" `
	Status    int         `gorm:"column:status;type:tinyint comment '状态';not null;default:1"`
	UserRoles []*UserRole `gorm:"foreignKey:UserID;references:ID"`
}

User 用户模型

func (*User) BeforeSave

func (model *User) BeforeSave(tx *gorm.DB) (err error)

BeforeSave 保存前模型事件

func (*User) ToBizUser

func (model *User) ToBizUser() *biz.User

ToBizUser 转换为biz层用户实体

type UserRole

type UserRole struct {
	db.BaseModel
	UserID uint64 `gorm:"column:user_id;type:int comment '用户ID'; index;not null; default:0"`
	User   *User
	RoleID uint64 `gorm:"column:role_id;type:int comment '角色ID'; index;not null; default:0"`
	Role   *Role
}

UserRole 用户角色

func (*UserRole) ToBizUserRole

func (u *UserRole) ToBizUserRole() *biz.UserRole

ToBizUserRole 转换为biz层用户角色实体

Jump to

Keyboard shortcuts

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