dbi

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2023 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 Expression

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

type Exprs

type Exprs []Expression

func (Exprs) Build

func (f Exprs) Build() string

func (Exprs) BuildORM

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

func (Exprs) BuildSQL

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

type Field

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

func (*Field) Generate

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

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