setting

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2021 License: BSD-3-Clause Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_DIR_MODE  = 0o755
	DEFAULT_FILE_MODE = 0o644
)
View Source
const (
	INIT_FILE_NAME   = "init"
	CONN_FILE_NAME   = "conn"
	SINGLE_FILE_NAME = "models"
	QUERY_FILE_NAME  = "queries"

	XORM_TAG_NAME        = "xorm"
	XORM_TAG_NOT_NULL    = "notnull"
	XORM_TAG_AUTO_INCR   = "autoincr"
	XORM_TAG_PRIMARY_KEY = "pk"
	XORM_TAG_UNIQUE      = "unique"
	XORM_TAG_INDEX       = "index"
)

Variables

This section is empty.

Functions

func GetLevelString

func GetLevelString(lvl log.LogLevel) string

将 xorm 的日志级别转为字符串

func ReadSettingsExt added in v1.1.0

func ReadSettingsExt(fileName string, cfg interface{}) (string, error)

func ReadSettingsFrom

func ReadSettingsFrom(fileType, fileName string, cfg interface{}) error

func SaveSettingsTo

func SaveSettingsTo(fileName string, cfg interface{}) error

func Settings2Bytes

func Settings2Bytes(cfg interface{}) []byte

Types

type Configure

type Configure struct {
	Debug         bool                  `json:"debug" yaml:"debug"`
	Connections   map[string]ConnConfig `json:"connections" yaml:"connections"`
	ReverseTarget ReverseTarget         `json:"reverse_target" yaml:"reverse_target"`
}

func ReadSettings

func ReadSettings(fileName, nameSpace string) (*Configure, error)

func (Configure) GetConnConfig

func (cfg Configure) GetConnConfig(key string) (ConnConfig, bool)

func (Configure) GetConnConfigMap

func (cfg Configure) GetConnConfigMap(keys ...string) map[string]ConnConfig

func (Configure) GetReverseTarget added in v1.0.8

func (cfg Configure) GetReverseTarget(name string) ReverseTarget

func (Configure) RemovePrivates added in v1.0.8

func (cfg Configure) RemovePrivates()

type ConnConfig

type ConnConfig struct {
	DriverName  string             `json:"driver_name" yaml:"driver_name"`
	ReadOnly    bool               `json:"read_only" yaml:"read_only"`
	TablePrefix string             `json:"table_prefix" yaml:"table_prefix"`
	LogFile     string             `json:"log_file" yaml:"log_file"`
	Params      dialect.ConnParams `json:"params" yaml:"params"`
}

func (ConnConfig) ConnectRedis added in v1.0.8

func (c ConnConfig) ConnectRedis(verbose bool) (redis.Conn, error)

func (ConnConfig) ConnectXorm added in v1.0.8

func (c ConnConfig) ConnectXorm(verbose bool) (*xorm.Engine, error)

type Globs added in v1.0.8

type Globs []glob.Glob

func NewGlobs added in v1.0.8

func NewGlobs(wildcards []string) Globs

func (Globs) MatchAll added in v1.0.8

func (gs Globs) MatchAll(word string, forEmpty bool) bool

func (Globs) MatchAny added in v1.0.8

func (gs Globs) MatchAny(word string, forEmpty bool) bool

type IReverseConfig

type IReverseConfig interface {
	GetReverseTarget(name string) ReverseTarget
	GetConnConfigMap(keys ...string) map[string]ConnConfig
	GetConnConfig(key string) (ConnConfig, bool)
}

type ReverseSource

type ReverseSource struct {
	DriverName   string `json:"driver_name" yaml:"driver_name"`
	TablePrefix  string `json:"table_prefix" yaml:"table_prefix"`
	ImporterPath string `json:"importer_path" yaml:"importer_path"`
	ConnStr      string `json:"conn_str" yaml:"conn_str"`
	OptStr       string `json:"opt_str" yaml:"opt_str"`
	// contains filtered or unexported fields
}

ReverseSource represents a reverse source which should be a database connection

func NewReverseSource

func NewReverseSource(c ConnConfig) (*ReverseSource, dialect.Dialect)

func (ReverseSource) Connect

func (r ReverseSource) Connect(verbose bool) (*xorm.Engine, redis.Conn, error)

type ReverseTarget

type ReverseTarget struct {
	Language          string   `json:"language" yaml:"language"`
	IncludeTables     []string `json:"include_tables" yaml:"include_tables"`
	ExcludeTables     []string `json:"exclude_tables" yaml:"exclude_tables"`
	InitNameSpace     string   `json:"init_name_space" yaml:"init_name_space"`
	OutputDir         string   `json:"output_dir" yaml:"output_dir"`
	TemplatePath      string   `json:"template_path" yaml:"template_path"`
	QueryTemplatePath string   `json:"query_template_path" yaml:"query_template_path"`
	InitTemplatePath  string   `json:"init_template_path" yaml:"init_template_path"`

	TableMapper  string            `json:"table_mapper" yaml:"table_mapper"`
	ColumnMapper string            `json:"column_mapper" yaml:"column_mapper"`
	Funcs        map[string]string `json:"funcs" yaml:"funcs"`
	Formatter    string            `json:"formatter" yaml:"formatter"`
	Importter    string            `json:"importter" yaml:"importter"`
	ExtName      string            `json:"-" yaml:"-"`
	NameSpace    string            `json:"-" yaml:"-"`

	MultipleFiles  bool   `json:"multiple_files" yaml:"multiple_files"`
	ApplyMixins    bool   `json:"apply_mixins" yaml:"apply_mixins"`
	MixinDirPath   string `json:"mixin_dir_path" yaml:"mixin_dir_path"`
	MixinNameSpace string `json:"mixin_name_space" yaml:"mixin_name_space"`
}

ReverseTarget represents a reverse target

func DefaultMixinReverseTarget added in v1.1.0

func DefaultMixinReverseTarget(nameSpace string) ReverseTarget

func DefaultReverseTarget added in v1.1.0

func DefaultReverseTarget(nameSpace string) ReverseTarget

func (ReverseTarget) GetFileName

func (t ReverseTarget) GetFileName(dir, name string) string

func (ReverseTarget) GetOutFileName

func (t ReverseTarget) GetOutFileName(name string) string

func (ReverseTarget) GetParentOutFileName

func (t ReverseTarget) GetParentOutFileName(name string, backward int) string

func (ReverseTarget) MergeOptions

func (t ReverseTarget) MergeOptions(key string, src *ReverseSource) ReverseTarget

type SqlLogger

type SqlLogger struct {
	*logging.Logger
	// contains filtered or unexported fields
}

func NewSqlLogger

func NewSqlLogger(filename string) *SqlLogger

func (*SqlLogger) IsShowSQL

func (s *SqlLogger) IsShowSQL() bool

IsShowSQL implement ILogger

func (*SqlLogger) Level

func (s *SqlLogger) Level() log.LogLevel

Level implement ILogger

func (*SqlLogger) SetLevel

func (s *SqlLogger) SetLevel(l log.LogLevel)

SetLevel implement ILogger

func (*SqlLogger) ShowSQL

func (s *SqlLogger) ShowSQL(show ...bool)

ShowSQL implement ILogger

type SqlTag

type SqlTag struct {
	reflect.StructTag
	// contains filtered or unexported fields
}

StructTag named sql or xorm

func NewSqlTag

func NewSqlTag() *SqlTag

func (*SqlTag) Delete

func (st *SqlTag) Delete(key string)

Deletes a tag

func (*SqlTag) Get

func (st *SqlTag) Get(key string) (string, bool)

Returns a tag from the tag data

func (*SqlTag) ParseTag

func (st *SqlTag) ParseTag(tag reflect.StructTag)

func (*SqlTag) Set

func (st *SqlTag) Set(key, val string)

Sets a tag in the tag data map

func (*SqlTag) String

func (st *SqlTag) String(head string) string

转为字符串格式,头通常使用sql或xorm

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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