database

package
v0.0.0-...-14907fc Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnInit

func ConnInit()

func GetDBConn

func GetDBConn() *gorm.DB

func ModelInit

func ModelInit()

ModelInit 每次启动初始化数据库,便于更改数据库结构

Types

type Event

type Event struct {
	/*
		One "event" has one "product"
	*/
	gorm.Model
	Name        string    `gorm:"type:varchar(100);not null"`
	EventPrice  float32   `gorm:"type:float;not null"`
	EventNum    int       `gorm:"type:int;not null"`
	StartTime   time.Time `gorm:"type:datetime;not null"`
	EndTime     time.Time `gorm:"type:datetime;not null"`
	Description string    `gorm:"type:varchar(200)"`
	ProductId   uint      `gorm:"type:int"`
}

type Product

type Product struct {
	/*
		One "product" has many "event"
	*/
	gorm.Model
	Name        string  `gorm:"type:varchar(100);not null"`
	Price       float32 `gorm:"type:float;not null"`
	LeftNum     int     `gorm:"type:int;not null"`
	Unit        string  `gorm:"type:varchar(50);not null"`
	Picture     string  `gorm:"type:varchar(100)"`
	Description string  `gorm:"type:varchar(200)"`
	Events      []Event `gorm:"foreignKey:ProductID;references:ID;constraint:OnDelete:SET NULL"`
}

Jump to

Keyboard shortcuts

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