Documentation ¶
Overview ¶
This file contain functions for operating a database
Index ¶
- func AllAppointments(from, to time.Time, userid uint, appointments *[]Appointment) (err error)
- func Close() error
- func Connect()
- func GetAppointments(UserID uint, a *[]Appointment)
- func GetPrice(option WashOption) string
- func Migrate()
- func Reset()
- func Seed()
- type Appointment
- type Car
- type CarType
- type IgnoreTimeModel
- type User
- type WashOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllAppointments ¶
func AllAppointments(from, to time.Time, userid uint, appointments *[]Appointment) (err error)
func GetAppointments ¶
func GetAppointments(UserID uint, a *[]Appointment)
func GetPrice ¶
func GetPrice(option WashOption) string
Types ¶
type Appointment ¶
type Appointment struct { IgnoreTimeModel UserID uint `json:",omitempty"` //DateTime string `gorm:"-"` //Time time.Time `json:"-" gorm:"unique;not null"` Time time.Time `binding:"required" gorm:"unique" json:",omitempty"` Option WashOption `json:",omitempty" binding:"min=1,max=3"` Comment string `json:",omitempty"` Car User *User `json:",omitempty" binding:"isdefault"` }
func (*Appointment) Create ¶
func (a *Appointment) Create(UserID uint) error
func (*Appointment) Delete ¶
func (a *Appointment) Delete(UserID uint) (NotFound bool)
query and delete
func (*Appointment) MarshallTime ¶
func (a *Appointment) MarshallTime() (err error)
marshall time and check valid valid hour should be [8, 12), [13, 17) deprecated
func (*Appointment) Update ¶
func (a *Appointment) Update(UserID uint)
type IgnoreTimeModel ¶
type IgnoreTimeModel struct { ID uint `gorm:"primary_key"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` DeletedAt *time.Time `json:"-";sql:"index"` }
basic database model that ignore time information when perform json marshalling
type User ¶
type User struct { IgnoreTimeModel Password string `json:",omitempty"` Admin bool `binding:"isdefault" gorm:"default:false" json:",omitempty"` FirstName string `binding:"required"` LastName string `binding:"required"` Email string `gorm:"unique;not null" binding:"required,email" json:",omitempty"` Mobile string `json:",omitempty"` Home string `json:",omitempty"` Work string `json:",omitempty"` Address string `json:",omitempty"` CarInfo string `json:",omitempty"` Car // contains filtered or unexported fields }
func (*User) BeforeCreate ¶
before create, hashing password
type WashOption ¶
type WashOption uint
const ( WashOptionNone WashOption = iota WashOut WashInAndOut WashDelux )
Click to show internal directories.
Click to hide internal directories.