44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
package models
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
type FakerDate time.Time
|
|
|
|
const (
|
|
timeFormat = "2006-01-02"
|
|
)
|
|
|
|
func (t *FakerDate) UnmarshalJSON(data []byte) (err error) {
|
|
fmt.Println(string(data))
|
|
newTime, err := time.ParseInLocation(`"`+timeFormat+`"`, string(data), time.Local)
|
|
*t = FakerDate(newTime)
|
|
return
|
|
}
|
|
|
|
func (t FakerDate) MarshalJSON() ([]byte, error) {
|
|
fmt.Println(time.Time(t).Format(timeFormat))
|
|
timeStr := fmt.Sprintf("\"%s\"", time.Time(t).Format(timeFormat))
|
|
return []byte(timeStr), nil
|
|
}
|
|
|
|
func (t FakerDate) String() string {
|
|
return time.Time(t).Format(timeFormat)
|
|
}
|
|
|
|
type HotelContactRequest struct {
|
|
Name string `json:"name"`
|
|
Age int `json:"age,string"`
|
|
Sex int `json:"sex,string"`
|
|
Phone string `json:"phone"`
|
|
Address string `json:"address"`
|
|
HotelCode string `json:"hotel_code"`
|
|
HotelName string `json:"hotel_name"`
|
|
LocateCityId string `json:"locate_city_id"`
|
|
Identification string `json:"identification"`
|
|
InData FakerDate `json:"in_data"`
|
|
OutData FakerDate `json:"out_data"`
|
|
}
|