model

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2017 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	USER_STATUS_UN_ACTIVE = iota
	USER_STATUS_NORMAL
	USER_STATUS_FORBIDDEN
)

Variables

View Source
var (
	ErrDataNotExist     = errors.New("Data does not exist")
	ErrDataAlreadyExist = errors.New("Data already exist")
)
View Source
var (
	HasEngine bool

	EnableSQLite3 bool
	EnableTiDB    bool
)

Functions

func DumpDatabase

func DumpDatabase(filePath string) error

DumpDatabase dumps all data from database to file system.

func InitDBConfig

func InitDBConfig(config *DbCfg)

func ModelCreate

func ModelCreate(engine Engine, model ModelProtocol) error

func ModelGet

func ModelGet(id uint64, model ModelProtocol) (bool, error)

func ModelUpdate

func ModelUpdate(engine Engine, id uint64, model ModelProtocol, specFields ...string) error

func NewEngine

func NewEngine() (err error)

func NewMailerUser

func NewMailerUser(u *User, activeCodeLives int) mailer.User

func NewTestEngine

func NewTestEngine(x *xorm.Engine) (err error)

func Ping

func Ping() error

func QueryUsers added in v0.1.1

func QueryUsers(currentUserID uint64, pageIndex, pageCount int, email string) (*dto.Pager, error)

func SetEngine

func SetEngine() (err error)

func Transaction

func Transaction(action func(sess *xorm.Session) (interface{}, error)) (interface{}, error)

Types

type App

type App struct {
	ID        uint64    `xorm:"pk autoincr"`
	Name      string    `xorm:"unique index notnull"`
	UID       uint64    `xorm:"notnull default(0)"`
	CreatedAt time.Time `xorm:"created"`
	UpdatedAt time.Time `xorm:"updated"`
	DeletedAt time.Time `xorm:"deleted"`
}

func FindAppsByIDs

func FindAppsByIDs(ids []uint64) ([]*App, error)

func (*App) Collaborators

func (self *App) Collaborators() ([]*Collaborator, error)

func (*App) Create

func (self *App) Create(engine Engine) error

func (*App) Delete

func (self *App) Delete(engine Engine) error

func (*App) Deployments

func (self *App) Deployments() ([]*Deployment, error)

func (*App) Exist

func (self *App) Exist() (bool, error)

func (*App) Get

func (self *App) Get() (bool, error)

func (*App) Update

func (self *App) Update(engine Engine, specFields ...string) error

type Collaborator

type Collaborator struct {
	ID        uint64    `xorm:"pk autoincr"`
	Role      int8      `xorm:"notnull default(0)"`
	UID       uint64    `xorm:"index notnull default(0)"`
	AppID     uint64    `xorm:"index notnull default(0)"`
	Email     string    `xorm:"index notnull"`
	CreatedAt time.Time `xorm:"created"`
	UpdatedAt time.Time `xorm:"updated"`
	DeletedAt time.Time `xorm:"deleted"`
}

func FindCollaboratorByAppNameAndUID

func FindCollaboratorByAppNameAndUID(appName string, uid uint64) (*Collaborator, error)

func FindCollaboratorsByAppIDs

func FindCollaboratorsByAppIDs(appIds []uint64) ([]*Collaborator, error)

func FindOwnerByAppName

func FindOwnerByAppName(appName string) (*Collaborator, error)

func (*Collaborator) App

func (self *Collaborator) App() (*App, error)

func (*Collaborator) Create

func (self *Collaborator) Create(engine Engine) error

func (*Collaborator) Delete

func (self *Collaborator) Delete(engine Engine) error

func (*Collaborator) DeleteByAppID

func (self *Collaborator) DeleteByAppID(engine Engine) error

func (*Collaborator) DeleteByAppIDAndUID

func (self *Collaborator) DeleteByAppIDAndUID(engine Engine) error

func (*Collaborator) Exist

func (self *Collaborator) Exist() (bool, error)

func (*Collaborator) Get

func (self *Collaborator) Get() (bool, error)

func (*Collaborator) Update

func (self *Collaborator) Update(engine Engine, specFields ...string) error

type DbCfg

type DbCfg struct {
	Type, Host, Name, User, Passwd, Path, SSLMode, LogPath string
}

type Deployment

type Deployment struct {
	ID            uint64 `xorm:"pk autoincr"`
	Name          string `xorm:"notnull default 'Staging'"`
	AppID         uint64 `xorm:"index notnull default(0)"`
	Key           string `xorm:"unique index notnull"`
	LastVersionID uint64 `xorm:"notnull default(0)"`
	LabelCursor   int    `xorm:"notnull default(0)"`
	Description   string
	CreatedAt     time.Time `xorm:"created"`
	UpdatedAt     time.Time `xorm:"updated"`
	DeletedAt     time.Time `xorm:"deleted"`
}

func FindDeploymentsByAppIDs

func FindDeploymentsByAppIDs(appIds []uint64) ([]*Deployment, error)

func (*Deployment) Create

func (self *Deployment) Create(engine Engine) error

func (*Deployment) Delete

func (self *Deployment) Delete(engine Engine) error

func (*Deployment) DeleteAllHistory

func (self *Deployment) DeleteAllHistory(engine Engine) error

func (*Deployment) DeleteAllPackage

func (self *Deployment) DeleteAllPackage(engine Engine) error

func (*Deployment) DeleteAllVersion

func (self *Deployment) DeleteAllVersion(engine Engine) error

func (*Deployment) DeleteByAppID

func (self *Deployment) DeleteByAppID(engine Engine) error

func (*Deployment) Detail

func (self *Deployment) Detail() (*DeploymentDetail, error)

func (*Deployment) Exist

func (self *Deployment) Exist() (bool, error)

func (*Deployment) Get

func (self *Deployment) Get() (bool, error)

func (*Deployment) GetPackageMetricsByAppIDAndName

func (self *Deployment) GetPackageMetricsByAppIDAndName() ([]*PackageMetricsDetail, error)

func (*Deployment) Histories

func (self *Deployment) Histories() ([]*DeploymentHistoryDetail, error)

func (*Deployment) PackageMetricsOfLabel

func (self *Deployment) PackageMetricsOfLabel(label string) (*PackageMetrics, error)

func (*Deployment) PackageOfVersion

func (self *Deployment) PackageOfVersion(appVersion string) (*Package, error)

func (*Deployment) Update

func (self *Deployment) Update(engine Engine, specFields ...string) error

type DeploymentDetail

type DeploymentDetail struct {
	Deployment        `xorm:"extends"`
	DeploymentVersion `xorm:"extends"`
	Package           `xorm:"extends"`
	PackageMetrics    `xorm:"extends"`
}

func FindDeploymentDetailsByAppID

func FindDeploymentDetailsByAppID(appID uint64) ([]*DeploymentDetail, error)

func (*DeploymentDetail) Convert

func (self *DeploymentDetail) Convert() interface{}

type DeploymentHistory

type DeploymentHistory struct {
	ID        uint64    `xorm:"pk autoincr"`
	DeployID  uint64    `xorm:"notnull default(0)"`
	PackageID uint64    `xorm:"notnull default(0)"`
	CreatedAt time.Time `xorm:"created"`
	DeletedAt time.Time `xorm:"deleted"`
}

func (*DeploymentHistory) Create

func (self *DeploymentHistory) Create(engine Engine) error

func (*DeploymentHistory) Delete

func (self *DeploymentHistory) Delete(engine Engine) error

func (*DeploymentHistory) Exist

func (self *DeploymentHistory) Exist() (bool, error)

func (*DeploymentHistory) Get

func (self *DeploymentHistory) Get() (bool, error)

func (*DeploymentHistory) Update

func (self *DeploymentHistory) Update(engine Engine, specFields ...string) error

type DeploymentHistoryDetail

type DeploymentHistoryDetail struct {
	DeploymentVersion `xorm:"extends"`
	Package           `xorm:"extends"`
	PackageMetrics    `xorm:"extends"`
}

func (*DeploymentHistoryDetail) Convert

func (self *DeploymentHistoryDetail) Convert() interface{}

type DeploymentVersion

type DeploymentVersion struct {
	ID         uint64 `xorm:"pk autoincr"`
	DeployID   uint64 `xorm:"index notnull default(0)"`
	PackageID  uint64 `xorm:"notnull default(0)"`
	AppVersion string
	CreatedAt  time.Time `xorm:"created"`
	UpdatedAt  time.Time `xorm:"updated"`
	DeletedAt  time.Time `xorm:"deleted"`
}

func (*DeploymentVersion) Create

func (self *DeploymentVersion) Create(engine Engine) error

func (*DeploymentVersion) Delete

func (self *DeploymentVersion) Delete(engine Engine) error

func (*DeploymentVersion) Exist

func (self *DeploymentVersion) Exist() (bool, error)

func (*DeploymentVersion) Get

func (self *DeploymentVersion) Get() (bool, error)

func (*DeploymentVersion) Update

func (self *DeploymentVersion) Update(engine Engine, specFields ...string) error

type Engine

type Engine interface {
	Delete(interface{}) (int64, error)
	Exec(string, ...interface{}) (sql.Result, error)
	Find(interface{}, ...interface{}) error
	Get(interface{}) (bool, error)
	Id(interface{}) *xorm.Session
	In(string, ...interface{}) *xorm.Session
	Insert(...interface{}) (int64, error)
	InsertOne(interface{}) (int64, error)
	Iterate(interface{}, xorm.IterFunc) error
	Sql(string, ...interface{}) *xorm.Session
	Table(interface{}) *xorm.Session
	Where(interface{}, ...interface{}) *xorm.Session
}

Engine represents a xorm engine or session.

func EngineGenerate

func EngineGenerate(engine Engine) Engine

type JsonObjectConverter

type JsonObjectConverter interface {
	Convert() interface{}
}

type ModelProtocol

type ModelProtocol interface {
	Update(engine Engine, specFields ...string) error

	Create(engine Engine) error

	Get() (bool, error)

	Delete(engine Engine) error

	Exist() (bool, error)
}

type Package

type Package struct {
	ID                 uint64 `xorm:"pk autoincr"`
	DeployID           uint64 `xorm:"index notnull default(0)"`
	DeployVersionID    uint64 `xorm:"index notnull default(0)"`
	Description        string
	Hash               string
	BlobURL            string
	Size               int64 `xorm:"notnull default(0)"`
	ManifestBlobURL    string
	ReleaseMethod      string
	Label              string `xorm:"index notnull"`
	OriginalLabel      string
	OriginalDeployment string
	ReleasedBy         string
	IsMandatory        bool      `xorm:"notnull default(0)"`
	IsDisabled         bool      `xorm:"notnull default(0)"`
	Rollout            uint8     `xorm:"notnull default(100)"`
	CreatedAt          time.Time `xorm:"created"`
	UpdatedAt          time.Time `xorm:"updated"`
	DeletedAt          time.Time `xorm:"deleted"`
}

func (*Package) Create

func (self *Package) Create(engine Engine) error

func (*Package) Delete

func (self *Package) Delete(engine Engine) error

func (*Package) Exist

func (self *Package) Exist() (bool, error)

func (*Package) FindPackagesByVersionIDAndReleaseMethods

func (self *Package) FindPackagesByVersionIDAndReleaseMethods(number int, isAsc bool, methods ...string) ([]*Package, error)

func (*Package) FindPrePackages

func (self *Package) FindPrePackages(number int, isAsc bool) ([]*Package, error)

func (*Package) Get

func (self *Package) Get() (bool, error)

func (*Package) Update

func (self *Package) Update(engine Engine, specFields ...string) error

type PackageDetail

type PackageDetail struct {
	Package     `xorm:"extends"`
	PackageDiff `xorm:"extends"`
}

type PackageDiff

type PackageDiff struct {
	ID                     uint64 `xorm:"pk autoincr"`
	OriginalPackageHash    string
	DiffAgainstPackageHash string
	DiffBlobURL            string
	DiffSize               int64     `xorm:"notnull default(0)"`
	CreatedAt              time.Time `xorm:"created"`
	UpdatedAt              time.Time `xorm:"updated"`
	DeletedAt              time.Time `xorm:"deleted"`
}

func (*PackageDiff) Create

func (self *PackageDiff) Create(engine Engine) error

func (*PackageDiff) Delete

func (self *PackageDiff) Delete(engine Engine) error

func (*PackageDiff) Exist

func (self *PackageDiff) Exist() (bool, error)

func (*PackageDiff) Get

func (self *PackageDiff) Get() (bool, error)

func (*PackageDiff) Update

func (self *PackageDiff) Update(engine Engine, specFields ...string) error

type PackageMetrics

type PackageMetrics struct {
	ID         uint64    `xorm:"pk autoincr"`
	PackageID  uint64    `xorm:"notnull default(0)"`
	Active     uint64    `xorm:"notnull default(0)"`
	Downloaded uint64    `xorm:"notnull default(0)"`
	Failed     uint64    `xorm:"notnull default(0)"`
	Installed  uint64    `xorm:"notnull default(0)"`
	CreatedAt  time.Time `xorm:"created"`
	UpdatedAt  time.Time `xorm:"updated"`
	DeletedAt  time.Time `xorm:"deleted"`
}

func (*PackageMetrics) Create

func (self *PackageMetrics) Create(engine Engine) error

func (*PackageMetrics) Delete

func (self *PackageMetrics) Delete(engine Engine) error

func (*PackageMetrics) Exist

func (self *PackageMetrics) Exist() (bool, error)

func (*PackageMetrics) Get

func (self *PackageMetrics) Get() (bool, error)

func (*PackageMetrics) Update

func (self *PackageMetrics) Update(engine Engine, specFields ...string) error

type PackageMetricsDetail

type PackageMetricsDetail struct {
	*PackageMetrics `xorm:"extends"`
	Label           string
}

type User

type User struct {
	ID        uint64 `xorm:"pk autoincr"`
	Email     string `xorm:"unique notnull"`
	Password  string `xorm:"notnull"`
	Rands     string `xorm:"index"`
	UserName  string
	LowerName string `xorm:"unique notnull"`
	IsAdmin   bool   `xorm:"notnull default(0)"`
	Status    int    `xorm:"notnull default(0)"`
	Salt      string
	CreatedAt time.Time `xorm:"created"`
	UpdatedAt time.Time `xorm:"updated"`
	DeletedAt time.Time `xorm:"deleted"`
}

func FindUserByIDs

func FindUserByIDs(ids []uint64) ([]*User, error)

func (*User) Apps

func (self *User) Apps() ([]*App, error)

func (*User) Collaborators

func (self *User) Collaborators() ([]*Collaborator, error)

func (*User) Convert

func (self *User) Convert() interface{}

func (*User) Create

func (self *User) Create(engine Engine) error

func (*User) Delete

func (self *User) Delete(engine Engine) error

func (*User) EmailUsable

func (self *User) EmailUsable() (bool, error)

func (*User) EncodePasswd

func (self *User) EncodePasswd()

func (*User) Exist

func (self *User) Exist() (bool, error)

func (*User) GenerateRands

func (self *User) GenerateRands()

func (*User) GenerateSalt

func (self *User) GenerateSalt()

func (*User) Get

func (self *User) Get() (bool, error)

func (*User) Tokens

func (self *User) Tokens() ([]*UserToken, error)

func (*User) Update

func (self *User) Update(engine Engine, specFields ...string) error

func (*User) ValidatePassword

func (self *User) ValidatePassword(passwd string) bool

type UserToken

type UserToken struct {
	ID          uint64 `xorm:"pk autoincr"`
	UID         uint64 `xorm:"unique(s) notnull default(0)"`
	Name        string `xorm:"unique(s) notnull"`
	Token       string `xorm:"notnull"`
	CreatedBy   string
	IsSession   bool `xorm:"notnull default(0)"`
	Description string
	ExpiresAt   time.Time
	CreatedAt   time.Time `xorm:"created"`
	DeletedAt   time.Time `xorm:"deleted"`
}

func (*UserToken) Convert

func (self *UserToken) Convert() interface{}

func (*UserToken) Create

func (self *UserToken) Create(engine Engine) error

func (*UserToken) Delete

func (self *UserToken) Delete(engine Engine) error

func (*UserToken) DeleteByCreatorAndUID

func (self *UserToken) DeleteByCreatorAndUID(engine Engine) error

func (*UserToken) DeleteByNameAndUID

func (self *UserToken) DeleteByNameAndUID(engine Engine) error

func (*UserToken) Exist

func (self *UserToken) Exist() (bool, error)

func (*UserToken) Get

func (self *UserToken) Get() (bool, error)

func (*UserToken) GetUnexpired

func (self *UserToken) GetUnexpired() (bool, error)

func (*UserToken) Update

func (self *UserToken) Update(engine Engine, specFields ...string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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