base

package
v0.0.1-beta Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ProviderSet = wire.NewSet(
	NewData,
	NewTransaction,
)

Functions

func NewTransaction

func NewTransaction(data *Data) base.Transaction

Types

type Base

type Base struct{}

func (*Base) TransformJson

func (b *Base) TransformJson(source, target interface{}) error

type Data

type Data struct {
	// contains filtered or unexported fields
}

Data .

func NewData

func NewData(c *conf.Data, logger log.Logger) (_ *Data, err error)

NewData .

func (*Data) DB

func (data *Data) DB(ctx context.Context) *gorm.DB

DB Get tx from context, and create it if not exists.

func (*Data) ExecTx

func (data *Data) ExecTx(ctx context.Context, fn func(ctx context.Context) error) error

ExecTx Execute fn with data.db, then set tx to context

type ExtraInfo

type ExtraInfo map[string]interface{}

func (*ExtraInfo) Scan

func (a *ExtraInfo) Scan(value interface{}) error

Scan Unmarshal

func (ExtraInfo) Value

func (a ExtraInfo) Value() (driver.Value, error)

Value Marshal

type Model

type Model struct {
	CreateUser string `json:"createUser" gorm:"type:varchar(16)"`
	ModifyUser string `json:"modifyUser" gorm:"type:varchar(16)"`
	GmtCreate  string `json:"gmtCreate" gorm:"type:varchar(64)"`
	GmtModify  string `json:"gmtModify" gorm:"type:varchar(64)"`
	Deleted    int64  `json:"deleted" gorm:"uniqueIndex:CODE_DELETED"`
}

func (*Model) BeforeCreate

func (m *Model) BeforeCreate(tx *gorm.DB) (err error)

func (*Model) BeforeUpdate

func (m *Model) BeforeUpdate(tx *gorm.DB) (err error)

type RepoBase

type RepoBase struct{}

func (RepoBase) StringToPBStruct

func (b RepoBase) StringToPBStruct(source string) (*structpb.Struct, error)

func (RepoBase) Transform

func (b RepoBase) Transform(source, target interface{}) error

Transform convert two object of struct with json tag

Jump to

Keyboard shortcuts

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