model

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2021 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Database Database  `yaml:"database"`
	Versions []Version `yaml:"versions"`
	// contains filtered or unexported fields
}

func (*Config) GetDatabase

func (c *Config) GetDatabase(version, dbID int64, tableName string) Database

func (*Config) GetDefaultDatabse

func (c *Config) GetDefaultDatabse() Database

func (*Config) GetLastVersionEntity

func (c *Config) GetLastVersionEntity(entityName string) Table

func (*Config) GetNewestVersion

func (c *Config) GetNewestVersion() Version

func (*Config) GetSpecificVersion

func (c *Config) GetSpecificVersion(version int64) Version

func (*Config) String

func (c *Config) String() string

func (*Config) Validate

func (c *Config) Validate() bool

type Database

type Database struct {
	DSN         string        `yaml:"dsn"`
	Passwd      string        `yaml:"passwd"`
	MaxConns    int           `yaml:"max_conns"`
	MinConns    int           `yaml:"min_conns"`
	MaxLifeTIme time.Duration `yaml:"max_lifetime"`
}

func (Database) ConnStr

func (n Database) ConnStr() (string, error)

func (*Database) IsNullObject

func (d *Database) IsNullObject() bool

func (*Database) SetMaxConns

func (d *Database) SetMaxConns(connAmout int)

func (*Database) SetMaxLifeTime

func (d *Database) SetMaxLifeTime(duration time.Duration)

func (*Database) SetMinConns

func (d *Database) SetMinConns(connAmout int)

func (*Database) String

func (n *Database) String() string

func (*Database) Validate

func (d *Database) Validate() bool

type IValidate

type IValidate interface {
	Validate() bool
}

type Rule

type Rule struct {
	Tables    []Table    `yaml:tables`
	Databases []Database `yaml:databases`
}

func (*Rule) GetBusicessEntity

func (r *Rule) GetBusicessEntity(entityName string) Table

func (Rule) GetDatabase

func (r Rule) GetDatabase(dbId int64) Database

func (*Rule) IsEmptyObject

func (r *Rule) IsEmptyObject() bool

func (*Rule) String

func (r *Rule) String() string

func (*Rule) Validate

func (r *Rule) Validate() bool

type Table

type Table struct {
	Name     string `yaml:name`
	Tags     []Tag  `yaml:tags`
	Key      string `yaml:key`
	TimeZone string `yaml:"timeZone"`
}

func (*Table) GetTable

func (e *Table) GetTable(bizName string) Tag

func (Table) GetTag

func (t Table) GetTag(tagId int64) Tag

func (*Table) GetTime

func (e *Table) GetTime(targetTIme time.Time) (util.TimeUtil, error)

func (*Table) IsEmptyTimeZone

func (e *Table) IsEmptyTimeZone() bool

func (*Table) IsNullObject

func (e *Table) IsNullObject() bool

func (*Table) String

func (e *Table) String() string
 func (e *Table) Validating() bool {
	mapIdHash := make(map[int]int)
	for _, v := range e.Tags {
		if val, ok := mapIdHash[v.ID]; ok {
			if val != v.Amount {
				return false
			}
		} else {
			mapIdHash[v.ID] = v.Amount
		}
	}
	return true
}

func (*Table) Validate

func (t *Table) Validate() bool

type Tag

type Tag struct {
	ID     int      `yaml:"id"`
	Names  []string `yaml:names`
	Amount int      `yaml:"amount"`
	Date   string   `yaml:"date,omitempty"`
	// contains filtered or unexported fields
}

func (*Tag) GetHashValue

func (t *Tag) GetHashValue(sequnce int64) int64

func (*Tag) GetIdString

func (t *Tag) GetIdString() string

func (*Tag) IsNullObject

func (t *Tag) IsNullObject() bool

func (*Tag) String

func (t *Tag) String() string

func (*Tag) Validate

func (t *Tag) Validate() bool

type Version

type Version struct {
	Version int64 `yaml:"version"`
	Rules   Rule  `yaml:"rules"`
}

func (*Version) GetBusicessEntity

func (v *Version) GetBusicessEntity(business string) Table

func (Version) GetBusicessRule

func (vc Version) GetBusicessRule(tableName string) Rule

func (Version) GetTable

func (v Version) GetTable(tableName string) Table

func (*Version) GetVer

func (vc *Version) GetVer() int64

func (*Version) String

func (v *Version) String() string

func (*Version) Validate

func (v *Version) Validate() bool

Jump to

Keyboard shortcuts

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