builtinmodels

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateHashedPassword

func GenerateHashedPassword(userPassword string) (string, error)

GenerateHashedPassword 将根据输入密码生成哈希密码 用户的输入

func GeneratePassword

func GeneratePassword(userPassword string) ([]byte, error)

GeneratePassword 将根据输入密码生成哈希密码 用户的输入

func GetRBACModels

func GetRBACModels() []interface{}

GetRBACModels all RBAC related models

func InsertRecords

func InsertRecords(records []interface{}) (int64, error)

InsertRecords records

Types

type AccessLog

type AccessLog struct {
	ID                          int64  `xorm:"'id' BigInt pk autoincr" json:"id"`
	AppID                       string `xorm:"'app_id' VARCHAR(42) index" json:"appId"`                                          // 应用标识
	Module                      string `xorm:"'module' VARCHAR(64) notnull index" json:"module"`                                 // 模块分组
	Name                        string `xorm:"'name' VARCHAR(64) notnull index" json:"name"`                                     // 模块功能名称
	UserID                      string `xorm:"'user_id' VARCHAR(64) index" json:"userId"`                                        // 用户ID
	RequestID                   string `xorm:"'request_id' VARCHAR(64) index" json:"requestId"`                                  // 请求唯一标识
	CorrelationID               string `xorm:"'correlation_id' VARCHAR(64) index" json:"currelationId"`                          // 调用链唯一标识
	DeviceID                    string `xorm:"'device_id' VARCHAR(64) index" json:"deviceId"`                                    // 设备标识
	RemoteIP                    string `xorm:"'remote_ip' VARCHAR(64) index" json:"remoteIp"`                                    // 源IP
	Agent                       string `xorm:"'agent' VARCHAR(128)" json:"agent"`                                                // 源客户端信息
	Markup                      string `xorm:"'markup' VARCHAR(128)" json:"markup"`                                              // 访问界面元素标记
	Status                      int    `xorm:"'status' Int index" json:"status"`                                                 // 响应状态
	Message                     string `xorm:"'message' TEXT" json:"message"`                                                    // 响应提示
	Timestamp                   int64  `xorm:"'timestamp' BigInt index comment('Timestamp of event occorred')" json:"timestamp"` // 事件时间戳
	behaviors.ModifyingBehavior `xorm:"extends"`
	rdbms.Datasource            `xorm:"-" datasource:"default"`
}

AccessLog label element

func (*AccessLog) Count

func (m *AccessLog) Count() (int64, error)

Count record

func (*AccessLog) Delete

func (m *AccessLog) Delete() (int64, error)

Delete record

func (*AccessLog) Exists

func (m *AccessLog) Exists() (bool, error)

Exists by record

func (*AccessLog) Fetch

func (m *AccessLog) Fetch() (bool, error)

Fetch retrieve one record by self condition

func (*AccessLog) GetID

func (m *AccessLog) GetID() int64

GetID primary id

func (*AccessLog) InsertMany

func (m *AccessLog) InsertMany(records []interface{}) (int64, error)

InsertMany records

func (*AccessLog) LoadFromEvent

func (m *AccessLog) LoadFromEvent(event events.Event)

LoadFromEvent load record fields by event data

func (*AccessLog) NewRecord

func (m *AccessLog) NewRecord() AccessLogModel

NewRecord of access log model

func (*AccessLog) Save

func (m *AccessLog) Save() (bool, error)

Save record to database

func (*AccessLog) TableName

func (m *AccessLog) TableName() string

TableName table name

type AccessLogModel

type AccessLogModel interface {
	Save() (bool, error)
	LoadFromEvent(events.Event)
	NewRecord() AccessLogModel
}

AccessLogModel interface

type AsyncRecordSaver

type AsyncRecordSaver struct {
	// contains filtered or unexported fields
}

AsyncRecordSaver struct

func GetAsyncRecordSaver

func GetAsyncRecordSaver() *AsyncRecordSaver

GetAsyncRecordSaver AsyncRecordSaver

func (*AsyncRecordSaver) Push

func (m *AsyncRecordSaver) Push(log RecordModel) error

Push log

type Module

type Module struct {
	ID                          int64  `xorm:"'id' BigInt pk autoincr" json:"id" form:"id"`
	Code                        string `xorm:"'code' VARCHAR(45) notnull index" json:"code" form:"code"`
	Name                        string `xorm:"'name' VARCHAR(64) notnull index" json:"name" form:"name"`
	Path                        string `xorm:"'path' VARCHAR(128) notnull index" json:"path" form:"path"`
	SystemID                    string `xorm:"'system_id' VARCHAR(45) null index" json:"system_id" form:"system_id"`
	ParentID                    int64  `xorm:"'parent_id' BigInt index" json:"parent_id" form:"parent_id"`
	Icon                        string `xorm:"'icon' VARCHAR(45) null" json:"icon" form:"icon"`
	ViewOrder                   int    `xorm:"'view_order' Int default(1)" json:"view_order" form:"view_order"`
	Flag                        int    `xorm:"'flag' Int index" json:"flag" form:"flag"`
	Remark                      string `xorm:"'remark' VARCHAR(255) null" json:"remark" form:"remark"`
	behaviors.ModifyingBehavior `xorm:"extends"`
	rdbms.Datasource            `xorm:"-" datasource:"default"`
	Children                    []parameters.TreeDataInterface `xorm:"-" json:"children" form:"-"`
}

Module 内置RBAC-模块模型。

func FindAuthorizedModules

func FindAuthorizedModules(userID int64) ([]Module, error)

FindAuthorizedModules by user id

func (*Module) Count

func (m *Module) Count() (int64, error)

Count record

func (*Module) Delete

func (m *Module) Delete() (int64, error)

Delete record

func (*Module) Exists

func (m *Module) Exists() (bool, error)

Exists by record

func (*Module) Fetch

func (m *Module) Fetch() (bool, error)

Fetch retrieve one record by self condition

func (*Module) GetKey

func (m *Module) GetKey() interface{}

GetKey interface of tree node data

func (*Module) GetTitle

func (m *Module) GetTitle() string

GetTitle interface of tree node data

func (*Module) InsertMany

func (m *Module) InsertMany(records []interface{}) (int64, error)

InsertMany records

func (*Module) IsValid

func (m *Module) IsValid() bool

IsValid 可以做一些非常简单的“低级”数据验证

func (*Module) Save

func (m *Module) Save() (bool, error)

Save record to database

func (*Module) SetChildren

func (m *Module) SetChildren(children []parameters.TreeDataInterface)

SetChildren interface of tree node data

func (*Module) TableName

func (m *Module) TableName() string

TableName table name

type NameInfo

type NameInfo struct {
	ID   interface{} `json:"id" xorm:"'id'"`
	Name string      `json:"name" xorm:"'name' VARCHAR"`
}

type Oauths

type Oauths struct {
	ID                          int64  `xorm:"'id' BigInt pk autoincr" json:"id" form:"id"`
	UserID                      int64  `xorm:"'user_id' BigInt index" json:"user_id" form:"user_id"`
	OauthType                   string `xorm:"'oauth_type' VARCHAR(64) notnull index" json:"oauth_type" form:"oauth_type"`
	OauthID                     string `xorm:"'oauth_id' VARCHAR(64) null index" json:"oauth_id" form:"oauth_id"`
	UnionID                     string `xorm:"'union_id' VARCHAR(64) null index" json:"union_id" form:"union_id"`
	Credential                  string `xorm:"'credential' VARCHAR(64) null" json:"credential" form:"credential"`
	behaviors.ModifyingBehavior `xorm:"extends"`
	rdbms.Datasource            `xorm:"-" datasource:"default"`
}

Oauths 内置第三方登录授权模型。

func (*Oauths) Count

func (m *Oauths) Count() (int64, error)

Count record

func (*Oauths) Delete

func (m *Oauths) Delete() (int64, error)

Delete record

func (*Oauths) Exists

func (m *Oauths) Exists() (bool, error)

Exists by record

func (*Oauths) Fetch

func (m *Oauths) Fetch() (bool, error)

Fetch retrieve one record by self condition

func (*Oauths) GetID

func (m *Oauths) GetID() int64

GetID primary id

func (*Oauths) InsertMany

func (m *Oauths) InsertMany(records []interface{}) (int64, error)

InsertMany records

func (*Oauths) IsValid

func (m *Oauths) IsValid() bool

IsValid 可以做一些非常简单的“低级”数据验证

func (*Oauths) Save

func (m *Oauths) Save() (bool, error)

Save record to database

func (*Oauths) TableName

func (m *Oauths) TableName() string

TableName table name

type OperationLog

type OperationLog struct {
	ID                          int64  `xorm:"'id' BigInt pk autoincr" json:"id"`
	AppID                       string `xorm:"'app_id' VARCHAR(42) index" json:"appId"`                                          // 应用标识
	Module                      string `xorm:"'module' VARCHAR(64) notnull index" json:"module"`                                 // 模块分组
	Name                        string `xorm:"'name' VARCHAR(64) notnull index" json:"name"`                                     // 模块功能名称
	UserID                      string `xorm:"'user_id' VARCHAR(64) index" json:"userId"`                                        // 用户ID
	RequestID                   string `xorm:"'request_id' VARCHAR(64) index" json:"requestId"`                                  // 请求唯一标识
	CorrelationID               string `xorm:"'correlation_id' VARCHAR(64) index" json:"currelationId"`                          // 调用链唯一标识
	DeviceID                    string `xorm:"'device_id' VARCHAR(64) index" json:"deviceId"`                                    // 设备标识
	RemoteIP                    string `xorm:"'remote_ip' VARCHAR(64) index" json:"remoteIp"`                                    // 源IP
	Agent                       string `xorm:"'agent' VARCHAR(128)" json:"agent"`                                                // 源客户端信息
	Status                      int    `xorm:"'status' Int index" json:"status"`                                                 // 响应状态
	Message                     string `xorm:"'message' TEXT" json:"message"`                                                    // 响应提示
	Timestamp                   int64  `xorm:"'timestamp' BigInt index comment('Timestamp of event occorred')" json:"timestamp"` // 事件时间戳
	behaviors.ModifyingBehavior `xorm:"extends"`
	rdbms.Datasource            `xorm:"-" datasource:"default"`
}

OperationLog label element

func (*OperationLog) Count

func (m *OperationLog) Count() (int64, error)

Count record

func (*OperationLog) Delete

func (m *OperationLog) Delete() (int64, error)

Delete record

func (*OperationLog) Exists

func (m *OperationLog) Exists() (bool, error)

Exists by record

func (*OperationLog) Fetch

func (m *OperationLog) Fetch() (bool, error)

Fetch retrieve one record by self condition

func (*OperationLog) GetID

func (m *OperationLog) GetID() int64

GetID primary id

func (*OperationLog) InsertMany

func (m *OperationLog) InsertMany(records []interface{}) (int64, error)

InsertMany records

func (*OperationLog) LoadFromEvent

func (m *OperationLog) LoadFromEvent(event events.Event)

LoadFromEvent load record fields by event data

func (*OperationLog) NewRecord

func (m *OperationLog) NewRecord() OperationLogModel

NewRecord of access log model

func (*OperationLog) Save

func (m *OperationLog) Save() (bool, error)

Save record to database

func (*OperationLog) TableName

func (m *OperationLog) TableName() string

TableName table name

type OperationLogModel

type OperationLogModel interface {
	Save() (bool, error)
	LoadFromEvent(events.Event)
	NewRecord() OperationLogModel
}

OperationLogModel interface

type RecordModel

type RecordModel interface {
	Save() (bool, error)
}

RecordModel interface

type Role

type Role struct {
	ID                          int64  `xorm:"'id' BigInt pk autoincr" json:"id" form:"id"`
	Name                        string `xorm:"'name' VARCHAR(64) notnull index" json:"name" form:"name"`
	Code                        string `xorm:"'code' VARCHAR(45) notnull index" json:"code" form:"code"`
	AppID                       string `xorm:"'app_id' VARCHAR(45) null index" json:"app_id" form:"app_id"`
	SystemID                    string `xorm:"'system_id' VARCHAR(45) null index" json:"system_id" form:"system_id"`
	Avatar                      string `xorm:"'avatar' VARCHAR(64) null" json:"avatar" form:"avatar"`
	Remark                      string `xorm:"'remark' VARCHAR(255) null" json:"remark" form:"remark"`
	behaviors.ModifyingBehavior `xorm:"extends"`
	rdbms.Datasource            `xorm:"-" datasource:"default"`
	Modules                     []NameInfo `xorm:"-" json:"modules"`
}

Role 内置RBAC-角色模型。

func (*Role) Count

func (m *Role) Count() (int64, error)

Count record

func (*Role) Delete

func (m *Role) Delete() (int64, error)

Delete record

func (*Role) Exists

func (m *Role) Exists() (bool, error)

Exists by record

func (*Role) Fetch

func (m *Role) Fetch() (bool, error)

Fetch retrieve one record by self condition

func (*Role) GetID

func (m *Role) GetID() int64

GetID primary id

func (*Role) InsertMany

func (m *Role) InsertMany(records []interface{}) (int64, error)

InsertMany records

func (*Role) IsValid

func (m *Role) IsValid() bool

IsValid 可以做一些非常简单的“低级”数据验证

func (*Role) Save

func (m *Role) Save() (bool, error)

Save record to database

func (*Role) TableName

func (m *Role) TableName() string

TableName table name

type RoleModuleRelation

type RoleModuleRelation struct {
	ID                          int64  `xorm:"'id' BigInt pk autoincr" json:"id" form:"id"`
	ModuleID                    int64  `xorm:"'module_id' BigInt notnull index unique(uniq_role_module_idx)" json:"module_id" form:"module_id"`
	RoleID                      int64  `xorm:"'role_id' BigInt notnull index unique(uniq_role_module_idx)" json:"role_id" form:"role_id"`
	SystemID                    string `xorm:"'system_id' VARCHAR(45) null index" json:"system_id" form:"system_id"`
	behaviors.ModifyingBehavior `xorm:"extends"`
	rdbms.Datasource            `xorm:"-" datasource:"default"`
}

RoleModuleRelation 内置RBAC-角色与被授权模块关联图模型。

func (*RoleModuleRelation) Count

func (m *RoleModuleRelation) Count() (int64, error)

Count record

func (*RoleModuleRelation) Delete

func (m *RoleModuleRelation) Delete() (int64, error)

Delete record

func (*RoleModuleRelation) Exists

func (m *RoleModuleRelation) Exists() (bool, error)

Exists by record

func (*RoleModuleRelation) Fetch

func (m *RoleModuleRelation) Fetch() (bool, error)

Fetch retrieve one record by self condition

func (*RoleModuleRelation) InsertMany

func (m *RoleModuleRelation) InsertMany(records []interface{}) (int64, error)

InsertMany records

func (*RoleModuleRelation) IsValid

func (m *RoleModuleRelation) IsValid() bool

IsValid 可以做一些非常简单的“低级”数据验证

func (*RoleModuleRelation) Save

func (m *RoleModuleRelation) Save() (bool, error)

Save record to database

func (*RoleModuleRelation) TableName

func (m *RoleModuleRelation) TableName() string

TableName table name

type User

type User struct {
	ID                          int64  `xorm:"'id' BigInt pk autoincr" json:"id" form:"id"`
	Name                        string `xorm:"'name' VARCHAR(64) notnull index" json:"name" form:"name"`
	Telephone                   string `xorm:"'telephone' VARCHAR(64) null index" json:"telephone" form:"telephone"`
	Email                       string `xorm:"'email' VARCHAR(64) null index" json:"email" form:"email"`
	Avatar                      string `xorm:"'avatar' VARCHAR(64) null index" json:"avatar" form:"avatar"`
	HashedPassword              string `xorm:"'passwd_hash' VARCHAR(64)" json:"-" form:"-"`
	behaviors.ModifyingBehavior `xorm:"extends"`
	rdbms.Datasource            `xorm:"-" datasource:"default"`
	Roles                       []NameInfo `xorm:"-" json:"roles"`
}

User 内置用户模型

func (*User) Count

func (m *User) Count() (int64, error)

Count record

func (*User) Delete

func (m *User) Delete() (int64, error)

Delete record

func (*User) Exists

func (m *User) Exists() (bool, error)

Exists by record

func (*User) Fetch

func (m *User) Fetch() (bool, error)

Fetch retrieve one record by self condition

func (*User) FindByName

func (m *User) FindByName(name string) (UserModel, error)

FindByName of user model

func (*User) GetID

func (m *User) GetID() int64

GetID primary id

func (*User) GetName

func (m *User) GetName() string

GetName user name

func (*User) GetPasswordHash

func (m *User) GetPasswordHash() []byte

GetPasswordHash user password

func (*User) GetUserID

func (m *User) GetUserID() string

GetUserID primary id

func (*User) InsertMany

func (m *User) InsertMany(records []interface{}) (int64, error)

InsertMany records

func (*User) IsValid

func (m *User) IsValid() bool

IsValid 可以做一些非常简单的“低级”数据验证

func (*User) NewRecord

func (m *User) NewRecord(name string, passwordHash []byte) UserModel

NewRecord of user model

func (*User) Save

func (m *User) Save() (bool, error)

Save record to database

func (*User) SetName

func (m *User) SetName(name string)

SetName user name

func (*User) SetPasswordHash

func (m *User) SetPasswordHash(passwdHash []byte)

SetPasswordHash user password

func (*User) SetUserID

func (m *User) SetUserID(id string) error

SetUserID primary id

func (*User) TableName

func (m *User) TableName() string

TableName table name

func (*User) VerifyPassword

func (m *User) VerifyPassword(passwordOrHash string) bool

VerifyPassword to user password

type UserModel

type UserModel interface {
	GetUserID() string
	SetUserID(string) error
	GetName() string
	SetName(string)
	GetPasswordHash() []byte
	SetPasswordHash([]byte)
	Save() (bool, error)
	NewRecord(name string, passwordHash []byte) UserModel
	FindByName(name string) (UserModel, error)
	VerifyPassword(passwordOrHash string) bool
}

UserModel interface

type UserRoleRelation

type UserRoleRelation struct {
	ID                          int64  `xorm:"'id' BigInt pk autoincr" json:"id" form:"id"`
	RoleID                      int64  `xorm:"'role_id' BigInt notnull index unique(uniq_user_role_idx)" json:"role_id" form:"role_id"`
	UserID                      int64  `xorm:"'user_id' BigInt notnull index unique(uniq_user_role_idx)" json:"user_id" form:"user_id"`
	SystemID                    string `xorm:"'system_id' VARCHAR(45) null index" json:"system_id" form:"system_id"`
	behaviors.ModifyingBehavior `xorm:"extends"`
	rdbms.Datasource            `xorm:"-" datasource:"default"`
}

UserRoleRelation 内置RBAC-角色与被授权模块关联图模型。

func (*UserRoleRelation) Count

func (m *UserRoleRelation) Count() (int64, error)

Count record

func (*UserRoleRelation) Delete

func (m *UserRoleRelation) Delete() (int64, error)

Delete record

func (*UserRoleRelation) Exists

func (m *UserRoleRelation) Exists() (bool, error)

Exists by record

func (*UserRoleRelation) Fetch

func (m *UserRoleRelation) Fetch() (bool, error)

Fetch retrieve one record by self condition

func (*UserRoleRelation) InsertMany

func (m *UserRoleRelation) InsertMany(records []interface{}) (int64, error)

InsertMany records

func (*UserRoleRelation) IsValid

func (m *UserRoleRelation) IsValid() bool

IsValid 可以做一些非常简单的“低级”数据验证

func (*UserRoleRelation) Save

func (m *UserRoleRelation) Save() (bool, error)

Save record to database

func (*UserRoleRelation) TableName

func (m *UserRoleRelation) TableName() string

TableName table name

Jump to

Keyboard shortcuts

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