dbi

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const FileTmpl = `package generate

import "time"

`
View Source
const TagTmpl = "`json:\"%s\" explain:\"%s\"`"
View Source
const Tmpl = `package entity
import "time"

type Example struct{
A int` + "`json:\"a\" explain:\"模板\"`" + `
B string
C time.Time
}
`

Variables

This section is empty.

Functions

func AddStruct

func AddStruct(name string) []byte

func Convert

func Convert(c ConvertInterface, filename string)

func ConvertByTable

func ConvertByTable(c ConvertInterface, tableName string)

func ConvertParams

func ConvertParams(v interface{}, escaper string) string

func GetDecl

func GetDecl() *ast.GenDecl

func Insert

func Insert(values interface{}, field ...string) (string, []interface{})

func NewLine

func NewLine() byte

func StructEnd

func StructEnd(name string) []byte

func TableName

func TableName(name string, id uint64) string

func TwoLine

func TwoLine() []byte

Types

type ConvertInterface

type ConvertInterface interface {
	Tables() []string
	Fields(tableName string) []*Field
	TypeToGoTYpe(typ string) string
}

type Deleted

type Deleted struct {
	DeleteAt, Time string
}

func DeletedAt

func DeletedAt(t string) *Deleted

type Field

type Field struct {
	Field   string
	Type    string
	Comment string
	GoTYpe  string
}

func (*Field) Generate

func (f *Field) Generate() *ast.Field

type FilterExpression

type FilterExpression struct {
	Field     string        `json:"field"`
	Operation Operation     `json:"method"`
	Value     []interface{} `json:"value"`
}

type FilterExpressions

type FilterExpressions []FilterExpression

func (FilterExpressions) Build

func (f FilterExpressions) Build() string

func (FilterExpressions) BuildORM

func (f FilterExpressions) BuildORM(odb *gorm.DB) *gorm.DB

func (FilterExpressions) BuildSQL

func (f FilterExpressions) BuildSQL() (string, []interface{})

type Operation

type Operation int
const (
	OperationPlace Operation = iota
	Equal
	NotEqual
	Greater
	Less
	Between
	GreaterOrEqual
	LessOrEqual
	IsNotNull
	IsNull
	In
	NotIn
	LIKE
)

func (Operation) SQL

func (m Operation) SQL() string

func (Operation) String

func (m Operation) String() string

type TimeModel

type TimeModel struct {
	CreatedAt time.Time  `json:"created_at" gorm:"default:current_timestamp"`
	UpdatedAt time.Time  `json:"updated_at"  gorm:"default:current_timestamp"`
	DeletedAt *time.Time `json:"deleted_at"`
}

type TimeStampModel

type TimeStampModel struct {
	CreatedAt int64 `json:"created_at" gorm:"default:current_timestamp"`
	UpdatedAt int64 `json:"updated_at" gorm:"default:current_timestamp"`
	DeletedAt int64 `json:"deleted_at"`
}

type TimeStringModel

type TimeStringModel struct {
	CreatedAt string `json:"created_at" gorm:"default:current_timestamp"`
	UpdatedAt string `json:"updated_at" gorm:"default:current_timestamp"`
	DeletedAt string `json:"deleted_at"`
}

Jump to

Keyboard shortcuts

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