db.go 15.4 KB
package DB

import (
	"go.mongodb.org/mongo-driver/bson/primitive"
	"go.mongodb.org/mongo-driver/mongo"
	"letu/Lib/Cache"
)

var Redis *Cache.Redis

var CItem *mongo.Collection          //所有游玩项目内容
var CComplaint *mongo.Collection     //投诉
var CInvestigation *mongo.Collection //调查
var CMember *mongo.Collection        //会员
var CCommodity *mongo.Collection     //商城
var CTags *mongo.Collection          //标签
var CScenic *mongo.Collection        //景区
var CLine *mongo.Collection          //推荐线路
var CUserLog *mongo.Collection       //用户行为记录
var COperatorLog *mongo.Collection   //操作员log
var CSystemLog *mongo.Collection     //操作记录
var CTrajectory *mongo.Collection    //移动轨迹
var CIcons *mongo.Collection         //图标信息
var CDevice *mongo.Collection        //设备清单
var CNotice *mongo.Collection        //公告
var CTopMenus *mongo.Collection      //菜单
var CSysAds *mongo.Collection        //平台广告
var DB *mongo.Database

type SScenic struct {
	Id                *primitive.ObjectID `bson:"_id" json:"Id" valid:"required"`
	Name              string              `bson:"Name" json:"Name" valid:"required"`
	Describe          string              `bson:"Describe" json:"Describe"`
	OpenHours         string              `bson:"OpenHours" json:"OpenHours"` //营业时间
	Mobile            string              `bson:"Mobile" json:"Mobile"`
	Address           string              `bson:"Address" json:"Address"`
	InvestigationUrl  string              `bson:"InvestigationUrl" json:"InvestigationUrl"` //问券调查的url地址
	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"`
	RangeLocation     []SLocation         `bson:"RangeLocation" json:"RangeLocation"`         //景区范围
	ZoomForIOS        SRange              `bson:"ZoomForIOS" json:"ZoomForIOS"`               //地图的缩放大小(IOS)
	ZoomForAndroidMin []SLocation         `bson:"ZoomForAndroidMin" json:"ZoomForAndroidMin"` //地图的缩放大小(Android最小)
	ZoomForAndroidMax []SLocation         `bson:"ZoomForAndroidMax" json:"ZoomForAndroidMax"` //地图的缩放大小(Android最大)
	Rotation          float64             `bson:"Rotation" json:"Rotation"`                   //旋转角度
	OpenTiles         bool                `bson:"OpenTiles" json:"OpenTiles"`                 //否开启地图切片
	ColorTiles        string              `bson:"ColorTiles" json:"ColorTiles"`               //切片底色(#FFFFFF)
	Display           bool                `bson:"Display" json:"Display"`                     //是否显示
	Remove            bool                `bson:"Remove" json:"Remove"`                       //是否删除
}

type SItem struct {
	Id                 *primitive.ObjectID `bson:"_id" json:"Id" valid:"required"`
	ScenicId           string              `bson:"ScenicId" json:"ScenicId" valid:"required"` // 景区id
	Name               string              `bson:"Name" json:"Name" valid:"required"`
	SubName            string              `bson:"SubName,omitempty" json:"SubName"`
	Location           SLocation           `bson:"Location" json:"Location" valid:"required"`
	Tags               []STag              `bson:"Tags" json:"Tags"`
	Icon               string              `bson:"Icon" json:"Icon" valid:"required"`
	LimitHeight        string              `bson:"LimitHeight,omitempty" json:"LimitHeight"`   //限高
	PlayDuration       string              `bson:"PlayDuration,omitempty" json:"PlayDuration"` //游玩时长
	SceneTime          string              `bson:"SceneTime,omitempty" json:"SceneTime"`       //场次时间
	Picture            []string            `bson:"Picture,omitempty" json:"Picture"`
	Voice              string              `bson:"Voice,omitempty" json:"Voice"` //音频
	Tel                string              `bson:"Tel,omitempty" json:"Tel"`
	AverageConsumption string              `bson:"AverageConsumption,omitempty" json:"AverageConsumption"` //人均消费
	Menu               string              `bson:"Menu,omitempty" json:"Menu"`                             //目录
	//Time                string              `bson:"Time,omitempty" json:"Time"`
	OpenHours           string             `bson:"OpenHours,omitempty" json:"OpenHours"`                     //开放时间
	LocationDescription string             `bson:"LocationDescription,omitempty" json:"LocationDescription"` //位置描述
	Reminder            string             `bson:"Reminder,omitempty" json:"Reminder"`                       //温馨提示
	State               int                `bson:"State,omitempty" json:"State"`                             // 运行状态0=正常1=停运
	CustomAttribute     []SCustomAttribute `bson:"CustomAttribute" json:"CustomAttribute"`                   // 自定义属性
	WaitingTimeDisplay  bool               `bson:"WaitingTimeDisplay" json:"WaitingTimeDisplay"`             //是否有等待时间显示
	ReminderInterval    []string           `bson:"ReminderInterval" json:"ReminderInterval"`       //排队提醒间隔时间
	Display             bool               `bson:"Display" json:"Display"`                                   //是否显示
}

type SCustomAttribute struct {
	Title   string `bson:"Title" json:"Title"`
	Content string `bson:"Content" json:"Content"`
}

type SModel struct {
	Model  string `bson:"Model" json:"Model"`
	Action string `bson:"Action" json:"Action"`
}

type SNotice struct {
	Id           *primitive.ObjectID `bson:"_id" json:"Id" valid:"required"`
	ScenicId     string              `bson:"ScenicId" json:"ScenicId" valid:"required"`
	Title        string              `bson:"Title" json:"Title" valid:"required"`
	Url          string              `bson:"Url" json:"Url"`
	CreateTime   int64               `bson:"CreateTime,omitempty" json:"CreateTime"`                               //创建时间
	UpdateTime   int64               `bson:"UpdateTime,omitempty" json:"UpdateTime"`                               //最后一次修改时间
	Expiry       int64               `bson:"Expiry" json:"Expiry"`                                                 //有效期
	ExpiryString string              `bson:"ExpiryString" json:"ExpiryString" valid:"required,in(15分钟|1小时|今天|今年)"` //有效期
}
type SIcons struct {
	Id       *primitive.ObjectID `bson:"_id" json:"Id" valid:"required"`
	ScenicId string              `bson:"ScenicId" json:"ScenicId"`
	Name     string              `bson:"Name" json:"Name"`
	Picture  string              `bson:"Picture" json:"Picture"`
}
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 STopMenus struct {
	Id       *primitive.ObjectID `bson:"_id" json:"Id" valid:"required"`
	ScenicId string              `bson:"ScenicId" json:"ScenicId" valid:"required"`
	Name     string              `bson:"Name" json:"Name" valid:"required"`   //菜单标题
	Tags     []string            `bson:"Tags" json:"Tags" valid:"required"`   //标签
	Order    int64               `bson:"Order" json:"Order" valid:"required"` //排序
}

type SDevice struct {
	DeviceId      string `bson:"DeviceId" json:"DeviceId"`
	Mac           string `bson:"Mac" json:"Mac"`
	UDID          string `bson:"UDID" json:"UDID"`
	SystemType    string `bson:"SystemType" json:"SystemType"`           //ios,android
	SystemVersion string `bson:"SystemVersion" json:"SystemVersion"`     //系统版本
	SystemModel   string `bson:"SystemModel" json:"SystemModel"`         //机型
	AppVersion    string `bson:"AppVersion" json:"AppVersion"`           //app版本
	DeviceToken   string `bson:"DeviceToken" json:"DeviceToken"`         //用于推送的token
	CreateTime    int64  `bson:"CreateTime,omitempty" json:"CreateTime"` //创建时间
}

type SUserLog struct {
	Type     string    `bson:"Type" json:"Type"`       // Log(事件)类型
	SubType  string    `bson:"SubType" json:"SubType"` // 分类
	ScenicId string    `bson:"ScenicId" json:"ScenicId"`
	UserId   string    `bson:"UserId" json:"UserId"`     // 用户ID
	UserName string    `bson:"UserName" json:"UserName"` //用户名称
	DateTime int64     `bson:"DateTime" json:"DateTime"` //时间戳
	Location SLocation `bson:"Location" json:"Location"` //位置
	Remarks  string    `bson:"Remarks" json:"Remarks"`   //备注
	Ip       string    `bson:"Ip" json:"Ip"`
	Source   string    `bson:"Source" json:"Source"` //来源
	Device   SDevice   `bson:"Device" json:"Device"` //设备信息
}

type SOperatorLog struct {
	Id       *primitive.ObjectID `bson:"_id" json:"Id" valid:"required"`
	ScenicId string              `bson:"ScenicId" json:"ScenicId"`
	UserId   string              `bson:"UserId" json:"UserId"`     // 用户ID
	UserName string              `bson:"UserName" json:"UserName"` //用户名称
	DateTime int64               `bson:"DateTime" json:"DateTime"` //时间戳
	Remarks  string              `bson:"Remarks" json:"Remarks"`   //备注
	Model    SModel              `bson:"Model" json:"Model"`
	Api      string              `bson:"Api" json:"Api"`
	Parames  interface{}         `bson:"Parames" json:"Parames"`
}
type SSystemLog 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       *primitive.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"`     //详情页下面的产品详细图
	Display  bool                `bson:"Display" json:"Display"`   //是否显示
}
type SLine struct {
	Id           *primitive.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 {
	Id       *primitive.ObjectID `bson:"_id" json:"Id" valid:"required"`
	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"`
	State    string              `bson:"State" json:"State"`       // 处理状态(未处理,已处理)
	DateTime int64               `bson:"DateTime" json:"DateTime"` //时间戳
}

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         *primitive.ObjectID `bson:"_id" json:"Id" valid:"required"`
	UserType   string              `bson:"UserType" json:"UserType" valid:"required,in(root|operator|visitor)"` // "root" or "operator" or "visitor"
	ScenicId   string              `bson:"ScenicId,omitempty" json:"ScenicId,omitempty"`
	Username   string              `bson:"Username,omitempty" json:"Username,omitempty"`
	Password   string              `bson:"Password,omitempty" json:"Password,omitempty"`
	Birthday   string              `bson:"Birthday,omitempty" json:"Birthday"`
	FullName   string              `bson:"FullName,omitempty" json:"FullName"`
	Mobile     string              `bson:"Mobile,omitempty" json:"Mobile"`
	Openid     string              `bson:"Openid,omitempty" json:"Openid"`
	Token      string              `bson:"Token,omitempty" json:"Token,omitempty"`
	Sex        string              `bson:"Sex,omitempty" json:"Sex"`
	Device     *SDevice            `bson:"Device,omitempty" json:"Device"`         //设备信息
	Auth       []string            `bson:"Auth,omitempty" json:"Auth"`             //权限信息
	Remarks    string              `bson:"Remarks,omitempty" json:"Remarks"`       //说明
	CreateTime int64               `bson:"CreateTime,omitempty" json:"CreateTime"` //创建时间
}

type STag struct {
	ScenicId  string `bson:"ScenicId" json:"ScenicId"`
	Type      string `bson:"Type" json:"Type"`
	TypeAlias string `TypeAlias:"alias" json:"TypeAlias"` // 类型的别名
	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 SSize struct {
	Width  int64 `bson:"Width" json:"Width"`
	Height int64 `bson:"Height" json:"Height"`
}
type SRange struct {
	Min float64 `bson:"Min" json:"Min"`
	Max float64 `bson:"Max" json:"Max"`
}
type SSysAds struct {
	Id      *primitive.ObjectID `bson:"_id" json:"Id" valid:"required"`
	Site    string              `bson:"Site" json:"Site" valid:"required"`               // 位置
	Size    SSize               `bson:"Size" json:"Size" valid:"required"`               // 尺寸
	Type    string              `bson:"Type" json:"Type" valid:"required,in(轮播|单图|单视频)"` // 类型
	Picture []SPicture          `bson:"Picture" json:"Picture"`                          // 图片
	Video   []SVideo            `bson:"Video" json:"Video"`                              // 视频
}