Documentation

Index

Constants

View Source
const (
	TWOSIDES = iota + 1
	ONLYTODB
	ONLYFROMDB
)
View Source
const (
	Version = "0.1"

	//Env = "dev"
	Env = "pro"

	DevBaseUrl = "http://localhost:1227/api/"
	//DevEaseWebZipUrl           = "http://localhost:12345/easyweb.zip"
	//DevSvrTemplateZipUrl       = "http://localhost:12345/server.zip"
	//DevWebTemplateZipUrl       = "http://localhost:12345/web.zip"
	//DevWebBasProZipUrl         = "http://localhost:12345/daminghu-web.zip"
	//DevWebBasProNoChromeZipUrl = "http://localhost:12345/nochrome/daminghu-web.zip"
	//DevBaseUrl                 = "http://sd-tlas-dev.uuzz.com:20802/bjtestapi/"
	DevEaseWebZipUrl           = "http://sd-tlas-dev.uuzz.com:20802/ydl/dl/easyweb.zip"
	DevSvrTemplateZipUrl       = "http://sd-tlas-dev.uuzz.com:20802/ydl/dl/server.zip"
	DevWebTemplateZipUrl       = "http://sd-tlas-dev.uuzz.com:20802/ydl/dl/web.zip"
	DevWebBasProZipUrl         = "http://sd-tlas-dev.uuzz.com:20802/ydl/dl/daminghu-web.zip"
	DevWebBasProNoChromeZipUrl = "http://sd-tlas-dev.uuzz.com:20802/ydl/dl/nochrome/daminghu-web.zip"

	ProBaseUrl                 = "http://sd-tlas-dev.uuzz.com:20802/bjtestapi/"
	ProEaseWebZipUrl           = "http://sd-tlas-dev.uuzz.com:20802/ydl/dl/easyweb.zip"
	ProSvrTemplateZipUrl       = "http://sd-tlas-dev.uuzz.com:20802/ydl/dl/server.zip"
	ProWebTemplateZipUrl       = "http://sd-tlas-dev.uuzz.com:20802/ydl/dl/web.zip"
	ProWebBasProZipUrl         = "http://sd-tlas-dev.uuzz.com:20802/ydl/dl/daminghu-web.zip"
	ProWebBasProNoChromeZipUrl = "http://sd-tlas-dev.uuzz.com:20802/ydl/dl/nochrome/daminghu-web.zip"
)
View Source
const (
	POSTGRES = "postgres"
	SQLITE   = "sqlite3"
	MYSQL    = "mysql"
	MSSQL    = "mssql"
	ORACLE   = "oracle"
)
View Source
const (
	UNKNOW_TYPE = iota
	TEXT_TYPE
	BLOB_TYPE
	TIME_TYPE
	NUMERIC_TYPE
)

Variables

View Source
var (
	BaseUrl                 = ProBaseUrl
	EaseWebZipUrl           = ProEaseWebZipUrl
	SvrTemplateZipUrl       = ProSvrTemplateZipUrl
	WebTemplateZipUrl       = ProWebTemplateZipUrl
	WebBasProZipUrl         = ProWebBasProZipUrl
	WebBasProNoChromeZipUrl = ProWebBasProNoChromeZipUrl

	CreateAllUrl    = BaseUrl + "create/all"
	CreateServerUrl = BaseUrl + "create/server"
	CreateWebUrl    = BaseUrl + "create/web"
)
View Source
var (
	Bit       = "BIT"
	TinyInt   = "TINYINT"
	SmallInt  = "SMALLINT"
	MediumInt = "MEDIUMINT"
	Int       = "INT"
	Integer   = "INTEGER"
	BigInt    = "BIGINT"

	Enum = "ENUM"
	Set  = "SET"

	Char             = "CHAR"
	Varchar          = "VARCHAR"
	NChar            = "NCHAR"
	NVarchar         = "NVARCHAR"
	TinyText         = "TINYTEXT"
	Text             = "TEXT"
	NText            = "NTEXT"
	Clob             = "CLOB"
	MediumText       = "MEDIUMTEXT"
	LongText         = "LONGTEXT"
	Uuid             = "UUID"
	UniqueIdentifier = "UNIQUEIDENTIFIER"
	SysName          = "SYSNAME"

	Date          = "DATE"
	DateTime      = "DATETIME"
	SmallDateTime = "SMALLDATETIME"
	Time          = "TIME"
	TimeStamp     = "TIMESTAMP"
	TimeStampz    = "TIMESTAMPZ"

	Decimal    = "DECIMAL"
	Numeric    = "NUMERIC"
	Money      = "MONEY"
	SmallMoney = "SMALLMONEY"

	Real   = "REAL"
	Float  = "FLOAT"
	Double = "DOUBLE"

	Binary     = "BINARY"
	VarBinary  = "VARBINARY"
	TinyBlob   = "TINYBLOB"
	Blob       = "BLOB"
	MediumBlob = "MEDIUMBLOB"
	LongBlob   = "LONGBLOB"
	Bytea      = "BYTEA"

	Bool    = "BOOL"
	Boolean = "BOOLEAN"

	Serial    = "SERIAL"
	BigSerial = "BIGSERIAL"

	Json  = "JSON"
	Jsonb = "JSONB"

	SqlTypes = map[string]int{
		Bit:       NUMERIC_TYPE,
		TinyInt:   NUMERIC_TYPE,
		SmallInt:  NUMERIC_TYPE,
		MediumInt: NUMERIC_TYPE,
		Int:       NUMERIC_TYPE,
		Integer:   NUMERIC_TYPE,
		BigInt:    NUMERIC_TYPE,

		Enum:  TEXT_TYPE,
		Set:   TEXT_TYPE,
		Json:  TEXT_TYPE,
		Jsonb: TEXT_TYPE,

		Char:       TEXT_TYPE,
		NChar:      TEXT_TYPE,
		Varchar:    TEXT_TYPE,
		NVarchar:   TEXT_TYPE,
		TinyText:   TEXT_TYPE,
		Text:       TEXT_TYPE,
		NText:      TEXT_TYPE,
		MediumText: TEXT_TYPE,
		LongText:   TEXT_TYPE,
		Uuid:       TEXT_TYPE,
		Clob:       TEXT_TYPE,
		SysName:    TEXT_TYPE,

		Date:          TIME_TYPE,
		DateTime:      TIME_TYPE,
		Time:          TIME_TYPE,
		TimeStamp:     TIME_TYPE,
		TimeStampz:    TIME_TYPE,
		SmallDateTime: TIME_TYPE,

		Decimal:    NUMERIC_TYPE,
		Numeric:    NUMERIC_TYPE,
		Real:       NUMERIC_TYPE,
		Float:      NUMERIC_TYPE,
		Double:     NUMERIC_TYPE,
		Money:      NUMERIC_TYPE,
		SmallMoney: NUMERIC_TYPE,

		Binary:    BLOB_TYPE,
		VarBinary: BLOB_TYPE,

		TinyBlob:         BLOB_TYPE,
		Blob:             BLOB_TYPE,
		MediumBlob:       BLOB_TYPE,
		LongBlob:         BLOB_TYPE,
		Bytea:            BLOB_TYPE,
		UniqueIdentifier: BLOB_TYPE,

		Bool: NUMERIC_TYPE,

		Serial:    NUMERIC_TYPE,
		BigSerial: NUMERIC_TYPE,
	}
)
View Source
var (
	IntType   = reflect.TypeOf(c_INT_DEFAULT)
	Int8Type  = reflect.TypeOf(c_INT8_DEFAULT)
	Int16Type = reflect.TypeOf(c_INT16_DEFAULT)
	Int32Type = reflect.TypeOf(c_INT32_DEFAULT)
	Int64Type = reflect.TypeOf(c_INT64_DEFAULT)

	UintType   = reflect.TypeOf(c_UINT_DEFAULT)
	Uint8Type  = reflect.TypeOf(c_UINT8_DEFAULT)
	Uint16Type = reflect.TypeOf(c_UINT16_DEFAULT)
	Uint32Type = reflect.TypeOf(c_UINT32_DEFAULT)
	Uint64Type = reflect.TypeOf(c_UINT64_DEFAULT)

	Float32Type = reflect.TypeOf(c_FLOAT32_DEFAULT)
	Float64Type = reflect.TypeOf(c_FLOAT64_DEFAULT)

	Complex64Type  = reflect.TypeOf(c_COMPLEX64_DEFAULT)
	Complex128Type = reflect.TypeOf(c_COMPLEX128_DEFAULT)

	StringType = reflect.TypeOf(c_EMPTY_STRING)
	BoolType   = reflect.TypeOf(c_BOOL_DEFAULT)
	ByteType   = reflect.TypeOf(c_BYTE_DEFAULT)
	BytesType  = reflect.SliceOf(ByteType)

	TimeType = reflect.TypeOf(c_TIME_DEFAULT)
)
View Source
var (
	PtrIntType   = reflect.PtrTo(IntType)
	PtrInt8Type  = reflect.PtrTo(Int8Type)
	PtrInt16Type = reflect.PtrTo(Int16Type)
	PtrInt32Type = reflect.PtrTo(Int32Type)
	PtrInt64Type = reflect.PtrTo(Int64Type)

	PtrUintType   = reflect.PtrTo(UintType)
	PtrUint8Type  = reflect.PtrTo(Uint8Type)
	PtrUint16Type = reflect.PtrTo(Uint16Type)
	PtrUint32Type = reflect.PtrTo(Uint32Type)
	PtrUint64Type = reflect.PtrTo(Uint64Type)

	PtrFloat32Type = reflect.PtrTo(Float32Type)
	PtrFloat64Type = reflect.PtrTo(Float64Type)

	PtrComplex64Type  = reflect.PtrTo(Complex64Type)
	PtrComplex128Type = reflect.PtrTo(Complex128Type)

	PtrStringType = reflect.PtrTo(StringType)
	PtrBoolType   = reflect.PtrTo(BoolType)
	PtrByteType   = reflect.PtrTo(ByteType)

	PtrTimeType = reflect.PtrTo(TimeType)
)

Functions

func CreateAuthor

func CreateAuthor() string

func GetNowTime

func GetNowTime() string

func GetNowTimeYYYYMMDDhhmmss

func GetNowTimeYYYYMMDDhhmmss() string

func SQLType2Type

func SQLType2Type(st SQLType) reflect.Type

default sql type change to go types

func UnixNow

func UnixNow() string

Types

type CmdParamStruct

type CmdParamStruct struct {
	BuildType string
	CfgPath   string
	Mode      string
	Jsondata  string
	Email     string
}
var (
	CmdParam CmdParamStruct
)

type Column

type Column struct {
	Name            string
	TableName       string
	FieldName       string
	SQLType         SQLType
	IsJSON          bool
	Length          int
	Length2         int
	Nullable        bool
	Default         string
	Indexes         map[string]int
	IsPrimaryKey    bool
	IsAutoIncrement bool
	MapType         int
	IsCreated       bool
	IsUpdated       bool
	IsDeleted       bool
	IsCascade       bool
	IsVersion       bool
	DefaultIsEmpty  bool
	EnumOptions     map[string]int
	SetOptions      map[string]int
	DisableTimeZone bool
	TimeZone        *time.Location // column specified time zone
	Comment         string
}

Column defines database column

type SQLType

type SQLType struct {
	Name           string
	DefaultLength  int
	DefaultLength2 int
}

xorm SQL types

func Type2SQLType

func Type2SQLType(t reflect.Type) (st SQLType)

Type2SQLType generate SQLType acorrding Go's type

func (*SQLType) IsBlob

func (s *SQLType) IsBlob() bool

func (*SQLType) IsJson

func (s *SQLType) IsJson() bool

func (*SQLType) IsNumeric

func (s *SQLType) IsNumeric() bool

func (*SQLType) IsText

func (s *SQLType) IsText() bool

func (*SQLType) IsTime

func (s *SQLType) IsTime() bool

func (*SQLType) IsType

func (s *SQLType) IsType(st int) bool

type Table

type Table struct {
	Name       string
	Type       reflect.Type
	ColumnsSeq []string
	ColumnsMap map[string][]*Column
	Columns    []*Column
	//Indexes       map[string]*Index
	PrimaryKeys   []string
	AutoIncrement string
	Created       map[string]bool
	Updated       string
	Deleted       string
	Version       string
	//Cacher        Cacher
	StoreEngine string
	Charset     string
	Comment     string
}

database table