model

package
v0.0.0-...-54086b0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2025 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Status_name = map[int32]string{
		0: "UNKNOWN",
		1: "PENDING",
	}
	Status_value = map[string]int32{
		"UNKNOWN": 0,
		"PENDING": 1,
	}
)

Enum value maps for Status.

View Source
var File_model_proto protoreflect.FileDescriptor

Functions

func AutoMigrate

func AutoMigrate(db *gorm.DB, dst ...interface{}) error

func Count

func Count(ctx context.Context, db *gorm.DB, model interface{}, opts ...Option) (int64, error)

func Create

func Create(ctx context.Context, db *gorm.DB, model interface{}, opts ...Option) error

func Delete

func Delete(ctx context.Context, db *gorm.DB, model interface{}, opts ...Option) error

func Find

func Find(ctx context.Context, db *gorm.DB, model interface{}, opts ...Option) error

func FindForUpdate

func FindForUpdate(ctx context.Context, db *gorm.DB, model interface{}, opts ...Option) error

func First

func First(ctx context.Context, db *gorm.DB, model interface{}, opts ...Option) error

func FirstForUpdate

func FirstForUpdate(ctx context.Context, db *gorm.DB, model interface{}, opts ...Option) error

func IsDBClosure

func IsDBClosure(opt Option) bool

func PartialUpdate

func PartialUpdate(ctx context.Context, db *gorm.DB, model interface{}, fields map[string]interface{}, opts ...Option) error

func Save

func Save(ctx context.Context, db *gorm.DB, model interface{}, opts ...Option) error

func Scan

func Scan(data interface{}, value interface{}) error

Scan for scanner helper

func UnscopedDelete

func UnscopedDelete(ctx context.Context, db *gorm.DB, model interface{}, opts ...Option) error

func Value

func Value(data interface{}) (interface{}, error)

Value for valuer helper

Types

type Author

type Author struct {
	Name  string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Email string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"`
	// contains filtered or unexported fields
}

func (*Author) Descriptor deprecated

func (*Author) Descriptor() ([]byte, []int)

Deprecated: Use Author.ProtoReflect.Descriptor instead.

func (*Author) GetEmail

func (x *Author) GetEmail() string

func (*Author) GetName

func (x *Author) GetName() string

func (*Author) ProtoMessage

func (*Author) ProtoMessage()

func (*Author) ProtoReflect

func (x *Author) ProtoReflect() protoreflect.Message

func (*Author) Reset

func (x *Author) Reset()

func (*Author) String

func (x *Author) String() string

type Option

type Option func(*gorm.DB) *gorm.DB

func DB

func DB(db *gorm.DB) Option

func Limit

func Limit(limit int) Option

func Offset

func Offset(offset int) Option

func Order

func Order(value interface{}) Option

func Select

func Select(fields ...string) Option

func StudentModelId

func StudentModelId(x int32) Option

func TableName

func TableName(name string) Option

func UserModelAddress

func UserModelAddress(x string) Option

func UserModelId

func UserModelId(x int32) Option

func UserModelName

func UserModelName(x string) Option

type Status

type Status int32
const (
	Status_UNKNOWN Status = 0
	Status_PENDING Status = 1
)

func (Status) Descriptor

func (Status) Descriptor() protoreflect.EnumDescriptor

func (Status) Enum

func (x Status) Enum() *Status

func (Status) EnumDescriptor deprecated

func (Status) EnumDescriptor() ([]byte, []int)

Deprecated: Use Status.Descriptor instead.

func (Status) Number

func (x Status) Number() protoreflect.EnumNumber

func (Status) String

func (x Status) String() string

func (Status) Type

func (Status) Type() protoreflect.EnumType

type Student

type Student struct {
	Id          int32                `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	Name        string               `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	Address     string               `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"`
	Phone       string               `protobuf:"bytes,4,opt,name=phone,proto3" json:"phone,omitempty"`
	Score       float32              `protobuf:"fixed32,5,opt,name=score,proto3" json:"score,omitempty"`
	CreateTime  *timestamp.Timestamp `protobuf:"bytes,6,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty"`
	UpdateTime  *timestamp.Timestamp `protobuf:"bytes,7,opt,name=update_time,json=updateTime,proto3" json:"update_time,omitempty"`
	DeletedTime *timestamp.Timestamp `protobuf:"bytes,8,opt,name=deleted_time,json=deletedTime,proto3" json:"deleted_time,omitempty"`
	// contains filtered or unexported fields
}

func (*Student) Descriptor deprecated

func (*Student) Descriptor() ([]byte, []int)

Deprecated: Use Student.ProtoReflect.Descriptor instead.

func (*Student) GetAddress

func (x *Student) GetAddress() string

func (*Student) GetCreateTime

func (x *Student) GetCreateTime() *timestamp.Timestamp

func (*Student) GetDeletedTime

func (x *Student) GetDeletedTime() *timestamp.Timestamp

func (*Student) GetId

func (x *Student) GetId() int32

func (*Student) GetName

func (x *Student) GetName() string

func (*Student) GetPhone

func (x *Student) GetPhone() string

func (*Student) GetScore

func (x *Student) GetScore() float32

func (*Student) GetUpdateTime

func (x *Student) GetUpdateTime() *timestamp.Timestamp

func (*Student) ProtoMessage

func (*Student) ProtoMessage()

func (*Student) ProtoReflect

func (x *Student) ProtoReflect() protoreflect.Message

func (*Student) Reset

func (x *Student) Reset()

func (*Student) String

func (x *Student) String() string

func (*Student) StudentModel

func (x *Student) StudentModel() (*StudentModel, error)

type StudentDao

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

func NewStudentDao

func NewStudentDao(db *gorm.DB) *StudentDao

func (*StudentDao) Count

func (dao *StudentDao) Count(ctx context.Context, opts ...Option) (int64, error)

func (*StudentDao) Create

func (dao *StudentDao) Create(ctx context.Context, model *StudentModel, opts ...Option) (*StudentModel, error)

func (*StudentDao) Delete

func (dao *StudentDao) Delete(ctx context.Context, opts ...Option) error

func (*StudentDao) DeleteUnscoped

func (dao *StudentDao) DeleteUnscoped(ctx context.Context, opts ...Option) error

func (*StudentDao) Find

func (dao *StudentDao) Find(ctx context.Context, opts ...Option) ([]*StudentModel, error)

func (*StudentDao) FindForUpdate

func (dao *StudentDao) FindForUpdate(ctx context.Context, opts ...Option) ([]*StudentModel, error)

func (*StudentDao) First

func (dao *StudentDao) First(ctx context.Context, opts ...Option) (*StudentModel, error)

func (*StudentDao) FirstForUpdate

func (dao *StudentDao) FirstForUpdate(ctx context.Context, opts ...Option) (*StudentModel, error)

func (*StudentDao) PartialUpdate

func (dao *StudentDao) PartialUpdate(ctx context.Context, model *StudentModel, fields map[string]interface{}, opts ...Option) (*StudentModel, error)

func (*StudentDao) Save

func (dao *StudentDao) Save(ctx context.Context, model *StudentModel, opts ...Option) (*StudentModel, error)

type StudentModel

type StudentModel struct {
	Id          int32          `gorm:"column:id;type:bigint;primaryKey" json:"id,omitempty"`
	Name        string         `gorm:"column:name" json:"name,omitempty"`
	Address     string         `gorm:"column:address" json:"address,omitempty"`
	Phone       string         `gorm:"column:phone" json:"phone,omitempty"`
	Score       float32        `gorm:"column:score" json:"score,omitempty"`
	CreateTime  time.Time      `gorm:"column:create_time;type:datetime;autoCreateTime;not null" json:"create_time,omitempty"`
	UpdateTime  time.Time      `gorm:"column:update_time;type:datetime;autoUpdateTime;not null" json:"update_time,omitempty"`
	DeletedTime gorm.DeletedAt `gorm:"column:deleted_time;type:datetime;index:idx_deleted_time" json:"deleted_time,omitempty"`
}

GormModel is an option for Student

func (*StudentModel) Student

func (x *StudentModel) Student() (*Student, error)

func (*StudentModel) TableName

func (x *StudentModel) TableName() string

type User

type User struct {
	Id          int32                `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	Name        string               `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	Email       string               `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"`
	Address     string               `protobuf:"bytes,4,opt,name=address,proto3" json:"address,omitempty"`
	Phone       string               `protobuf:"bytes,5,opt,name=phone,proto3" json:"phone,omitempty"`
	Score       float32              `protobuf:"fixed32,6,opt,name=score,proto3" json:"score,omitempty"`
	Balance     float64              `protobuf:"fixed64,7,opt,name=balance,proto3" json:"balance,omitempty"`
	CreateTime  *timestamp.Timestamp `protobuf:"bytes,8,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty"`
	UpdateTime  *timestamp.Timestamp `protobuf:"bytes,9,opt,name=update_time,json=updateTime,proto3" json:"update_time,omitempty"`
	DeletedTime *timestamp.Timestamp `protobuf:"bytes,11,opt,name=deleted_time,json=deletedTime,proto3" json:"deleted_time,omitempty"`
	Date        *timestamp.Timestamp `protobuf:"bytes,10,opt,name=date,proto3" json:"date,omitempty"`
	Extra       []byte               `protobuf:"bytes,12,opt,name=extra,proto3" json:"extra,omitempty"`
	Author      *User_Author         `protobuf:"bytes,13,opt,name=author,proto3" json:"author,omitempty"`
	Status      Status               `protobuf:"varint,14,opt,name=status,proto3,enum=model.Status" json:"status,omitempty"`
	Status1     Status               `protobuf:"varint,15,opt,name=status1,proto3,enum=model.Status" json:"status1,omitempty"`
	Status2     Status               `protobuf:"varint,16,opt,name=status2,proto3,enum=model.Status" json:"status2,omitempty"`
	T1          int64                `protobuf:"varint,18,opt,name=t1,proto3" json:"t1,omitempty"`
	T2          uint64               `protobuf:"varint,19,opt,name=t2,proto3" json:"t2,omitempty"`
	T3          string               `protobuf:"bytes,20,opt,name=t3,proto3" json:"t3,omitempty"`
	D1          int64                `protobuf:"varint,21,opt,name=d1,proto3" json:"d1,omitempty"`
	Ids         []int32              `protobuf:"varint,22,rep,packed,name=ids,proto3" json:"ids,omitempty"`
	M1          map[string]string    `` /* 146-byte string literal not displayed */
	// contains filtered or unexported fields
}

func (*User) Descriptor deprecated

func (*User) Descriptor() ([]byte, []int)

Deprecated: Use User.ProtoReflect.Descriptor instead.

func (*User) GetAddress

func (x *User) GetAddress() string

func (*User) GetAuthor

func (x *User) GetAuthor() *User_Author

func (*User) GetBalance

func (x *User) GetBalance() float64

func (*User) GetCreateTime

func (x *User) GetCreateTime() *timestamp.Timestamp

func (*User) GetD1

func (x *User) GetD1() int64

func (*User) GetDate

func (x *User) GetDate() *timestamp.Timestamp

func (*User) GetDeletedTime

func (x *User) GetDeletedTime() *timestamp.Timestamp

func (*User) GetEmail

func (x *User) GetEmail() string

func (*User) GetExtra

func (x *User) GetExtra() []byte

func (*User) GetId

func (x *User) GetId() int32

func (*User) GetIds

func (x *User) GetIds() []int32

func (*User) GetM1

func (x *User) GetM1() map[string]string

func (*User) GetName

func (x *User) GetName() string

func (*User) GetPhone

func (x *User) GetPhone() string

func (*User) GetScore

func (x *User) GetScore() float32

func (*User) GetStatus

func (x *User) GetStatus() Status

func (*User) GetStatus1

func (x *User) GetStatus1() Status

func (*User) GetStatus2

func (x *User) GetStatus2() Status

func (*User) GetT1

func (x *User) GetT1() int64

func (*User) GetT2

func (x *User) GetT2() uint64

func (*User) GetT3

func (x *User) GetT3() string

func (*User) GetUpdateTime

func (x *User) GetUpdateTime() *timestamp.Timestamp

func (*User) ProtoMessage

func (*User) ProtoMessage()

func (*User) ProtoReflect

func (x *User) ProtoReflect() protoreflect.Message

func (*User) Reset

func (x *User) Reset()

func (*User) String

func (x *User) String() string

func (*User) UserModel

func (x *User) UserModel() (*UserModel, error)

type UserDao

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

func NewUserDao

func NewUserDao(db *gorm.DB) *UserDao

func (*UserDao) Count

func (dao *UserDao) Count(ctx context.Context, opts ...Option) (int64, error)

func (*UserDao) Create

func (dao *UserDao) Create(ctx context.Context, model *UserModel, opts ...Option) (*UserModel, error)

func (*UserDao) Delete

func (dao *UserDao) Delete(ctx context.Context, opts ...Option) error

func (*UserDao) DeleteUnscoped

func (dao *UserDao) DeleteUnscoped(ctx context.Context, opts ...Option) error

func (*UserDao) Find

func (dao *UserDao) Find(ctx context.Context, opts ...Option) ([]*UserModel, error)

func (*UserDao) FindForUpdate

func (dao *UserDao) FindForUpdate(ctx context.Context, opts ...Option) ([]*UserModel, error)

func (*UserDao) First

func (dao *UserDao) First(ctx context.Context, opts ...Option) (*UserModel, error)

func (*UserDao) FirstForUpdate

func (dao *UserDao) FirstForUpdate(ctx context.Context, opts ...Option) (*UserModel, error)

func (*UserDao) PartialUpdate

func (dao *UserDao) PartialUpdate(ctx context.Context, model *UserModel, fields map[string]interface{}, opts ...Option) (*UserModel, error)

func (*UserDao) Save

func (dao *UserDao) Save(ctx context.Context, model *UserModel, opts ...Option) (*UserModel, error)

type UserModel

type UserModel struct {
	Id          int32             `gorm:"column:id;type:bigint;primaryKey" json:"id,omitempty"`
	Name        string            `gorm:"column:name;index:idx_name_addr,unique" json:"name,omitempty"`
	Email       string            `gorm:"column:email" json:"email,omitempty"`
	Address     string            `gorm:"column:address;index:idx_name_addr,unique" json:"address,omitempty"`
	Phone       string            `gorm:"column:phone" json:"phone,omitempty"`
	Score       float32           `gorm:"column:score;type:decimal(10,2) unsigned;not null" json:"score,omitempty"`
	Balance     float64           `gorm:"column:balance" json:"balance,omitempty"`
	CreateTime  time.Time         `gorm:"column:create_time;type:datetime;autoCreateTime;not null" json:"create_time,omitempty"`
	UpdateTime  time.Time         `gorm:"column:update_time;type:datetime;autoUpdateTime;not null" json:"update_time,omitempty"`
	DeletedTime gorm.DeletedAt    `gorm:"column:deleted_time;type:datetime;index:idx_deleted_time" json:"deleted_time,omitempty"`
	Date        datatypes.Date    `gorm:"column:date;type:date" json:"date,omitempty"`
	Extra       []byte            `gorm:"column:extra;type:tinyblob;default:'abc'" json:"extra,omitempty"`
	Author      *User_AuthorModel `gorm:"-" json:"author,omitempty"`
	Status      string            `gorm:"column:status;type:enum('PENDING','UNKNOWN');default:'UNKNOWN'" json:"status,omitempty"`
	Status1     string            `gorm:"column:status1;default:'UNKNOWN'" json:"status1,omitempty"`
	Status2     Status            `gorm:"column:status2;type:int;default:0" json:"status2,omitempty"`
	T1          time.Time         `gorm:"column:t1;type:datetime;autoCreateTime;not null" json:"t1,omitempty"`
	T2          time.Time         `gorm:"column:t2;type:datetime;autoUpdateTime;not null" json:"t2,omitempty"`
	T3          time.Time         `gorm:"column:t3;type:datetime;not null" json:"t3,omitempty"`
	D1          datatypes.Date    `gorm:"column:d1;type:date" json:"d1,omitempty"`
	Ids         UserModelIdsList  `gorm:"column:ids;type:longtext" json:"ids,omitempty"`
	M1          UserModelM1Map    `gorm:"column:m1;type:longtext" json:"m1,omitempty"`
}

GormModel is an option for User

func (*UserModel) TableName

func (x *UserModel) TableName() string

func (*UserModel) User

func (x *UserModel) User() (*User, error)

type UserModelIdsList

type UserModelIdsList []int32

func (*UserModelIdsList) Scan

func (x *UserModelIdsList) Scan(value interface{}) error

func (UserModelIdsList) Value

func (x UserModelIdsList) Value() (driver.Value, error)

type UserModelM1Map

type UserModelM1Map map[string]string

func (*UserModelM1Map) Scan

func (x *UserModelM1Map) Scan(value interface{}) error

func (UserModelM1Map) Value

func (x UserModelM1Map) Value() (driver.Value, error)

type User_Author

type User_Author struct {
	Name  string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Email string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"`
	// contains filtered or unexported fields
}

func (*User_Author) Descriptor deprecated

func (*User_Author) Descriptor() ([]byte, []int)

Deprecated: Use User_Author.ProtoReflect.Descriptor instead.

func (*User_Author) GetEmail

func (x *User_Author) GetEmail() string

func (*User_Author) GetName

func (x *User_Author) GetName() string

func (*User_Author) ProtoMessage

func (*User_Author) ProtoMessage()

func (*User_Author) ProtoReflect

func (x *User_Author) ProtoReflect() protoreflect.Message

func (*User_Author) Reset

func (x *User_Author) Reset()

func (*User_Author) String

func (x *User_Author) String() string

func (*User_Author) User_AuthorModel

func (x *User_Author) User_AuthorModel() (*User_AuthorModel, error)

type User_AuthorModel

type User_AuthorModel struct {
	Name  string `gorm:"column:name" json:"name,omitempty"`
	Email string `gorm:"column:email" json:"email,omitempty"`
}

GormModel is an option for User_Author

func (*User_AuthorModel) User_Author

func (x *User_AuthorModel) User_Author() (*User_Author, error)

Jump to

Keyboard shortcuts

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