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: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close()

Close 关闭

func New

func New(c map[string]string) (err error)

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

Types

type Record

type Record struct {
	ID        primitive.ObjectID `bson:"_id" json:"id" valid:"required"`
	DriverID  primitive.ObjectID `bson:"driverID" json:"driverID" valid:"required"`
	Charge    int64              `bson:"charge" json:"charge" valid:"required"`
	Refund    int64              `bson:"refund" json:"refund" valid:"-"`
	StartDate string             `bson:"startDate" json:"startDate" valid:"required"`
	EndDate   string             `bson:"endDate" json:"endDate" valid:"required"`
	CreatedAt time.Time          `bson:"createdAt" json:"createdAt" valid:"required"`
}

Record 订阅记录

func GetRecord

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

GetRecord 通过id获取用户的订阅记录

func GetRecords

func GetRecords(driverID primitive.ObjectID) ([]Record, error)

GetRecords 获取用户的订阅记录

func (*Record) Add

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

Add 创建一条订阅记录

func (*Record) MakeRefund

func (r *Record) MakeRefund(refund int64) (err error)

MakeRefund 订阅记录退款

type Suscription

type Suscription struct {
	DriverID    primitive.ObjectID `bson:"_id" json:"driverID" valid:"required"`
	Renew       bool               `bson:"renew" json:"renew" valid:"required"`
	ExpiredDate string             `bson:"expiredDate" json:"expiredDate" valid:"required"`
	CreatedAt   time.Time          `bson:"createdAt" json:"createdAt" valid:"required"`
}

Suscription 用户的订阅状态

func GetSuscription

func GetSuscription(driverID primitive.ObjectID) (*Suscription, error)

GetSuscription 获取用户的订阅状态

func (*Suscription) Add

func (s *Suscription) Add() (err error)

Add 创建新的用户订阅状态

func (*Suscription) IsExpired

func (s *Suscription) IsExpired() bool

IsExpired 用户订阅状态是否过期

type Transaction

type Transaction struct {
	ID       primitive.ObjectID `bson:"_id" json:"id" valid:"required"`
	DriverID primitive.ObjectID `bson:"driverID" json:"driverID" valid:"required"`
	RecordID primitive.ObjectID `bson:"recordID" json:"recordID" valid:"required"`
}

Transaction 交易结构体

Jump to

Keyboard shortcuts

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