model

package
v0.0.0-...-7161ace Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultAdminUserAlias = "Administrator"

DefaultAdminUserAlias default admin user alias

View Source
const RoleAdmin = "admin"

RoleAdmin admin role

Variables

This section is empty.

Functions

func GetRegisterModels

func GetRegisterModels() map[string]Interface

GetRegisterModels will return the register models

func RegisterModel

func RegisterModel(models ...Interface)

RegisterModel register model

Types

type Article

type Article struct {
	BaseModel
	Slug           string   `json:"slug" gorm:"primaryKey"`
	Title          string   `json:"title"`
	Description    string   `json:"description"`
	Body           string   `json:"body"`
	TagList        []string `json:"tagList"`
	Favorited      bool     `json:"favorited"`
	FavoritesCount int      `json:"favoritesCount"`
}

func (*Article) Index

func (u *Article) Index() map[string]interface{}

Index return custom index

func (*Article) PrimaryKey

func (u *Article) PrimaryKey() string

PrimaryKey return custom primary key

func (*Article) ShortTableName

func (u *Article) ShortTableName() string

ShortTableName return custom table name

func (*Article) TableName

func (u *Article) TableName() string

TableName return custom table name

type BaseModel

type BaseModel struct {
	CreateTime time.Time `json:"createTime"`
	UpdateTime time.Time `json:"updateTime"`
}

BaseModel common model

func (*BaseModel) SetCreateTime

func (m *BaseModel) SetCreateTime(time time.Time)

SetCreateTime set create time

func (*BaseModel) SetUpdateTime

func (m *BaseModel) SetUpdateTime(time time.Time)

SetUpdateTime set update time

type CustomClaims

type CustomClaims struct {
	Email     string `json:"email"`
	GrantType string `json:"grantType"`
	jwt.RegisteredClaims
}

CustomClaims is the custom claims

type Interface

type Interface interface {
	TableName() string
	ShortTableName() string
}

Interface model interface

type Tag

type Tag struct {
	BaseModel
	Name string   `json:"name" gorm:"primaryKey"`
	Slug []string `json:"slug"`
}

func (*Tag) Index

func (u *Tag) Index() map[string]interface{}

Index return custom index

func (*Tag) PrimaryKey

func (u *Tag) PrimaryKey() string

PrimaryKey return custom primary key

func (*Tag) ShortTableName

func (u *Tag) ShortTableName() string

ShortTableName return custom table name

func (*Tag) TableName

func (u *Tag) TableName() string

TableName return custom table name

type User

type User struct {
	BaseModel
	Name     string `json:"username" gorm:"primaryKey"`
	Email    string `json:"email"`
	Password string `json:"password,omitempty"`
	Bio      string `json:"bio"`
	Image    string `json:"image"`
}

Article is the model of user

func (*User) Index

func (u *User) Index() map[string]interface{}

Index return custom index

func (*User) PrimaryKey

func (u *User) PrimaryKey() string

PrimaryKey return custom primary key

func (*User) ShortTableName

func (u *User) ShortTableName() string

ShortTableName return custom table name

func (*User) TableName

func (u *User) TableName() string

TableName return custom table name

type UserArticle

type UserArticle struct {
	BaseModel
	UserName string `json:"username" `
	Slug     string `json:"slug"`
}

func (*UserArticle) Index

func (u *UserArticle) Index() map[string]interface{}

Index return custom index

func (*UserArticle) PrimaryKey

func (u *UserArticle) PrimaryKey() string

PrimaryKey return custom primary key

func (*UserArticle) ShortTableName

func (u *UserArticle) ShortTableName() string

ShortTableName return custom table name

func (*UserArticle) TableName

func (u *UserArticle) TableName() string

TableName return custom table name

Jump to

Keyboard shortcuts

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