model

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AutoModel

type AutoModel struct {
	ID           int64      `json:"key,string"  gorm:"primary_key;"`
	CreatedTime  *time.Time `json:"created_time" `
	CreateUser   *User      `json:"create_user"`
	CreateUserID int64      `json:"create_user_id,string"`
	UpdatedTime  *time.Time `json:"updated_time" `
	UpdateUser   *User      `json:"update_user"`
	UpdateUserID int64      `json:"update_user_id,string"`
	DeletedTime  *time.Time `json:"deleted_time" `
	DeleteUser   *User      `json:"delete_user"`
	DeleteUserID int64      `json:"delete_user_id,string"`
}

AutoModel with id auto increment

type Changelog

type Changelog struct {
	Logmodel
	Resource    string `json:"resource"  gorm:"type:varchar(50);not null;default:''"`     // resource name
	ResourceKey string `json:"resource_key"  gorm:"type:varchar(50);not null;default:''"` // resource key
	DVersion    string `json:"d_version" gorm:"type:varchar(50);not null;default:''"`     // current change d version
	Type        string `json:"type"  gorm:"type:varchar(50);not null;default:''"`         // operation type create , update , delete
	Column      string `json:"column"  gorm:"type:varchar(50);not null;default:''"`
	OldValue    string `json:"old_value"  gorm:"type:varchar(200);not null;default:''"` // old value before change
	NewValue    string `json:"new_value"  gorm:"type:varchar(200);not null;default:''"` // new value after change
	TraceID     string `json:"trace_id"  gorm:"type:varchar(50);not null;"`
}

Changelog model Error

type DeleteParam added in v0.0.38

type DeleteParam struct {
	Key      int64  `json:"key,string" binding:"required"`
	DVersion string `json:"d_version" binding:"required"`
}

DeleteParam delete param , used for get deleted body

type Error

type Error struct {
	Logmodel
	TraceID  string `json:"trace_id"  gorm:"type:varchar(50);index;not null;"` //http seq number
	File     string `json:"file"  `
	Line     string `json:"line"  gorm:"type:varchar(50);"`
	FuncName string `json:"func_name"`
	Error    string `json:"error" `
}

Error model Error

type Group

type Group struct {
	Model
	Name        string       `json:"name" gorm:"type:varchar(50);unique;not null;"`
	Description string       `json:"description" gorm:"type:varchar(100);not null;default:''"`
	Permissions []Permission `json:"permissions" gorm:"many2many:group_permissions;"`
	PGroup      *Group       `json:"p_group"`
	PID         int64        `json:"p_id,string"`
	Roles       []Role       `json:"roles" gorm:"many2many:group_roles;"`
}

Group model Group

type Logmodel

type Logmodel struct {
	ID           int64      `json:"key,string"  gorm:"primary_key;AUTO_INCREMENT:false"`
	CreatedTime  *time.Time `json:"created_time" `
	CreateUser   *User      `json:"create_user"`
	CreateUserID int64      `json:"create_user_id,string" `
}

Logmodel common type

type Model

type Model struct {
	ID           int64      `json:"key,string"  gorm:"primary_key;AUTO_INCREMENT:false" mapstructure:"key"`
	CreatedTime  *time.Time `json:"created_time" `
	CreateUser   *User      `json:"create_user" `
	CreateUserID int64      `json:"create_user_id,string" `
	UpdatedTime  *time.Time `json:"updated_time"`
	UpdateUser   *User      `json:"update_user"`
	UpdateUserID int64      `json:"update_user_id,string" `
	DeletedTime  *time.Time `json:"deleted_time"`
	DeleteUser   *User      `json:"delete_user"`
	DeleteUserID int64      `json:"delete_user_id,string" `
	DVersion     string     `json:"d_version"`
}

Model common type

type Permission

type Permission struct {
	Model
	Code string `json:"code" gorm:"type:varchar(100);index;unique;not null;"`
	Name string `json:"name" gorm:"type:varchar(100);not null;default:''"`
}

Permission model Role

type Role

type Role struct {
	Model
	Name        string       `json:"name" gorm:"type:varchar(50);index;unique;not null;"`
	Description string       `json:"description" gorm:"type:varchar(100);not null;default:''"`
	Permissions []Permission `json:"permissions" gorm:"many2many:role_permissions;"`
}

Role model Role

type Simpmodel

type Simpmodel struct {
	ID          int64      `json:"key,string"  gorm:"primary_key;AUTO_INCREMENT:false"`
	CreatedTime *time.Time `json:"created_time" `
}

Simpmodel common type

type User

type User struct {
	Model
	UserName           string       `json:"user_name" gorm:"type:varchar(50);index;not null;"`            // login username /profile
	NameLocal          string       `json:"name_local"  gorm:"type:varchar(50);" `                        // local name
	NameEN             string       `json:"name_en"  gorm:"type:varchar(50);" `                           // EN name
	Email              string       `json:"email"  gorm:"type:varchar(50);" `                             // login email
	Phone              string       `json:"phone" gorm:"type:varchar(50);" `                              // login phone
	Groups             []Group      `json:"groups" gorm:"many2many:user_groups;"`                         // foreign key -->group
	Permissions        []Permission `json:"permissions" gorm:"many2many:user_permissions;"`               // foreign key --->permission
	PreferenceLanguage string       `json:"preference_language" gorm:"type:varchar(50);default:'en-US'" ` // user preference language

}

User model User

type Viewmodel

type Viewmodel struct {
	ID           int64      `json:"key,string"  gorm:"primary_key;AUTO_INCREMENT:false"`
	CreatedTime  *time.Time `json:"created_time" `
	CreateUser   *User      `json:"create_user"`
	CreateUserID int64      `json:"create_user_id,string"`
	UpdatedTime  *time.Time `json:"updated_time" `
	UpdateUser   *User      `json:"update_user"`
	UpdateUserID int64      `json:"update_user_id,string"`
	DeletedTime  *time.Time `json:"deleted_time" `
	DeleteUser   *User      `json:"delete_user"`
	DeleteUserID int64      `json:"delete_user_id,string"`
}

Viewmodel for view type

Jump to

Keyboard shortcuts

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