db.go 7.53 KB
package DB

import (
	"gopkg.in/mgo.v2"
	"gopkg.in/mgo.v2/bson"
	"letu/Lib/Cache"
)

var Redis *Cache.Redis

var DBSession *mgo.Session
var CItem *mgo.Collection          //所有游玩项目内容
var CComplaint *mgo.Collection     //投诉
var CInvestigation *mgo.Collection //调查
var CMember *mgo.Collection        //会员
var CCommodity *mgo.Collection     //商城
var CTags *mgo.Collection          //标签
var CScenic *mgo.Collection        //景区
var CLine *mgo.Collection          //推荐线路
var CEventLog *mgo.Collection      //用户行为记录
var CActionLog *mgo.Collection     //操作记录
var CTrajectory *mgo.Collection    //移动轨迹
var DB *mgo.Database

type SItem struct {
	Id                  *bson.ObjectId `bson:"_id" json:"Id" valid:"required"`
	Name                string         `bson:"Name" json:"Name"`
	SubName             string         `bson:"SubName" json:"SubName"`
	Location            SLocation      `bson:"Location" json:"Location"`
	Tags                []STag         `bson:"Tags" json:"Tags"`
	Icon                string         `bson:"Icon" json:"Icon"`
	LimitHeight         string         `bson:"LimitHeight" json:"LimitHeight"`   //限高
	PlayDuration        string         `bson:"PlayDuration" json:"PlayDuration"` //游玩时长
	SceneTime           string         `bson:"SceneTime" json:"SceneTime"`       //场次时间
	Picture             []string       `bson:"Picture" json:"Picture"`
	Voice               string         `bson:"Voice" json:"Voice"` //音频
	Tel                 string         `bson:"Tel" json:"Tel"`
	AverageConsumption  string         `bson:"AverageConsumption" json:"AverageConsumption"` //人均消费
	Menu                string         `bson:"Menu" json:"Menu"`                             //目录
	Time                string         `bson:"Time" json:"Time"`
	OpenHours           string         `bson:"OpenHours" json:"OpenHours"`                     //开放时间
	LocationDescription string         `bson:"LocationDescription" json:"LocationDescription"` //位置描述
	Reminder            string         `bson:"Reminder" json:"Reminder"`                       //温馨提示
	State               int            `bson:"State" json:"State"`                             // 运行状态0=正常1=停运
}
type STrajectory struct {
	UserId   string    `bson:"UserId" json:"UserId"` // 用户ID
	Location SLocation `bson:"Location" json:"Location"`
	Time     int64     `bson:"Time" json:"Time"`
}
type SLocation struct {
	Latitude  float64 `bson:"Latitude" json:"Latitude"`   //纬度
	Longitude float64 `bson:"Longitude" json:"Longitude"` //经度
}
type SEventLog struct {
	UserId   string    `bson:"UserId" json:"UserId"`     // 用户ID
	UserName string    `bson:"UserName" json:"UserName"` //用户名称
	TypeNum  int64     `bson:"TypeNum" json:"TypeNum"`   //类型编号
	TypeName string    `bson:"TypeName" json:"TypeName"` //类型名称
	DateTime int64     `bson:"DateTime" json:"DateTime"` //时间戳
	Location SLocation `bson:"Location" json:"Location"` //位置
	Remarks  string    `bson:"Remarks" json:"Remarks"`   //备注
}
type SActionLog struct {
	UserId   string      `bson:"UserId" json:"UserId"`     // 用户ID
	UserName string      `bson:"UserName" json:"UserName"` //用户名称
	Mobile   string      `bson:"Mobile" json:"Mobile"`     //手机号
	TypeNum  int64       `bson:"TypeNum" json:"TypeNum"`   //类型编号
	TypeName string      `bson:"TypeName" json:"TypeName"` //类型名称
	DateTime int64       `bson:"DateTime" json:"DateTime"` //时间戳
	Location SLocation   `bson:"Location" json:"Location"` //位置
	Content  string      `bson:"Content" json:"Content"`   //内容
	Error    interface{} `bson:"Error" json:"Error"`       //错误信息
}
type SCommodity struct {
	Id       *bson.ObjectId `bson:"_id" json:"Id" valid:"required"`
	Name     string         `bson:"Name" json:"Name"`
	Price    string         `bson:"Price" json:"Price"`
	ShopName string         `bson:"ShopName" json:"ShopName"`
	ItemId   string         `bson:"ItemId" json:"ItemId"`     //项目id
	KvPhoto  string         `bson:"KvPhoto" json:"KvPhoto"`   //用于列表页的图片
	TopPhoto []SPicture     `bson:"TopPhoto" json:"TopPhoto"` //详情页最上面的轮播图
	Images   []string       `bson:"Images" json:"Images"`     //详情页下面的产品详细图
}
type SLine struct {
	Id           *bson.ObjectId `bson:"_id" json:"Id" valid:"required"`
	Name         string         `bson:"Name" json:"Name"`
	SubName      string         `bson:"SubName" json:"SubName"`   //游玩时长
	Location     []SLocation    `bson:"Location" json:"Location"` //线路点坐标
	PlayDuration string         `bson:"PlayDuration" json:"PlayDuration"`
	Suitable     string         `bson:"Suitable" json:"Suitable"` //适合人群
	Content      string         `bson:"Content" json:"Content"`
	Distance     string         `bson:"Distance" json:"Distance"`       // 距离
	Annotations  []string       `bson:"Annotations" json:"Annotations"` //需要点亮的设施id
}

type SComplaint struct {
	Type     string   `bson:"Type" json:"Type"`
	ScenicId string   `bson:"ScenicId" json:"ScenicId"` // 景区id
	Mobile   string   `bson:"Mobile" json:"Mobile"`
	FullName string   `bson:"FullName" json:"FullName"`
	Sex      string   `bson:"Sex" json:"Sex"`
	Content  string   `bson:"Content" json:"Content"`
	Image    []string `bson:"Image" json:"Image"`
}

type SInvestigation struct {
	UserId string      `bson:"UserId" json:"UserId"` // 用户ID
	Mobile string      `bson:"Mobile" json:"Mobile"` //手机号
	Data   interface{} `bson:"Data" json:"Data"`
}
type SMember struct {
	Id       *bson.ObjectId `bson:"_id" json:"Id" valid:"required"`
	Password string         `bson:"Password" json:"Password"`
	Birthday string         `bson:"Birthday" json:"Birthday"`
	FullName string         `bson:"FullName" json:"FullName"`
	Mobile   string         `bson:"Mobile" json:"Mobile"`
	Openid   string         `bson:"Openid" json:"Openid"`
	Token    string         `bson:"Token" json:"Token"`
	Sex      string         `bson:"Sex" json:"Sex"`
}

type STag struct {
	Type string `bson:"Type" json:"Type"`
	Name string `bson:"Name" json:"Name"`
}

type SPicture struct {
	Src  string `bson:"Src" json:"Src"`   // 地址,也可能是视频地址
	Link string `bson:"Link" json:"Link"` // 链接地址
}
type SVideo struct {
	Src          string `bson:"Src" json:"Src"`                   // 地址,也可能是视频地址
	Link         string `bson:"Link" json:"Link"`                 // 链接地址
	VideoPicture string `bson:"VideoPicture" json:"VideoPicture"` // 用于视频的首桢图
	Title        string `bson:"Title" json:"Title"`               // 标题
}
type SScenic struct {
	Id                *bson.ObjectId `bson:"_id" json:"Id" valid:"required"`
	Name              string         `bson:"Name" json:"Name"`
	Describe          string         `bson:"Describe" json:"Describe"`
	OpenHours         string         `bson:"OpenHours" json:"OpenHours"` //营业时间
	Mobile            string         `bson:"Mobile" json:"Mobile"`
	Address           string         `bson:"Address" json:"Address"`
	Location          SLocation      `bson:"Location" json:"Location"`
	Picture           []SPicture     `bson:"Picture" json:"Picture"`
	ShopAdPicture     []SPicture     `bson:"ShopAdPicture" json:"ShopAdPicture"`         //商城列表页图片
	ItemScenicPicture []SPicture     `bson:"ItemScenicPicture" json:"ItemScenicPicture"` //项目场次照片
	ActivityPicture   []SPicture     `bson:"ActivityPicture" json:"ActivityPicture"`     //活动照片
	VideoList         []SVideo       `bson:"VideoList" json:"VideoList"`
}