models

package
v0.0.0-...-fea8a0b Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2021 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ORDER_STATUS_WAIT_ACCEPT  = "WAIT_ACCEPT"
	ORDER_STATUS_WAIT_PAYMENT = "WAIT_PAYMENT"
	ORDER_STATUS_PAID         = "PAID"
	ORDER_STATUS_WAIT_COMMENT = "WAIT_COMMENT"
	ORDER_STATUS_COMPLETE     = "COMPLETE"
	ORDER_STATUS_CANCELED     = "CONCELED"
	ORDER_STATUS_REJECTED     = "REJECTED"
)

Variables

View Source
var HOME_PAGE_MAX_HOUSES int = 5
View Source
var HOUSE_LIST_PAGE_CAPACITY int = 2

Functions

func DataTableInit

func DataTableInit(db *gorm.DB)

func GetGorm

func GetGorm() *gorm.DB

func Init

func Init()

Types

type Area

type Area struct {
	//gorm.Model
	ID     int      `json:"area_id"`
	Name   string   `gorm:"size:32" json:"area_name"`
	Houses []*House `json:"houses"`
}

type Facility

type Facility struct {
	ID     int      `json:"fid"`
	Name   string   `gorm:"size:32"`
	Houses []*House `gorm:"many2many:house_facilities"`
}

type House

type House struct {
	//gorm.Model
	ID              int           `json:"house_id"`
	UserID          uint          `json:"user_id"`
	AreaID          uint          `json:"area_id"`
	Title           string        `gorm:"size:64" json:"title"`
	Price           int           `gorm:"default:0" json:"price"`
	Address         string        `gorm:"size:512;default:''" json:"address"`
	Room_count      int           `gorm:"default:1" json:"room_count"`
	Acreage         int           `gorm:"default:0" json:"acreage"`
	Unit            string        `gorm:"size:32;default:''" json:"unit"`
	Capacity        int           `gorm:"default:1" json:"capacity"`
	Beds            string        `gorm:"size:64;default:''" json:"beds"`
	Deposit         int           `gorm:"default:0" json:"deposit"`
	Min_days        int           `gorm:"default:1" json:"min_days"`
	Max_days        int           `gorm:"default:0" json:"max_days"`
	Order_count     int           `gorm:"default:0" json:"order_count"`
	Index_image_url string        `gorm:"size:256;default:''" json:"index_image_url"`
	Facilities      []*Facility   `gorm:"many2many:house_facilities;" json:"facilities"`
	Images          []*HouseImage `json:"img_urls"`
	Orders          []*OrderHouse `json:"orders"`
	Ctime           time.Time     `gorm:"autoCreateTime" json:"ctime"`
}

func (*House) To_house_info

func (this *House) To_house_info() interface{}

func (*House) To_one_house_desc

func (this *House) To_one_house_desc() interface{}

type HouseImage

type HouseImage struct {
	ID      int    `json:"house_image_id"`
	Url     string `gorm:"size:256" json:"url"`
	HouseID uint   `json:"house_id"`
}

type OrderHouse

type OrderHouse struct {
	ID          int       `json:"order_id"`
	UserID      uint      `json:"user_id"`
	HouseID     uint      `json:"house_id"`
	Begin_date  time.Time `gorm:"type:time"`
	End_date    time.Time `gorm:"type:time"`
	Days        int
	House_price int
	Amount      int
	Status      string    `gorm:"default:'WAIT_ACCEPT'"`
	Comment     string    `gorm:"size:512"`
	Ctime       time.Time `gorm:"autoCreateTime" json:"ctime"`
	Credit      bool
}

func (*OrderHouse) To_order_info

func (this *OrderHouse) To_order_info() interface{}

type User

type User struct {
	//gorm.Model, we only need the p-key, so it's necessary to add the gorm.model
	Uid           string `gorm:"primary_key;size:256" json:"user_id"`
	Name          string `gorm:"size:50"  json:"name"`
	Password_hash string `gorm:"size:256" json:"password"`
	Email         string `gorm:"size:50;unique"  json:"email"`
	Real_name     string `gorm:"size:32" json:"real_name"`
	Id_card       string `gorm:"size:20" json:"id_card"`
	Avatar_url    string `gorm:"size:256" json:"avatar_url"`
	//one to many, `gorm:"foreignKey:UserID"`
	Houses []*House      `json:"houses"`
	Orders []*OrderHouse `json:"orders"`
}

Jump to

Keyboard shortcuts

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