model

package
v0.0.0-...-3cc3e56 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrKeyNotExist = errors.New("json map key not exist")
	ErrKeyKind     = errors.New("json map value kind error")
)

Functions

This section is empty.

Types

type ApiType

type ApiType string

type Apis

type Apis struct {
	Modelx
	DeletedAt             soft_delete.DeletedAt `json:"deleteAt" gorm:"uniqueIndex:idx_api_name"`
	ApiType               ApiType               `json:"apiType" gorm:"column:api_type;default:'';not null;index"`
	Name                  string                `json:"name" gorm:"column:api_name;type:varchar(200);uniqueIndex:idx_api_name;not null"` // api name
	Method                string                `json:"method" gorm:"column:method;type:varchar(50);not null;index"`                     // api name// http method
	Description           string                `json:"description" gorm:"column:description;type:varchar(200);not null"`                // description
	SqlType               SqlType               `json:"sqlType" gorm:"column:sql_type;not null;index"`
	SqlTemplate           JSONMap               `json:"sqlTemplate" gorm:"column:sql_template;not null"`                      // sql template
	SqlTemplateParameters JSONMap               `json:"sqlTemplateParameters" gorm:"column:sql_template_parameters;not null"` // template parameters
	SqlTemplateResult     JSONMap               `json:"sqlTemplateResult" gorm:"column:sql_template_result;not null"`         // format result

}

base sql template or sql chain

type Database

type Database struct {
	Modelx
	DeletedAt soft_delete.DeletedAt `json:"deleteAt" gorm:"uniqueIndex:idx_db_key"`
	DBKey     string                `json:"dbKey" gorm:"column:db_key;type:varchar(200);uniqueIndex:idx_db_key;not null"` // db key desc
	Type      DbType                `json:"dbType" gorm:"column:db_type;not null;index"`
	Host      string                `json:"host" gorm:"column:host;type:varchar(100);not null"`
	Port      int                   `json:"port" gorm:"column:port;not null"`
	User      string                `json:"user" gorm:"column:user;not null"`
	Password  string                `json:"password" gorm:"column:password;not null"`
	DBName    string                `json:"dbName" gorm:"column:db_name;not null"`
}

TODO: db config

type DbType

type DbType string
const (
	DbTypePostgres DbType = "postgres"
)

type JSONMap

type JSONMap map[string]interface{}

JSONMap defiend JSON data type, need to implements driver.Valuer, sql.Scanner interface

func FromMapString

func FromMapString(m map[string]string) JSONMap

func (JSONMap) GetFloat

func (jm JSONMap) GetFloat(key string) (float64, error)

func (JSONMap) GetInt

func (jm JSONMap) GetInt(key string) (int64, error)

func (JSONMap) GetString

func (jm JSONMap) GetString(key string) (string, error)

func (JSONMap) GormDBDataType

func (JSONMap) GormDBDataType(db *gorm.DB, field *schema.Field) string

GormDBDataType gorm db data type

func (JSONMap) GormDataType

func (m JSONMap) GormDataType() string

GormDataType gorm common data type

func (JSONMap) GormValue

func (jm JSONMap) GormValue(ctx context.Context, db *gorm.DB) clause.Expr

func (JSONMap) MarshalJSON

func (m JSONMap) MarshalJSON() ([]byte, error)

MarshalJSON to output non base64 encoded []byte

func (JSONMap) MustGetString

func (jm JSONMap) MustGetString(key string) string

func (*JSONMap) Scan

func (m *JSONMap) Scan(val interface{}) error

Scan scan value into Jsonb, implements sql.Scanner interface

func (JSONMap) ToMapString

func (jm JSONMap) ToMapString() (map[string]string, error)

func (*JSONMap) UnmarshalJSON

func (m *JSONMap) UnmarshalJSON(b []byte) error

UnmarshalJSON to deserialize []byte

func (JSONMap) Value

func (m JSONMap) Value() (driver.Value, error)

Value return json value, implement driver.Valuer interface

type Modelx

type Modelx struct {
	ID        uint      `json:"id" gorm:"primarykey"`
	CreatedAt time.Time `json:"createdAt" gorm:"<-:create"`
	UpdatedAt time.Time `json:"deletedAt"`
}

soft delete

func (*Modelx) GetID

func (m *Modelx) GetID() uint

type SqlType

type SqlType int8
const (
	SqlTypeTemplate SqlType = iota + 1 // template
	SqlTypeChain                       // chain
)

func SqlTypeFromStr

func SqlTypeFromStr(tp string) (SqlType, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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