model

package
v0.0.0-...-da6f084 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CrudTime

type CrudTime struct {

	/** 创建时间 */
	CreatedAt time.Time

	/** 更新时间 */
	UpdatedAt time.Time

	/** 删除时间 */
	DeletedAt *time.Time `sql:"index"`
}

定义 增删改时间 结构体

type Function

type Function struct {

	/** 主键 id */
	ID string `gorm:"type:varchar(36);primary_key" form:"id"`

	/** 功能名称 */
	FunName string

	/** 访问路径 */
	FunUrl string

	/** 是否生成菜单  */
	IsMenu bool

	/** 图标 */
	FunIcon string

	/** 序号 */
	Seq int

	/** 父功能 id */
	PId *string

	/** 父功能 */
	ParentFunction *Function `gorm:"foreignkey:PId;save_associations:false:" `

	/** 子功能 */
	ChildFunctions []*Function `gorm:"foreignkey:ID"`

	/** 对应的角色 */
	Roles []*Role `gorm:"many2many:role_functions;" json:"-"`

	/** 增删改的时间 */
	CrudTime
	// contains filtered or unexported fields
}

功能菜单结构体

func (*Function) BeforeCreate

func (function *Function) BeforeCreate(scope *gorm.Scope) error

插入前生成主键

type Role

type Role struct {

	/** 主键id */
	ID string `gorm:"type:varchar(36);primary_key" form:"id"`

	/** 角色名称 */
	RoleName string `gorm:"type:varchar(32);unique;not null" form:"role_name" binding:"required"`

	/** 角色类别标识 */
	RoleKey string `gorm:"type:varchar(16);not null"  form:"role_key" binding:"required"`

	/** 角色描述 */
	Description string `gorm:"type:varchar(128)" form:"description"`

	/** 角色关联的功能 */
	Functions []*Function `gorm:"many2many:role_functions;" json:"-"`

	/** 增删改的时间 */
	CrudTime
}

角色结构体

func (*Role) BeforeCreate

func (role *Role) BeforeCreate(scope *gorm.Scope) error

插入前生成主键

type User

type User struct {

	/** 主键 */
	ID string `gorm:"type:varchar(36);primary_key"`

	/** 姓名 */
	UserName string `gorm:"type:varchar(32);unique_index;not null" form:"username" binding:"required"`

	/** 密码  */
	Password string `gorm:"type:varchar(64);not null" json:"-" form:"password" binding:"required"`

	/** 电话 */
	Phone string `gorm:"type:varchar(11);unique" form:"phone" binding:"required"`

	/** 邮件 */
	Email string `gorm:"type:varchar(64)" form:"email" `

	/** 商户号 */
	MerchantNo string `gorm:"type:varchar(32)" form:"merchant_no" `

	/** 商户名称 */
	MerchantName string `gorm:"-"`

	/** 标志 1 表示这个账号是由管理方为商户添加的账号 */
	Flag int

	/** 登陆次数 */
	LogonCount int

	/** 状态  0 正常  */
	Status int

	/** 最后一次登陆时间 */
	LoginTime time.Time `gorm:"default:null"`

	/** 增删改的时间 */
	CrudTime

	/** 用户对应的角色 */
	Role *Role `gorm:"foreignkey:RoleId;save_associations:false:"`

	/** 外键 */
	RoleId *string `gorm:"type:varchar(36)" form:"role_id" `
}

func (*User) BeforeCreate

func (user *User) BeforeCreate(scope *gorm.Scope) error

插入前生成主键

func (*User) Validator

func (user *User) Validator() error

校验表单中提交的参数是否合法

Jump to

Keyboard shortcuts

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