model

package
v0.0.0-...-e6fd437 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PasswordMinLength = 8
	PasswordMaxLength = 16
)

Variables

This section is empty.

Functions

func InitOpTypeData

func InitOpTypeData(db *gorm.DB) error

Types

type AuthPermission

type AuthPermission struct {
	Id         int       `gorm:"primaryKey;AUTO_INCREMENT;column:id;" json:"id"`
	AuthCode   string    `gorm:"index:idx_code,unique;column:auth_code;type:varchar(128);not null;" json:"auth_code"`
	AuthName   string    `gorm:"column:auth_name;type:varchar(128);not null;" json:"auth_name"`
	AuthType   *int      `gorm:"column:auth_type;type:int(5);default:0;not null;" json:"auth_type"` // 0. backend api auth 1. front auth
	URI        string    `gorm:"column:uri;type:varchar(200);" json:"uri"`
	Method     string    `gorm:"column:method;type:varchar(10);" json:"method"`
	Group      string    `gorm:"column:group;type:varchar(128);" json:"group"`
	IsLogin    bool      `gorm:"column:is_login;type:tinyint(1);default:false;not null" json:"is_login"`
	IsCheck    bool      `gorm:"column:is_check;type:tinyint(1);default:false;not null" json:"is_check"`
	CreateTime time.Time `gorm:"column:create_time;not null;autoCreateTime;type:datetime" json:"createTime"`
	UpdateTime time.Time `gorm:"column:update_time;not null;autoUpdateTime;type:datetime" json:"updateTime"`
}

func (*AuthPermission) Create

func (p *AuthPermission) Create() error

func (*AuthPermission) Delete

func (p *AuthPermission) Delete(ids []int) error

func (*AuthPermission) Find

func (*AuthPermission) IsValid

func (p *AuthPermission) IsValid() error

func (*AuthPermission) Update

func (p *AuthPermission) Update() error

type AuthRole

type AuthRole struct {
	Id          int       `gorm:"primaryKey;AUTO_INCREMENT;column:id;" json:"id"`
	RoleCode    string    `gorm:"index:idx_code,unique;column:role_code;type:varchar(128);not null;" json:"role_code"`
	RoleName    string    `gorm:"index:idx_name,unique;column:role_name;type:varchar(128);not null" json:"role_name"`
	MaxVolCount int       `gorm:"column:max_vol_count;type:int;" json:"max_vol_count"`
	MaxVolSize  int       `gorm:"column:max_vol_size;type:int;" json:"max_vol_size"`
	CreateTime  time.Time `gorm:"column:create_time;not null;autoCreateTime;type:datetime" json:"createTime"`
	UpdateTime  time.Time `gorm:"column:update_time;not null;autoUpdateTime;type:datetime" json:"updateTime"`
}

func (*AuthRole) Create

func (r *AuthRole) Create(permissionIds []int) error

func (*AuthRole) Delete

func (r *AuthRole) Delete(ids []int) error

func (*AuthRole) Find

func (r *AuthRole) Find(param *FindAuthRoleParam) ([]AuthRoleVo, int, error)

func (*AuthRole) IsValid

func (r *AuthRole) IsValid() error

func (*AuthRole) Update

func (r *AuthRole) Update(permissionIds []int) error

type AuthRolePermission

type AuthRolePermission struct {
	Id           int `gorm:"primaryKey;AUTO_INCREMENT;column:id;" json:"id"`
	RoleId       int `gorm:"index:idx_role_permission,unique;column:role_id;type:int;not null;" json:"role_id"`
	PermissionId int `gorm:"index:idx_role_permission,unique;column:permission_id;type:int;not null;" json:"permission_id"`
}

type AuthRoleVo

type AuthRoleVo struct {
	AuthRole
	Permissions []AuthPermission `json:"permissions"`
}

type AuthUser

type AuthUser struct {
	Id         int       `gorm:"primaryKey;AUTO_INCREMENT;column:id;" json:"id"`
	UserName   string    `gorm:"index:idx_name,unique;column:user_name;type:varchar(32);not null;" json:"user_name"`
	Password   string    `gorm:"column:password;type:varchar(128);not null" json:"password"`
	Email      string    `gorm:"index:idx_email,unique;column:email;type:varchar(128);not null" json:"email"`
	Phone      string    `gorm:"index:idx_phone,unique;column:phone;type:varchar(11);not null" json:"phone"`
	CreateTime time.Time `gorm:"column:create_time;not null;autoCreateTime;type:datetime" json:"createTime"`
	UpdateTime time.Time `gorm:"column:update_time;not null;autoUpdateTime;type:datetime" json:"updateTime"`
}

func (*AuthUser) Create

func (u *AuthUser) Create(roleIds []int) error

func (*AuthUser) Delete

func (u *AuthUser) Delete(ids []int) error

func (*AuthUser) Find

func (u *AuthUser) Find(param *FindAuthUserParam) ([]AuthUserVo, int, error)

func (*AuthUser) IsValid

func (u *AuthUser) IsValid() error

func (*AuthUser) Update

func (u *AuthUser) Update(roleIds []int) error

func (*AuthUser) UpdatePassword

func (u *AuthUser) UpdatePassword() error

type AuthUserRole

type AuthUserRole struct {
	Id     int `gorm:"primaryKey;AUTO_INCREMENT;column:id;" json:"id"`
	UserId int `gorm:"index:idx_user_role,unique;column:user_id;type:int;not null;" json:"user_id"`
	RoleId int `gorm:"index:idx_user_role,unique;column:role_id;type:int;not null;" json:"role_id"`
}

type AuthUserVo

type AuthUserVo struct {
	AuthUser
	Password *struct{}  `json:"password,omitempty"`
	Roles    []AuthRole `json:"roles"`
}

type Cluster

type Cluster struct {
	Id         int64          `gorm:"primaryKey;auto_increment" json:"id"`
	Name       string         `gorm:"type:varchar(100);not null;default:'';index" json:"name"`
	MasterAddr types.StrSlice `gorm:"type:varchar(1024);not null;default:'[]'" json:"master_addr"`
	IDC        string         `gorm:"column:idc;type:varchar(255);not null;default:''" json:"idc"`
	Cli        string         `gorm:"type:varchar(255);not null;default:''" json:"cli"`
	Domain     string         `gorm:"type:varchar(255);not null;default:''" json:"domain"`
	ConsulAddr string         `gorm:"type:varchar(255);not null;default:''" json:"consul_addr"`
	Tag        string         `gorm:"type:varchar(255);not null;default:'';index" json:"tag"`
	S3Endpoint string         `gorm:"column:s3_endpoint;type:varchar(255);not null;default:''" json:"s3_endpoint"`
	VolType    enums.VolType  `gorm:"type:tinyint(1);not null;default:0" json:"vol_type"`
	CreateTime time.Time      `gorm:"create_time" json:"create_time"`
	UpdateTime time.Time      `gorm:"update_time" json:"update_time"`
}

func (*Cluster) Create

func (c *Cluster) Create() error

func (*Cluster) Find

func (c *Cluster) Find(param FindClusterParam) ([]Cluster, int64, error)

func (*Cluster) FindAll

func (c *Cluster) FindAll(name string) ([]Cluster, error)

func (*Cluster) FindId

func (c *Cluster) FindId(id int64) error

func (*Cluster) FindName

func (c *Cluster) FindName(name string) (*Cluster, error)

FindName find cluster by name. Does this need to be cached ?

func (*Cluster) FindTag

func (c *Cluster) FindTag(tag string) (*Cluster, error)

func (*Cluster) Update

func (c *Cluster) Update(id int64, set map[string]interface{}) error

type FindAuthPermissionParam

type FindAuthPermissionParam struct {
	Page         int    `form:"page"`
	PageSize     int    `form:"page_size"`
	Ids          []int  `form:"ids"`
	AuthCodeLike string `form:"auth_code_like"`
	AuthNameLike string `form:"auth_name_like"`
}

type FindAuthRoleParam

type FindAuthRoleParam struct {
	Page         int    `form:"page"`
	PageSize     int    `form:"page_size"`
	Ids          []int  `form:"ids"`
	RoleCodeLike string `form:"role_code_like"`
	RoleNameLike string `form:"role_name_like"`
}

type FindAuthUserParam

type FindAuthUserParam struct {
	IsAll        bool   `form:"is_all"`
	Page         int    `form:"page"`
	PageSize     int    `form:"page_size"`
	UserNameLike string `form:"user_name_like"`
	EmailLike    string `form:"email_like"`
	PhoneLike    string `form:"phone_like"`
}

type FindClusterParam

type FindClusterParam struct {
	Page    int    `form:"page"`
	PerPage int    `form:"per_page"`
	Name    string `form:"name"`
	VolType *int   `form:"vol_type"`
}

type FindOpLogParam

type FindOpLogParam struct {
	Page     int `form:"page"`
	PerPage  int `form:"per_page"`
	OpTypeId int `form:"op_type_id"`
	UserId   int `form:"user_id"`
}

func (*FindOpLogParam) Check

func (p *FindOpLogParam) Check() error

type FindVolsParam

type FindVolsParam struct {
	Owner   string `form:"owner" binding:"required"`
	Page    int    `form:"page"`
	PerPage int    `form:"per_page"`
}

func (*FindVolsParam) Check

func (p *FindVolsParam) Check() error

type NodeConfig

type NodeConfig struct {
	Id            int64        `gorm:"primaryKey" json:"id"`
	Node          string       `gorm:"type:varchar(255);index;not null;default:''" json:"node"`
	Cluster       string       `gorm:"type:varchar(255);not null;default:''" json:"cluster"`
	Configuration types.MapStr `gorm:"type:varchar(2048);not null;default:'{}'" json:"configuration"`
	UpdatedAt     time.Time    `json:"updated_at"`
}

func (*NodeConfig) One

func (e *NodeConfig) One(node, cluster string) error

func (*NodeConfig) Upsert

func (e *NodeConfig) Upsert(node, cluster, key, value string) error

type NodeConfigFailure

type NodeConfigFailure struct {
	Id           int64     `gorm:"primaryKey" json:"id"`
	Node         string    `gorm:"type:varchar(255);not null;default:''" json:"node"`
	Cluster      string    `gorm:"type:varchar(255);not null;default:''" json:"cluster"`
	Key          string    `gorm:"type:varchar(255);not null;default:''" json:"key"`
	Value        string    `gorm:"type:varchar(255);not null;default:''" json:"value"`
	FailedReason string    `gorm:"type:varchar(255);not null;default:''"  json:"failed_reason"`
	CreatedAt    time.Time `json:"created_at"`
}

func (*NodeConfigFailure) Insert

func (e *NodeConfigFailure) Insert() error

func (*NodeConfigFailure) One

func (e *NodeConfigFailure) One(node, cluster string) error

type OpType

type OpType struct {
	Id         int       `gorm:"primaryKey" json:"id"`
	NameEN     string    `gorm:"type:varchar(100);not null;default:''" json:"name_en"`
	NameCN     string    `gorm:"type:varchar(100);not null;default:''" json:"name_cn"`
	URI        string    `gorm:"type:varchar(200);uniqueIndex:idx_uri_method;not null;default:''" json:"uri"`
	Method     string    `gorm:"type:varchar(10);uniqueIndex:idx_uri_method;not null;default:''" json:"method"`
	Record     bool      `gorm:"not null;default:0" json:"record"`
	CreateTime time.Time `gorm:"not null;default:CURRENT_TIMESTAMP(3)" json:"create_time"`
	UpdateTime time.Time `gorm:"not null;default:CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" json:"update_time"`
}

func (*OpType) Create

func (o *OpType) Create() error

func (*OpType) Find

func (o *OpType) Find(record *bool) ([]OpType, error)

func (*OpType) FindByUniqKey

func (o *OpType) FindByUniqKey(uri, method string) (*OpType, error)

func (*OpType) UpdateId

func (o *OpType) UpdateId(param *OpTypeUpdateParam) error

type OpTypeUpdateParam

type OpTypeUpdateParam struct {
	Id     int    `gorm:"-" json:"id" binding:"required"`
	NameEN string `json:"name_en"`
	NameCN string `json:"name_cn"`
	Record *bool  `json:"record"`
}

type OperationLog

type OperationLog struct {
	Id          uint64       `gorm:"primaryKey" json:"id"`
	Service     string       `gorm:"type:varchar(20);not null;default:''" json:"service"` // blobstore/cubefs
	Cluster     string       `gorm:"type:varchar(255);index;not null;default:''" json:"cluster"`
	UserId      int          `gorm:"index;not null;default:0" json:"user_id"`
	UserName    string       `gorm:"type:varchar(50);not null;default:''" json:"user_name"`
	OpTypeId    int          `gorm:"index;not null;default:0" json:"op_type_id"`
	OpTypeEN    string       `gorm:"type:varchar(100);not null;default:''" json:"op_type_en"`
	OpTypeCN    string       `gorm:"type:varchar(100);not null;default:''" json:"op_type_cn"`
	URI         string       `gorm:"type:varchar(200);not null;default:''" json:"uri"`
	Method      string       `gorm:"type:varchar(10);not null;default:''" json:"method"`
	QueryParams types.Values `gorm:"type:varchar(1024);not null;default:''" json:"query_params"`
	BodyParams  types.Map    `gorm:"type:varchar(1024);not null;default:''" json:"body_params"`
	Result      types.Map    `gorm:"type:varchar(500);not null;default:''" json:"result"`
	CreateTime  time.Time    `gorm:"primaryKey" json:"create_time"`
}

func (*OperationLog) Create

func (o *OperationLog) Create() error

func (*OperationLog) Find

func (o *OperationLog) Find(param *FindOpLogParam) ([]OperationLog, int64, error)

type User

type User struct {
	Id         uint64           `gorm:"primaryKey" json:"id"`
	Name       string           `gorm:"type:varchar(50);not null;default:'';uniqueIndex" json:"name"`
	Role       int              `gorm:"type:tinyint(4);not null;default:3" json:"role"`
	AccessKey  types.EncryptStr `gorm:"type:varchar(500);not null;default:''" json:"access_key"`
	SecretKey  types.EncryptStr `gorm:"type:varchar(500);not null;default:''" json:"secret_key"`
	CreatorId  int              `gorm:"not null;default:0;index" json:"creator_id"`
	CreateTime time.Time        `gorm:"not null;default:CURRENT_TIMESTAMP(3)" json:"create_time"`
}

func (*User) Create

func (u *User) Create() error

type Vol

type Vol struct {
	Id              uint64    `gorm:"primaryKey" json:"id"`
	Name            string    `gorm:"type:varchar(100);not null;default:'';index" json:"name"`
	Owner           string    `gorm:"type:varchar(50);not null;default:'';index" json:"owner"`
	Capacity        uint64    `gorm:"not null;default:0" json:"capacity"`
	CacheCap        int       `gorm:"not null;default:0" json:"cache_cap"`
	CrossZone       bool      `gorm:"not null;default:0" json:"cross_zone"`
	Business        string    `gorm:"type:varchar(200);not null;default:''" json:"business"`
	DefaultPriority bool      `gorm:"not null;default:0" json:"default_priority"`
	ReplicaNumber   int       `gorm:"type:tinyint(4);not null;default:0" json:"replica_number"`
	VolType         int       `gorm:"type:tinyint(1);not null;default:0" json:"vol_type"`
	CreatorId       int       `gorm:"not null;default:0;index" json:"creator_id"`
	CreateTime      time.Time `gorm:"not null;default:CURRENT_TIMESTAMP(3)" json:"create_time"`
}

func (*Vol) Create

func (v *Vol) Create() error

func (*Vol) Find

func (v *Vol) Find(param *FindVolsParam) ([]Vol, int64, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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