models

package
v0.0.0-...-3ae992e Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2016 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interval

type Interval struct {
	ID     bson.ObjectId `bson:"_id,omitempty"`
	UserID bson.ObjectId
	Start  time.Time
	Stop   time.Time `bson:",omitempty"`
}

Interval contains the Duration of a work from a user

func NewInterval

func NewInterval(userID bson.ObjectId, start time.Time, stop time.Time) Interval

func NewIntervalWithStart

func NewIntervalWithStart(userID bson.ObjectId, start time.Time) Interval

func NewPersistedInterval

func NewPersistedInterval(id bson.ObjectId, userID bson.ObjectId, start time.Time, stop time.Time) Interval

func NewPersistedIntervalWithStart

func NewPersistedIntervalWithStart(id bson.ObjectId, userID bson.ObjectId, start time.Time) Interval

func (Interval) EqualsWithoutID

func (interval Interval) EqualsWithoutID(that Interval) bool

type IntervalDao

type IntervalDao interface {
	Save(interval Interval) error
	FindByUserID(userID bson.ObjectId) ([]Interval, error)
	IsUserWorking(userID bson.ObjectId) (bool, error)
	Start(userID bson.ObjectId) error
	Stop(userID bson.ObjectId) error
	FindOpenIntervals(userID bson.ObjectId) ([]Interval, error)
	FindInRange(userID bson.ObjectId, begin time.Time, end time.Time) ([]Interval, error)
}

func NewIntervalDao

func NewIntervalDao(session *mgo.Session, dbName string) IntervalDao

type IntervalDaoImpl

type IntervalDaoImpl struct {
	// contains filtered or unexported fields
}

func (*IntervalDaoImpl) FindByUserID

func (dao *IntervalDaoImpl) FindByUserID(userID bson.ObjectId) ([]Interval, error)

func (*IntervalDaoImpl) FindInRange

func (dao *IntervalDaoImpl) FindInRange(userID bson.ObjectId, begin time.Time, end time.Time) ([]Interval, error)

FindInRange returns all intervals where start is greater than or equals begin and less than end

func (*IntervalDaoImpl) FindOpenIntervals

func (dao *IntervalDaoImpl) FindOpenIntervals(userID bson.ObjectId) ([]Interval, error)

FindOpenIntervals returns all intervals where stop is not set/zero value

func (*IntervalDaoImpl) IsUserWorking

func (dao *IntervalDaoImpl) IsUserWorking(userID bson.ObjectId) (bool, error)

func (*IntervalDaoImpl) Save

func (dao *IntervalDaoImpl) Save(interval Interval) error

func (*IntervalDaoImpl) Start

func (dao *IntervalDaoImpl) Start(userID bson.ObjectId) error

func (*IntervalDaoImpl) Stop

func (dao *IntervalDaoImpl) Stop(userID bson.ObjectId) error

Stop sets stop to current time, if the user is working. Returns an error when the user is not working or has more than one interval without a stop time or find returns an error.

type User

type User struct {
	ID       bson.ObjectId `bson:"_id,omitempty"`
	Name     string
	Worktime time.Duration
	Overtime time.Duration
}

func NewMinimalUser

func NewMinimalUser(name string, worktime time.Duration) User

func NewPersistedMinimalUser

func NewPersistedMinimalUser(id bson.ObjectId, name string, worktime time.Duration) User

func NewPersistedUser

func NewPersistedUser(id bson.ObjectId, name string, worktime time.Duration, ovetime time.Duration) User

func NewUser

func NewUser(name string, worktime time.Duration, ovetime time.Duration) User

func (User) EqualsWithoutID

func (user User) EqualsWithoutID(that User) bool

type UserDao

type UserDao interface {
	Save(user User) error
	SaveWithPassword(user UserWithPassword) error
	FindByID(id bson.ObjectId) (User, error)
	FindByName(name string) (User, error)
	AddPassword(id bson.ObjectId, password []byte) error
	AddPasswordByUser(username string, password []byte) error
	GetPassword(id bson.ObjectId) ([]byte, error)
	GetPasswordByUser(username string) ([]byte, error)
	Update(user User) error
}

func NewUserDao

func NewUserDao(session *mgo.Session, dbName string) UserDao

type UserDaoImpl

type UserDaoImpl struct {
	// contains filtered or unexported fields
}

func (*UserDaoImpl) AddPassword

func (dao *UserDaoImpl) AddPassword(id bson.ObjectId, password []byte) error

func (*UserDaoImpl) AddPasswordByUser

func (dao *UserDaoImpl) AddPasswordByUser(username string, password []byte) error

func (*UserDaoImpl) FindByID

func (dao *UserDaoImpl) FindByID(id bson.ObjectId) (User, error)

func (*UserDaoImpl) FindByName

func (dao *UserDaoImpl) FindByName(name string) (User, error)

func (*UserDaoImpl) GetPassword

func (dao *UserDaoImpl) GetPassword(id bson.ObjectId) ([]byte, error)

func (*UserDaoImpl) GetPasswordByUser

func (dao *UserDaoImpl) GetPasswordByUser(username string) ([]byte, error)

func (*UserDaoImpl) Save

func (dao *UserDaoImpl) Save(user User) error

func (*UserDaoImpl) SaveWithPassword

func (dao *UserDaoImpl) SaveWithPassword(user UserWithPassword) error

func (*UserDaoImpl) Update

func (dao *UserDaoImpl) Update(user User) error

type UserWithPassword

type UserWithPassword struct {
	ID       bson.ObjectId `bson:"_id,omitempty"`
	Name     string
	Worktime time.Duration
	Overtime time.Duration
	Password string
}

func NewMinimalUserWithPassword

func NewMinimalUserWithPassword(name string, worktime time.Duration, password []byte) UserWithPassword

func (UserWithPassword) EqualsWithoutID

func (user UserWithPassword) EqualsWithoutID(that UserWithPassword) bool

Jump to

Keyboard shortcuts

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