164 lines
5.8 KiB
Go
164 lines
5.8 KiB
Go
package schema
|
|
|
|
import (
|
|
"github.guxuan/haibei/pkg/util"
|
|
)
|
|
|
|
// Defining the `Activity` struct.
|
|
type House struct {
|
|
util.BaseModel
|
|
Name string `json:"name" gorm:"size:128;not null;index;comment:名字"`
|
|
Title string `json:"title" gorm:"size:128;not null;index;comment:标题"`
|
|
Cover string `json:"cover" gorm:"size:2048;not null;comment:封面"`
|
|
Price string `json:"price" gorm:"comment:价格"`
|
|
Labels *[]string `json:"labels" gorm:"serializer:json;comment:标签数组"`
|
|
Images *[]string `json:"images" gorm:"serializer:json;comment:详图数组"`
|
|
Videos *[]string `json:"videos" gorm:"serializer:json;comment:视频数组"`
|
|
WatchAvatars *[]string `json:"watchAvatars" gorm:"serializer:json;comment:围观人数头像"`
|
|
WatchNum int `json:"watchNum" gorm:"size:11;comment:围观人数"`
|
|
Area float64 `json:"area" gorm:"not null;comment:占地面积"`
|
|
OpenAt string `json:"openAt" gorm:"comment:开盘时间"`
|
|
MasterType string `json:"masterType" gorm:"comment:主力户型"`
|
|
Address string `json:"address" gorm:"size:1024;not null;comment:楼盘地址"`
|
|
Latitude float64 `json:"latitude" gorm:"comment:经度"`
|
|
Longitude float64 `json:"longitude" gorm:"comment:维度"`
|
|
LayOuts *[]LayOut `json:"layOuts" gorm:"serializer:json;comment:户型图数组"`
|
|
Advisers *[]Adviser `json:"advisers" gorm:"serializer:json;comment:顾问数组"`
|
|
AreaID uint `json:"areaId" gorm:"index;comment:城市id"`
|
|
Detail Detail `json:"detail" gorm:"serializer:json;comment:项目详情"`
|
|
Surroundings *Surroundings `json:"surroundings" gorm:"serializer:json;comment:周边设施"`
|
|
Status string `json:"status" gorm:"size:20;index;comment:状态"`
|
|
}
|
|
type Detail struct {
|
|
BasicInfo BasicInfo `json:"basicInfo"`
|
|
SalesInfo SalesInfo `json:"salesInfo"`
|
|
CommunityInfo CommunityInfo `json:"communityInfo"`
|
|
}
|
|
|
|
type BasicInfo struct {
|
|
Area string `json:"area"`
|
|
Address string `json:"address"`
|
|
Typer string `json:"type"`
|
|
UnitStruct string `json:"unitStruct"`
|
|
Status string `json:"status"`
|
|
MasterType string `json:"masterType"`
|
|
ShowAddress string `json:"showAddress"`
|
|
BuildingArea string `json:"buildingarea"`
|
|
}
|
|
type SalesInfo struct {
|
|
Status string `json:"status"`
|
|
Duration string `json:"duration"`
|
|
SalesType string `json:"salesType"`
|
|
SalesAddress string `json:"salesAddress"`
|
|
SalesPhone string `json:"salesPhone"`
|
|
}
|
|
type CommunityInfo struct {
|
|
PackingNum string `json:"packingNum"`
|
|
RoomNUM string `json:"roomNUM"`
|
|
GreeningRate string `json:"greeningRate"`
|
|
R19009Ratio string `json:"r19009Ratio"`
|
|
R19010Ratio string `json:"r19010Ratio"`
|
|
R19011Ratio string `json:"r19011Ratio"`
|
|
PropertyType string `json:"propertyType"`
|
|
PropertyName string `json:"propertyName"`
|
|
PropertyPrice string `json:"propertyPrice"`
|
|
}
|
|
type Surroundings struct {
|
|
BusNum int `json:"busNum"`
|
|
SchoolNum int `json:"schoolNum"`
|
|
HospitalNum int `json:"hospitalNum"`
|
|
LifeNum int `json:"lifeNum"`
|
|
MetroNum int `json:"metroNum"`
|
|
}
|
|
type LayOut struct {
|
|
Img string `json:"img"`
|
|
Title string `json:"title"`
|
|
Price string `json:"price"`
|
|
Labels *[]string `json:"labels"`
|
|
Area float64 `json:"area"`
|
|
Direction string `json:"direction"`
|
|
}
|
|
type Adviser struct {
|
|
Avatar string `json:"avatar"`
|
|
Name string `json:"name"`
|
|
Phone string `json:"phone"`
|
|
}
|
|
|
|
// Defining the query parameters for the `Activity` struct.
|
|
type HouseQueryParam struct {
|
|
util.PaginationParam
|
|
LikeName string `form:"name" `
|
|
LikeTitle string `form:"title" `
|
|
Status string `form:"status" `
|
|
AreaID uint `form:"areaId"`
|
|
}
|
|
|
|
// Defining the query options for the `Activity` struct.
|
|
type HouseQueryOptions struct {
|
|
util.QueryOptions
|
|
}
|
|
|
|
// Defining the query result for the `Activity` struct.
|
|
type HouseQueryResult struct {
|
|
Data Houses
|
|
PageResult *util.PaginationResult
|
|
}
|
|
|
|
// Defining the slice of `Activity` struct.
|
|
type Houses []*House
|
|
|
|
// Defining the data structure for creating a `Activity` struct.
|
|
type HouseForm struct {
|
|
Name string `json:"name" `
|
|
Title string `json:"title" `
|
|
Cover string `json:"cover" `
|
|
Price string `json:"price" `
|
|
Labels *[]string `json:"labels" `
|
|
Images *[]string `json:"images" `
|
|
Videos *[]string `json:"videos"`
|
|
WatchAvatars *[]string `json:"watchAvatars" `
|
|
WatchNum int `json:"watchNum" `
|
|
Area float64 `json:"area" `
|
|
OpenAt string `json:"openAt"`
|
|
MasterType string `json:"masterType" `
|
|
Address string `json:"address" `
|
|
Latitude float64 `json:"latitude" `
|
|
Longitude float64 `json:"longitude" `
|
|
LayOuts *[]LayOut `json:"layOuts" `
|
|
Advisers *[]Adviser `json:"advisers" `
|
|
AreaID uint `json:"areaId" `
|
|
Detail Detail `json:"detail" `
|
|
Surroundings *Surroundings `json:"surroundings"`
|
|
Status string `json:"status" `
|
|
}
|
|
|
|
// A validation function for the `ActivityForm` struct.
|
|
func (a *HouseForm) Validate() error {
|
|
return nil
|
|
}
|
|
|
|
// Convert `ActivityForm` to `Activity` object.
|
|
func (a *HouseForm) FillTo(house *House) error {
|
|
house.Name = a.Name
|
|
house.Title = a.Title
|
|
house.Cover = a.Cover
|
|
house.Price = a.Price
|
|
house.Labels = a.Labels
|
|
house.Images = a.Images
|
|
house.Videos = a.Videos
|
|
house.WatchAvatars = a.WatchAvatars
|
|
house.WatchNum = a.WatchNum
|
|
house.Area = a.Area
|
|
house.OpenAt = a.OpenAt
|
|
house.MasterType = a.MasterType
|
|
house.Address = a.Address
|
|
house.Latitude = a.Latitude
|
|
house.Longitude = a.Longitude
|
|
house.LayOuts = a.LayOuts
|
|
house.Advisers = a.Advisers
|
|
house.AreaID = a.AreaID
|
|
house.Detail = a.Detail
|
|
house.Status = a.Status
|
|
return nil
|
|
}
|