model

package
v1.2.10 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column struct {
	gorm.ColumnType
	TableName   string `gorm:"column:TABLE_NAME"`
	UseScanType bool   `gorm:"-"`
	// contains filtered or unexported fields
}

Column table column's info

func (*Column) AddDataTypeMap added in v1.0.0

func (c *Column) AddDataTypeMap(key, value string)

func (*Column) AddDataTypePkgMap added in v1.0.0

func (c *Column) AddDataTypePkgMap(key, value string)

func (*Column) GetDataType

func (c *Column) GetDataType() (fieldtype string)

GetDataType get data type

func (*Column) SetDataTypeMap

func (c *Column) SetDataTypeMap(m map[string]string)

SetDataTypeMap set data type map

func (*Column) SetDataTypePkgMap added in v1.0.0

func (c *Column) SetDataTypePkgMap(m map[string]string)

SetDataTypePkgMap set data type pkg map

func (*Column) ToField

func (c *Column) ToField(nullable, coverable, signable bool) (string, *Field)

ToField convert to field

func (*Column) WithNS

func (c *Column) WithNS(jsonTagNS func(columnName string) string)

WithNS with name strategy

type Config

type Config struct {
	ModelPkg  string
	TableName string
	ModelName string
	//ImportPkgPaths []string
	TemplateDir          string
	FieldWithTags        []string
	ConvTypeMap          map[string]string
	ConvTypePkgMap       map[string]string
	DynamicConstSuffixes []string // dynamic const suffix
	AutoValueFields      []string

	FieldConfig
}

Config model configuration

type Field

type Field struct {
	Name                 string
	ColumnName           string
	TypeName             string
	OriginalTypeName     string // 原始类型
	DatabaseTypeName     string // varchar
	ColumnType           string // varchar(64)
	PrimaryKey           bool
	AutoIncrement        bool
	Length               int64
	DecimalSizeOK        bool
	DecimalSizeScale     int64
	DecimalSizePrecision int64
	Nullable             bool
	Unique               bool
	ScanType             reflect.Type
	Comment              string
	DefaultValueOK       bool
	DefaultValue         string
	CustomTypeMap        map[string]string // 自定义类型映射
}

func (*Field) GenType

func (m *Field) GenType() string

GenType ...

type FieldConfig

type FieldConfig struct {
	DataTypeMap    map[string]string
	DataTypePkgMap map[string]string

	FieldNullable  bool // generate pointer when field is nullable
	FieldCoverable bool // generate pointer when field has default value
	FieldSignable  bool // detect integer field's unsigned type, adjust generated data type

	FieldJSONTagNS func(columnName string) string
}

FieldConfig field configuration

Jump to

Keyboard shortcuts

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