model

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const TableNameCasbinRuleM = "casbin_rule"
View Source
const TableNamePostM = "post"
View Source
const TableNameUserM = "user"

Variables

This section is empty.

Functions

This section is empty.

Types

type CasbinRuleM

type CasbinRuleM struct {
	ID    int64   `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"`
	PType *string `gorm:"column:ptype" json:"ptype"`
	V0    *string `gorm:"column:v0" json:"v0"`
	V1    *string `gorm:"column:v1" json:"v1"`
	V2    *string `gorm:"column:v2" json:"v2"`
	V3    *string `gorm:"column:v3" json:"v3"`
	V4    *string `gorm:"column:v4" json:"v4"`
	V5    *string `gorm:"column:v5" json:"v5"`
}

CasbinRuleM mapped from table <casbin_rule>

func (*CasbinRuleM) TableName

func (*CasbinRuleM) TableName() string

TableName CasbinRuleM's table name

type PostM

type PostM struct {
	ID        int64     `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"`
	UserID    string    `gorm:"column:userID;not null;comment:用户唯一 ID" json:"userID"`                                  // 用户唯一 ID
	PostID    string    `gorm:"column:postID;not null;uniqueIndex:idx_post_postID;comment:博文唯一 ID" json:"postID"`      // 博文唯一 ID
	Title     string    `gorm:"column:title;not null;comment:博文标题" json:"title"`                                       // 博文标题
	Content   string    `gorm:"column:content;not null;comment:博文内容" json:"content"`                                   // 博文内容
	CreatedAt time.Time `gorm:"column:createdAt;not null;default:current_timestamp;comment:博文创建时间" json:"createdAt"`   // 博文创建时间
	UpdatedAt time.Time `gorm:"column:updatedAt;not null;default:current_timestamp;comment:博文最后修改时间" json:"updatedAt"` // 博文最后修改时间
}

PostM mapped from table <post>

func (*PostM) AfterCreate

func (m *PostM) AfterCreate(tx *gorm.DB) error

AfterCreate 在创建数据库记录之后生成 postID.

func (*PostM) TableName

func (*PostM) TableName() string

TableName PostM's table name

type UserM

type UserM struct {
	ID        int64     `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"`
	UserID    string    `gorm:"column:userID;not null;uniqueIndex:idx_user_userID;comment:用户唯一 ID" json:"userID"`       // 用户唯一 ID
	Username  string    `gorm:"column:username;not null;uniqueIndex:idx_user_username;comment:用户名(唯一)" json:"username"` // 用户名(唯一)
	Password  string    `gorm:"column:password;not null;comment:用户密码(加密后)" json:"password"`                             // 用户密码(加密后)
	Nickname  string    `gorm:"column:nickname;not null;comment:用户昵称" json:"nickname"`                                  // 用户昵称
	Email     string    `gorm:"column:email;not null;comment:用户电子邮箱地址" json:"email"`                                    // 用户电子邮箱地址
	Phone     string    `gorm:"column:phone;not null;uniqueIndex:idx_user_phone;comment:用户手机号" json:"phone"`            // 用户手机号
	CreatedAt time.Time `gorm:"column:createdAt;not null;default:current_timestamp;comment:用户创建时间" json:"createdAt"`    // 用户创建时间
	UpdatedAt time.Time `gorm:"column:updatedAt;not null;default:current_timestamp;comment:用户最后修改时间" json:"updatedAt"`  // 用户最后修改时间
}

UserM mapped from table <user>

func (*UserM) AfterCreate

func (m *UserM) AfterCreate(tx *gorm.DB) error

AfterCreate 在创建数据库记录之后生成 userID.

func (*UserM) BeforeCreate

func (m *UserM) BeforeCreate(tx *gorm.DB) error

BeforeCreate 在创建数据库记录之前加密明文密码.

func (*UserM) TableName

func (*UserM) TableName() string

TableName UserM's table name

Jump to

Keyboard shortcuts

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