models

package
v0.0.0-...-402636f Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Consultant

type Consultant struct {
	ID        uint64     `gorm:"primary_key" json:"id"`
	CreatedAt time.Time  `json:"-"`
	UpdatedAt time.Time  `json:"-"`
	DeletedAt *time.Time `json:"-"`
	Name      string     `gorm:"not null;unique" json:"name"`
}

Consultant struct

type ConsultantCSV

type ConsultantCSV struct {
	CreatedAt DateTime `csv:"created_at"`
	Name      string   `csv:"name"`
}

ConsultantCSV csv struct

type ConsultantManager

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

ConsultantManager struct

func NewConsultantManager

func NewConsultantManager(db *DB) (*ConsultantManager, error)

NewConsultantManager - Create a consultant manager that can be used for retrieving consultants

func (*ConsultantManager) ConsultantCount

func (db *ConsultantManager) ConsultantCount() int

ConsultantCount -

func (*ConsultantManager) ConsultantList

func (db *ConsultantManager) ConsultantList() []Consultant

ConsultantList - return a list of Consultants

func (*ConsultantManager) ConsultantSeed

func (db *ConsultantManager) ConsultantSeed(file string) int

ConsultantSeed - will load data from data file

type DB

type DB struct {
	*gorm.DB
}

DB abstraction

func NewPostgresDB

func NewPostgresDB(dataSourceName string) *DB

NewPostgresDB - postgres database

type Date

type Date struct {
	time.Time
}

Date used for csv marshalling and unmarshalling

func (*Date) MarshalCSV

func (date *Date) MarshalCSV() (string, error)

MarshalCSV Convert the internal date as CSV string

func (*Date) UnmarshalCSV

func (date *Date) UnmarshalCSV(csv string) (err error)

UnmarshalCSV Convert the CSV string as internal date

type DateTime

type DateTime struct {
	time.Time
}

DateTime used for csv marshalling and unmarshalling

func (*DateTime) MarshalCSV

func (date *DateTime) MarshalCSV() (string, error)

MarshalCSV Convert the internal date as CSV string

func (*DateTime) UnmarshalCSV

func (date *DateTime) UnmarshalCSV(csv string) (err error)

UnmarshalCSV Convert the CSV string as internal date

type Holiday

type Holiday struct {
	ID          uint64     `gorm:"primary_key" json:"id"`
	CreatedAt   time.Time  `json:"-"`
	UpdatedAt   time.Time  `json:"-"`
	DeletedAt   *time.Time `json:"-"`
	Date        time.Time  `gorm:"not null" json:"date"`
	Description string     `gorm:"not null" json:"description"`
}

Holiday struct

type HolidayCSV

type HolidayCSV struct {
	CreatedAt   DateTime `csv:"created_at"`
	Date        Date     `csv:"date"`
	Description string   `csv:"description"`
}

HolidayCSV csv struct

type HolidayManager

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

HolidayManager struct

func NewHolidayManager

func NewHolidayManager(db *DB) (*HolidayManager, error)

NewHolidayManager - Create a Project manager that can be used for retrieving ReportedRecordss

func (*HolidayManager) HolidayCount

func (db *HolidayManager) HolidayCount() int

HolidayCount - return all records of Holidays

func (*HolidayManager) HolidaySeed

func (db *HolidayManager) HolidaySeed(file string) int

HolidaySeed - will load data from data file

func (*HolidayManager) HolidaysGetAll

func (db *HolidayManager) HolidaysGetAll() []Holiday

HolidaysGetAll - return all records of ReportedRecords

type Project

type Project struct {
	ID        uint64     `gorm:"primary_key" json:"id"`
	CreatedAt time.Time  `json:"-"`
	UpdatedAt time.Time  `json:"-"`
	DeletedAt *time.Time `json:"-"`
	Name      string     `gorm:"not null" json:"name"`
}

Project struct

type ProjectCSV

type ProjectCSV struct {
	CreatedAt DateTime `csv:"created_at"`
	Name      string   `csv:"name"`
}

ProjectCSV csv struct

type ProjectManager

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

ProjectManager struct

func NewProjectManager

func NewProjectManager(db *DB) (*ProjectManager, error)

NewProjectManager - Create a Project manager that can be used for retrieving ReportedRecordss

func (*ProjectManager) ProjectCount

func (db *ProjectManager) ProjectCount() int

ProjectCount - return all records of Rates

func (*ProjectManager) ProjectSeed

func (db *ProjectManager) ProjectSeed(file string) int

ProjectSeed - will load data from data file

func (*ProjectManager) ProjectsGetAll

func (db *ProjectManager) ProjectsGetAll() []Project

ProjectsGetAll - return all records of ReportedRecords

type Rate

type Rate struct {
	ID        uint64     `gorm:"primary_key" json:"id"`
	CreatedAt time.Time  `json:"-"`
	UpdatedAt time.Time  `json:"-"`
	DeletedAt *time.Time `json:"-"`
	Name      string     `gorm:"not null" json:"name"`
}

Rate struct

type RateCSV

type RateCSV struct {
	CreatedAt DateTime `csv:"created_at"`
	Name      string   `csv:"name"`
}

RateCSV csv struct

type RateManager

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

RateManager struct

func NewRateManager

func NewRateManager(db *DB) (*RateManager, error)

NewRateManager - Create a Rate manager that can be used for retrieving ReportedRecordss

func (*RateManager) RateCount

func (db *RateManager) RateCount() int

RateCount - return all records of Rates

func (*RateManager) RateSeed

func (db *RateManager) RateSeed(file string) int

RateSeed - will load data from data file

func (*RateManager) RatesGetAll

func (db *RateManager) RatesGetAll() []Rate

RatesGetAll - return all records of Rates

type ReportedRecord

type ReportedRecord struct {
	ID          uint64     `gorm:"primary_key" json:"id"`
	CreatedAt   time.Time  `json:"-"`
	UpdatedAt   time.Time  `json:"-"`
	DeletedAt   *time.Time `json:"-"`
	Date        time.Time  `gorm:"not null" json:"date"`
	Hours       float64    `gorm:"not null" json:"hours"`
	Project     string     `gorm:"not null" json:"project"`
	Description string     `gorm:"not null" json:"description"`
	Rate        string     `gorm:"not null" json:"rate"`
	Consultant  string     `gorm:"not null" json:"consultant"`
}

ReportedRecord struct

type ReportedRecordCSV

type ReportedRecordCSV struct {
	CreatedAt   DateTime `csv:"created_at"`
	Date        Date     `csv:"date"`
	Hours       float64  `csv:"hours"`
	Project     string   `csv:"project"`
	Description string   `csv:"description"`
	Rate        string   `csv:"rate"`
	Consultant  string   `csv:"consultant"`
}

ReportedRecordCSV csv struct

type ReportedRecordManager

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

ReportedRecordManager struct

func NewReportedRecordManager

func NewReportedRecordManager(db *DB) (*ReportedRecordManager, error)

NewReportedRecordManager - Create a ReportedRecords manager that can be used for retrieving ReportedRecordss

func (*ReportedRecordManager) ReportedRecordAdd

func (db *ReportedRecordManager) ReportedRecordAdd(newRecord ReportedRecord) ReportedRecord

ReportedRecordAdd -

func (*ReportedRecordManager) ReportedRecordCount

func (db *ReportedRecordManager) ReportedRecordCount() int

ReportedRecordCount -

func (*ReportedRecordManager) ReportedRecordSeed

func (db *ReportedRecordManager) ReportedRecordSeed(file string) int

ReportedRecordSeed - will load data from data file

func (*ReportedRecordManager) ReportedRecordUpdate

func (db *ReportedRecordManager) ReportedRecordUpdate(r UpdatedValue) ReportedRecord

ReportedRecordUpdate -

func (*ReportedRecordManager) ReportedRecordsDelete

func (db *ReportedRecordManager) ReportedRecordsDelete(id uint64) []ReportedRecord

ReportedRecordsDelete - return all records of ReportedRecords

func (*ReportedRecordManager) ReportedRecordsGetAll

func (db *ReportedRecordManager) ReportedRecordsGetAll() []ReportedRecord

ReportedRecordsGetAll - return all records of ReportedRecords

func (*ReportedRecordManager) ReportedRecordsInMonth

func (db *ReportedRecordManager) ReportedRecordsInMonth(month string) []ReportedRecord

ReportedRecordsInMonth - return all records of ReportedRecords

type UpdatedValue

type UpdatedValue struct {
	ID    int64
	Type  string
	Value string
}

UpdatedValue used to pass updated ReportedRecord value type and relevant ID

type User

type User struct {
	ID        uint64     `gorm:"primary_key" json:"id"`
	CreatedAt time.Time  `json:"-"`
	UpdatedAt time.Time  `json:"-"`
	DeletedAt *time.Time `json:"-"`
	Username  string     `gorm:"not null;unique" json:"username"`
	Password  string     `gorm:"not null" json:"-"`
	UUID      string     `gorm:"not null;unique" json:"uuid"`
}

User struct

type UserManager

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

UserManager struct

func NewUserManager

func NewUserManager(db *DB) (*UserManager, error)

NewUserManager - Create a new *UserManager that can be used for managing users.

func (*UserManager) AddUser

func (state *UserManager) AddUser(username, password string) *User

AddUser - Creates a user and hashes the password

func (*UserManager) CheckPassword

func (state *UserManager) CheckPassword(hashedPassword, password string) bool

CheckPassword - compare a hashed password with a possible plaintext equivalent

func (*UserManager) FindUser

func (state *UserManager) FindUser(username string) *User

FindUser -

func (*UserManager) FindUserByUUID

func (state *UserManager) FindUserByUUID(uuid string) *User

FindUserByUUID -

func (*UserManager) HasUser

func (state *UserManager) HasUser(username string) bool

HasUser - Check if the given username exists.

func (*UserManager) HashPassword

func (state *UserManager) HashPassword(username, password string) string

HashPassword - Hash the password (takes a username as well, it can be used for salting).

Jump to

Keyboard shortcuts

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