entity

package
v0.0.0-...-7c9259c Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActivateEmailTemplatePath = "./views/activate.mailer.tmpl"
)

Variables

View Source
var ErrSessionNotFound = errors.New("not found")

Functions

This section is empty.

Types

type Base

type Base struct {
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

Base 基础模型,公共模型

type Permission

type Permission struct {
	ID          uint    `gorm:"primaryKey"`
	Code        string  `gorm:"type:varchar(64);uniqueIndex;not null"`
	Name        string  `gorm:"type:varchar(64);not null"`
	Description *string `gorm:"type:varchar(256)"`
	*Base
}

Permission 权限表结构

func (Permission) ToDto

func (p Permission) ToDto() *dto.PermissionResponse

type Role

type Role struct {
	ID          uint          `gorm:"primaryKey"`
	Code        string        `gorm:"type:varchar(64);uniqueIndex;not null"`
	Name        string        `gorm:"type:varchar(64);not null"`
	Description string        `gorm:"type:varchar(256)"`
	Permissions []*Permission `gorm:"many2many:role_permissions"`
	*Base
}

Role 角色表结构

func (*Role) ToDto

func (r *Role) ToDto() *dto.RoleResponse

type Session

type Session struct {
	// token id
	TID string `redis:"tid" json:"tid"`
	// 用户 id
	UID          uint   `redis:"uid" json:"uid"`
	RefreshToken string `redis:"refresh_token" json:"refresh_token"`
	// 设置 redis 不扫描,以字符串格式存储
	ExpiresAt time.Time `redis:"_" json:"expires_at"`
	CreatedAt time.Time `redis:"_" json:"created_at"`
	UserAgent string    `redis:"user_agent" json:"user_agent"`
	ClientIP  string    `redis:"client_ip" json:"client_ip"`
}

Session 登录 Session

type User

type User struct {
	ID          uint    `gorm:"primaryKey"`
	Name        string  `gorm:"type:varchar(16);not null"`
	Email       string  `gorm:"type:varchar(255);uniqueIndex;not null"`
	Password    string  `gorm:"type:varchar(64);not null;"`
	Avatar      *string `gorm:"type:varchar(255)"`
	ActivatedAt *time.Time
	VerifyCode  *string `gorm:"type:varchar(255);comment '注册时激活账号发送邮件的签名'"`
	Roles       []*Role `gorm:"many2many:user_roles"`
	*Base
}

User 用户表结构

func (*User) ComparePassword

func (u *User) ComparePassword(password string) error

func (*User) Count

func (user *User) Count(db *gorm.DB) int64

func (*User) SetActivateEmailMessage

func (user *User) SetActivateEmailMessage(activateEmailURL string) (string, error)

func (*User) SetPassword

func (u *User) SetPassword(password string)

func (*User) ToDto

func (u *User) ToDto() *dto.UserResponse

Jump to

Keyboard shortcuts

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