entity

package
v0.0.0-...-10680b3 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UnknownRelationType = iota
	QQ
	Tel
	Email
	Address
)

Variables

View Source
var RelationTypeMap = map[int]string{
	UnknownRelationType: "unknown",
	QQ:                  "qq",
	Tel:                 "tel",
	Email:               "email",
	Address:             "address",
}

Functions

func RelationTypeToString

func RelationTypeToString(tp int) string

Types

type Contact

type Contact struct {
	xdb.Entity
	SupplierId int64      `gorm:"column:supplier_id;NOT NULL" json:"supplier_id"` // 供货商ID
	Firstname  string     `gorm:"column:firstname;NOT NULL" json:"firstname"`     // 名
	Lastname   string     `gorm:"column:lastname;NOT NULL" json:"lastname"`       // 姓
	Title      string     `gorm:"column:title;NOT NULL" json:"title"`             // 职称
	Relations  []Relation `gorm:"ForeignKey:contact_id"`
	xdb.CUDTime
}

func (*Contact) GetRelations

func (c *Contact) GetRelations(ctx context.Context, db *gorm.DB) []Relation

func (Contact) TableName

func (c Contact) TableName() string

type Relation

type Relation struct {
	xdb.Entity
	ContactId int64  `gorm:"column:contact_id;NOT NULL" json:"contact_id"`
	Type      int    `gorm:"column:type;NOT NULL" json:"type"`   // 联系方式类型
	Value     string `gorm:"column:value;NOT NULL" json:"value"` // 联系方式值
	xdb.CUDTime
}

func (Relation) TableName

func (Relation) TableName() string

type Supplier

type Supplier struct {
	xdb.Entity
	Name     string    `gorm:"column:name;NOT NULL" json:"name"`       // 供货商名称
	Address  string    `gorm:"column:address;NOT NULL" json:"address"` // 供货商地址
	Contacts []Contact `gorm:"ForeignKey:supplier_id"`
	xdb.CUDTime
}

func (*Supplier) GetContacts

func (s *Supplier) GetContacts(ctx context.Context, db *gorm.DB) []Contact

func (Supplier) TableName

func (s Supplier) TableName() string

Jump to

Keyboard shortcuts

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