model

package
v0.0.0-...-afd247e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 18, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close()

Close 关闭

func GetNotesByRecordIDs

func GetNotesByRecordIDs(recordIDs []primitive.ObjectID) (map[primitive.ObjectID]DifNotes, error)

GetNotesByRecordIDs 获取recordIDs相对应的记录并以key为recordID,value为所对应Notes的map结构返回

func New

func New(c map[string]string) error

New 创建数据库连接并传入config

Types

type DifNote

type DifNote bson.M

DifNote 不同的笔记

type DifNotes

type DifNotes []DifNote

DifNotes 不同的笔记集合

type HrTime

type HrTime float64

HrTime 重要时间点

const (
	// HR0D5 0.5小时
	HR0D5 HrTime = 0.5
	// HR5D5 5.5小时
	HR5D5 HrTime = 5.5
	// HR7 7.5小时
	HR7 HrTime = 7
	// HR10 10小时
	HR10 HrTime = 10
	// HR13 13小时
	HR13 HrTime = 13
	// HR24 24小时
	HR24 HrTime = 24
	// HR70 70小时
	HR70 HrTime = 70
)

type INote

type INote interface {
	Add() error
}

INote 笔记接口

type Location

type Location struct {
	Address locModel.Address `bson:"address,omitempty" json:"address,omitempty" valid:"-"`
	Coors   locModel.Coors   `bson:"coors,omitempty" json:"coors,omitempty" valid:"-"`
}

Location 位置信息

type ModificationNote

type ModificationNote struct {
	Note `bson:",inline"`
	By   primitive.ObjectID `bson:"by" json:"by" valid:"required"`
}

ModificationNote 人为修改笔记

func (*ModificationNote) Add

func (mn *ModificationNote) Add() error

Add 人为修改笔记添加到数据库

type Note

type Note struct {
	ID        primitive.ObjectID `bson:"_id" json:"id" valid:"-"`
	RecordID  primitive.ObjectID `bson:"recordID" json:"recordID" valid:"required"`
	Type      NoteType           `bson:"noteType" json:"noteType" valid:"required"`
	Comment   string             `bson:"comment" json:"comment" valid:"-"`
	CreatedAt time.Time          `bson:"createdAt" json:"createdAt" valid:"required"`
}

Note 笔记

type NoteType

type NoteType string

NoteType 笔记类型

const (
	// SYSTEMNOTE 系统笔记类型
	SYSTEMNOTE NoteType = "system"
	// MODIFICATIONNOTE 人为修改笔记类型
	MODIFICATIONNOTE NoteType = "modification"
	// TRIPNOTE 行程笔记类型
	TRIPNOTE NoteType = "trip"
	// OTHERWORKNOTE 其它笔记类型
	OTHERWORKNOTE NoteType = "others"
)

type OtherWorkNote

type OtherWorkNote struct {
	Note `bson:",inline"`
}

OtherWorkNote 其它笔记

func (*OtherWorkNote) Add

func (own *OtherWorkNote) Add() error

Add 其它笔记添加到数据库

type Record

type Record struct {
	ID            primitive.ObjectID `bson:"_id" json:"id" valid:"-"`
	DriverID      primitive.ObjectID `bson:"driverID" json:"driverID" valid:"required"`
	Type          Type               `bson:"type" json:"type" valid:"required"`
	Time          time.Time          `bson:"time" json:"time" valid:"required"`
	Duration      time.Duration      `bson:"duration" json:"duration" valid:"required"`
	StartLocation Location           `bson:"startLocation" json:"startLocation" valid:"required"`
	EndLocation   Location           `bson:"endLocation," json:"endLocation" valid:"required"`
	VehicleID     primitive.ObjectID `bson:"vehicleID" json:"vehicleID" valid:"required"`
	StartMileAge  *float64           `bson:"startDistance,omitempty" json:"startDistance,omitempty" valid:"-"`
	EndMileAge    *float64           `bson:"endDistance,omitempty" json:"endDistance,omitempty" valid:"-"`
	CreatedAt     time.Time          `bson:"createdAt" json:"createdAt" valid:"required"`
	ClientTime    *time.Time         `bson:"clientTime,omitempty" json:"clientTime,omitempty" valid:"-"`
	DeletedAt     *time.Time         `bson:"deletedAt,omitempty" json:"deletedAt,omitempty" valid:"-"`
}

Record 记录

func GetLastestRecord

func GetLastestRecord(driverID primitive.ObjectID) (*Record, error)

GetLastestRecord 获取最近的一条记录

func GetRecord

func GetRecord(id primitive.ObjectID) (*Record, error)

GetRecord 通过id获取记录

func GetRecords

func GetRecords(driverID primitive.ObjectID, from, to time.Time, getDeleted bool) ([]Record, error)

GetRecords 获取用户时间段内的记录

func (*Record) Add

func (r *Record) Add() (err error)

Add 记录添加

func (*Record) Delete

func (r *Record) Delete() error

Delete 记录删除

type Records

type Records []Record

Records .

func (Records) SyncAdd

func (rs Records) SyncAdd() (err error)

SyncAdd 批量上传添加

type SystemNote

type SystemNote struct {
	Note `bson:",inline"`
}

SystemNote 系统笔记

func (*SystemNote) Add

func (sn *SystemNote) Add() error

Add 系统笔记添加到数据库

type TripNote

type TripNote struct {
	Note                `bson:",inline"`
	TransportOperatorID *primitive.ObjectID `bson:"transportOperatorID,omitempty" json:"transportOperatorID,omitempty" valid:"-"`
	StartTime           time.Time           `bson:"startTime" json:"startTime" valid:"required"`
	EndTime             time.Time           `bson:"endTime" json:"endTime" valid:"required"`
	StartLocation       Location            `bson:"startLocation" json:"startLocation" valid:"required"`
	EndLocation         Location            `bson:"endLocation" json:"endLocation" valid:"required"`
}

TripNote 行程笔记

func (*TripNote) Add

func (tn *TripNote) Add() error

Add 行程笔记添加到数据库

type Type

type Type string

Type 记录类型

const (
	// WORK 工作记录类型
	WORK Type = "work"
	// REST 休息记录类型
	REST Type = "rest"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL