Role.go 835 字节
Newer Older
MELF晓宇's avatar
MELF晓宇 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
/**
 * @Time    :2021/11/12 14:18
 * @Author  :MELF晓宇
 * @Email   :xyzh.melf@petalmail.com
 * @FileName:Role.go
 * @Project :gin-start
 * @Blog    :https://blog.csdn.net/qq_29537269
 * @Guide   :https://guide.melf.space
 * @Information:
 *
 */

package models

import (
	"gin-start/pkg/ID"
	"gorm.io/gorm"
	"time"
)

type Role struct {
	ID        int64          `gorm:"primaryKey;comment:角色ID"`
	CreatedAt time.Time      `gorm:"comment:创建时间"`
	UpdatedAt time.Time      `gorm:"comment:更新时间"`
	DeletedAt gorm.DeletedAt `gorm:"index;comment:删除时间"`
	RoleName  string         `gorm:"type:varchar(20);not null;comment:角色名称"`
}

func (role *Role) BeforeCreate(tx *gorm.DB) (err error) {
	role.ID = ID.CreateId()
	return
}

// TableName 自定义表名
func (Role) TableName() string {
	return "role"
}