models

package
v0.0.0-...-68900ed Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2016 License: MIT Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EventFilterByTenant

func EventFilterByTenant(tenantID int, originaldb *gorm.DB) func(db *gorm.DB) *gorm.DB

EventFilterByTenant is a gorm filter for a Belongs To relationship.

func PresentationFilterByEvent

func PresentationFilterByEvent(eventID int, originaldb *gorm.DB) func(db *gorm.DB) *gorm.DB

PresentationFilterByEvent is a gorm filter for a Belongs To relationship.

func PresentationFilterBySpeaker

func PresentationFilterBySpeaker(speakerID int, originaldb *gorm.DB) func(db *gorm.DB) *gorm.DB

PresentationFilterBySpeaker is a gorm filter for a Belongs To relationship.

func SeriesFilterByTenant

func SeriesFilterByTenant(tenantID int, originaldb *gorm.DB) func(db *gorm.DB) *gorm.DB

SeriesFilterByTenant is a gorm filter for a Belongs To relationship.

func SpeakerFilterByEvent

func SpeakerFilterByEvent(eventID int, originaldb *gorm.DB) func(db *gorm.DB) *gorm.DB

SpeakerFilterByEvent is a gorm filter for a Belongs To relationship.

func UserFilterByTenant

func UserFilterByTenant(tenantID int, originaldb *gorm.DB) func(db *gorm.DB) *gorm.DB

UserFilterByTenant is a gorm filter for a Belongs To relationship.

Types

type Event

type Event struct {
	ID            int `gorm:"primary_key"` // This is the ID PK field
	CreatedAt     time.Time
	DeletedAt     *time.Time
	EndDate       *time.Time
	Name          string
	Presentations []Presentation // has many Presentations
	Speakers      []Speaker      // has many Speakers
	StartDate     *time.Time
	TenantID      int // has many Event
	URL           *string
	UpdatedAt     time.Time
	Tenant        Tenant
}

This is the Event model

func EventFromCreateEventPayload

func EventFromCreateEventPayload(payload *app.CreateEventPayload) *Event

EventFromCreateEventPayload Converts source CreateEventPayload to target Event model only copying the non-nil fields from the source.

func EventFromUpdateEventPayload

func EventFromUpdateEventPayload(payload *app.UpdateEventPayload) *Event

EventFromUpdateEventPayload Converts source UpdateEventPayload to target Event model only copying the non-nil fields from the source.

func (*Event) EventToEvent

func (m *Event) EventToEvent() *app.Event

EventToEvent returns the Event representation of Event.

func (Event) TableName

func (m Event) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

type EventDB

type EventDB struct {
	Db gorm.DB
}

EventDB is the implementation of the storage interface for Event.

func NewEventDB

func NewEventDB(db gorm.DB) *EventDB

NewEventDB creates a new storage type.

func (*EventDB) Add

func (m *EventDB) Add(ctx context.Context, model *Event) (*Event, error)

Add creates a new record. /// Maybe shouldn't return the model, it's a pointer.

func (*EventDB) DB

func (m *EventDB) DB() interface{}

DB returns the underlying database.

func (*EventDB) Delete

func (m *EventDB) Delete(ctx context.Context, id int) error

Delete removes a single record.

func (*EventDB) Get

func (m *EventDB) Get(ctx context.Context, id int) (Event, error)

Get returns a single Event as a Database Model This is more for use internally, and probably not what you want in your controllers

func (*EventDB) List

func (m *EventDB) List(ctx context.Context) []Event

List returns an array of Event

func (*EventDB) ListEvent

func (m *EventDB) ListEvent(ctx context.Context, tenantID int) []*app.Event

ListEvent returns an array of view: default.

func (*EventDB) OneEvent

func (m *EventDB) OneEvent(ctx context.Context, id int, tenantID int) (*app.Event, error)

OneEvent returns an array of view: default.

func (*EventDB) TableName

func (m *EventDB) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

func (*EventDB) Update

func (m *EventDB) Update(ctx context.Context, model *Event) error

Update modifies a single record.

func (*EventDB) UpdateFromCreateEventPayload

func (m *EventDB) UpdateFromCreateEventPayload(ctx context.Context, payload *app.CreateEventPayload, id int) error

UpdateFromCreateEventPayload applies non-nil changes from CreateEventPayload to the model and saves it

func (*EventDB) UpdateFromUpdateEventPayload

func (m *EventDB) UpdateFromUpdateEventPayload(ctx context.Context, payload *app.UpdateEventPayload, id int) error

UpdateFromUpdateEventPayload applies non-nil changes from UpdateEventPayload to the model and saves it

type EventStorage

type EventStorage interface {
	DB() interface{}
	List(ctx context.Context) []Event
	Get(ctx context.Context, id int) (Event, error)
	Add(ctx context.Context, event *Event) (*Event, error)
	Update(ctx context.Context, event *Event) error
	Delete(ctx context.Context, id int) error

	ListEvent(ctx context.Context, tenantID int) []*app.Event
	OneEvent(ctx context.Context, id int, tenantID int) (*app.Event, error)

	UpdateFromCreateEventPayload(ctx context.Context, payload *app.CreateEventPayload, id int) error

	UpdateFromUpdateEventPayload(ctx context.Context, payload *app.UpdateEventPayload, id int) error
}

EventStorage represents the storage interface.

type Login

type Login struct {
	Email    string
	Password string
}
func (u *User) AfterCreate() error {
	if *u.Validated {
		return nil
	}
	go u.ValidationEmail()
	return nil
}
func (u *User) ValidationEmail() error {
	sg := sendgrid.NewSendGridClientWithApiKey("")
	message := sendgrid.NewMail()
	message.AddTo(u.Email)
	message.AddToName(u.FirstName + " " + u.LastName)
	message.SetSubject("Validate your account")
	msg := fmt.Sprintf("<html><body>Welcome.<br/><br/>Please click <a href='<validationurl>validaate_email?u=%d&validation=%s'>here</a> to validate your account.</body></html>", u.ID, *u.ValidationCode)
	message.SetHTML(msg)
	message.SetFrom(supportEmail)
	r := sg.Send(message)

	return r
}

type Presentation

type Presentation struct {
	ID        int `gorm:"primary_key"` // This is the ID PK field
	Abstract  string
	CreatedAt time.Time
	DeletedAt *time.Time
	Detail    *string
	EventID   int // Belongs To Event
	Name      *string
	SpeakerID int // Belongs To Speaker
	UpdatedAt time.Time
	Event     Event
	Speaker   Speaker
}

This is the presentation model

func PresentationFromCreatePresentationPayload

func PresentationFromCreatePresentationPayload(payload *app.CreatePresentationPayload) *Presentation

PresentationFromCreatePresentationPayload Converts source CreatePresentationPayload to target Presentation model only copying the non-nil fields from the source.

func PresentationFromUpdatePresentationPayload

func PresentationFromUpdatePresentationPayload(payload *app.UpdatePresentationPayload) *Presentation

PresentationFromUpdatePresentationPayload Converts source UpdatePresentationPayload to target Presentation model only copying the non-nil fields from the source.

func (*Presentation) PresentationToPresentation

func (m *Presentation) PresentationToPresentation() *app.Presentation

PresentationToPresentation returns the Presentation representation of Presentation.

func (*Presentation) PresentationToPresentationAdmin

func (m *Presentation) PresentationToPresentationAdmin() *app.PresentationAdmin

PresentationToPresentationAdmin returns the Presentation representation of Presentation.

func (Presentation) TableName

func (m Presentation) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

type PresentationDB

type PresentationDB struct {
	Db gorm.DB
}

PresentationDB is the implementation of the storage interface for Presentation.

func NewPresentationDB

func NewPresentationDB(db gorm.DB) *PresentationDB

NewPresentationDB creates a new storage type.

func (*PresentationDB) Add

func (m *PresentationDB) Add(ctx context.Context, model *Presentation) (*Presentation, error)

Add creates a new record. /// Maybe shouldn't return the model, it's a pointer.

func (*PresentationDB) DB

func (m *PresentationDB) DB() interface{}

DB returns the underlying database.

func (*PresentationDB) Delete

func (m *PresentationDB) Delete(ctx context.Context, id int) error

Delete removes a single record.

func (*PresentationDB) Get

func (m *PresentationDB) Get(ctx context.Context, id int) (Presentation, error)

Get returns a single Presentation as a Database Model This is more for use internally, and probably not what you want in your controllers

func (*PresentationDB) List

func (m *PresentationDB) List(ctx context.Context) []Presentation

List returns an array of Presentation

func (*PresentationDB) ListPresentation

func (m *PresentationDB) ListPresentation(ctx context.Context, eventID int, speakerID int) []*app.Presentation

ListPresentation returns an array of view: default.

func (*PresentationDB) ListPresentationAdmin

func (m *PresentationDB) ListPresentationAdmin(ctx context.Context, eventID int, speakerID int) []*app.PresentationAdmin

ListPresentationAdmin returns an array of view: admin.

func (*PresentationDB) OnePresentation

func (m *PresentationDB) OnePresentation(ctx context.Context, id int, eventID int, speakerID int) (*app.Presentation, error)

OnePresentation returns an array of view: default.

func (*PresentationDB) OnePresentationAdmin

func (m *PresentationDB) OnePresentationAdmin(ctx context.Context, id int, eventID int, speakerID int) (*app.PresentationAdmin, error)

OnePresentationAdmin returns an array of view: admin.

func (*PresentationDB) TableName

func (m *PresentationDB) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

func (*PresentationDB) Update

func (m *PresentationDB) Update(ctx context.Context, model *Presentation) error

Update modifies a single record.

func (*PresentationDB) UpdateFromCreatePresentationPayload

func (m *PresentationDB) UpdateFromCreatePresentationPayload(ctx context.Context, payload *app.CreatePresentationPayload, id int) error

UpdateFromCreatePresentationPayload applies non-nil changes from CreatePresentationPayload to the model and saves it

func (*PresentationDB) UpdateFromUpdatePresentationPayload

func (m *PresentationDB) UpdateFromUpdatePresentationPayload(ctx context.Context, payload *app.UpdatePresentationPayload, id int) error

UpdateFromUpdatePresentationPayload applies non-nil changes from UpdatePresentationPayload to the model and saves it

type PresentationStorage

type PresentationStorage interface {
	DB() interface{}
	List(ctx context.Context) []Presentation
	Get(ctx context.Context, id int) (Presentation, error)
	Add(ctx context.Context, presentation *Presentation) (*Presentation, error)
	Update(ctx context.Context, presentation *Presentation) error
	Delete(ctx context.Context, id int) error

	ListPresentationAdmin(ctx context.Context, eventID int, speakerID int) []*app.PresentationAdmin
	OnePresentationAdmin(ctx context.Context, id int, eventID int, speakerID int) (*app.PresentationAdmin, error)

	ListPresentation(ctx context.Context, eventID int, speakerID int) []*app.Presentation
	OnePresentation(ctx context.Context, id int, eventID int, speakerID int) (*app.Presentation, error)

	UpdateFromCreatePresentationPayload(ctx context.Context, payload *app.CreatePresentationPayload, id int) error

	UpdateFromUpdatePresentationPayload(ctx context.Context, payload *app.UpdatePresentationPayload, id int) error
}

PresentationStorage represents the storage interface.

type Series

type Series struct {
	ID        int `gorm:"primary_key"` // This is the ID PK field
	CreatedAt time.Time
	DeletedAt *time.Time
	Name      string
	TenantID  int // Belongs To Tenant
	UpdatedAt time.Time
	Tenant    Tenant
}

This is the Series model

func SeriesFromCreateSeriesPayload

func SeriesFromCreateSeriesPayload(payload *app.CreateSeriesPayload) *Series

SeriesFromCreateSeriesPayload Converts source CreateSeriesPayload to target Series model only copying the non-nil fields from the source.

func SeriesFromUpdateSeriesPayload

func SeriesFromUpdateSeriesPayload(payload *app.UpdateSeriesPayload) *Series

SeriesFromUpdateSeriesPayload Converts source UpdateSeriesPayload to target Series model only copying the non-nil fields from the source.

func (*Series) SeriesToSeries

func (m *Series) SeriesToSeries() *app.Series

SeriesToSeries returns the Series representation of Series.

func (Series) TableName

func (m Series) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

type SeriesDB

type SeriesDB struct {
	Db gorm.DB
}

SeriesDB is the implementation of the storage interface for Series.

func NewSeriesDB

func NewSeriesDB(db gorm.DB) *SeriesDB

NewSeriesDB creates a new storage type.

func (*SeriesDB) Add

func (m *SeriesDB) Add(ctx context.Context, model *Series) (*Series, error)

Add creates a new record. /// Maybe shouldn't return the model, it's a pointer.

func (*SeriesDB) DB

func (m *SeriesDB) DB() interface{}

DB returns the underlying database.

func (*SeriesDB) Delete

func (m *SeriesDB) Delete(ctx context.Context, id int) error

Delete removes a single record.

func (*SeriesDB) Get

func (m *SeriesDB) Get(ctx context.Context, id int) (Series, error)

Get returns a single Series as a Database Model This is more for use internally, and probably not what you want in your controllers

func (*SeriesDB) List

func (m *SeriesDB) List(ctx context.Context) []Series

List returns an array of Series

func (*SeriesDB) ListSeries

func (m *SeriesDB) ListSeries(ctx context.Context, tenantID int) []*app.Series

ListSeries returns an array of view: default.

func (*SeriesDB) OneSeries

func (m *SeriesDB) OneSeries(ctx context.Context, id int, tenantID int) (*app.Series, error)

OneSeries returns an array of view: default.

func (*SeriesDB) TableName

func (m *SeriesDB) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

func (*SeriesDB) Update

func (m *SeriesDB) Update(ctx context.Context, model *Series) error

Update modifies a single record.

func (*SeriesDB) UpdateFromCreateSeriesPayload

func (m *SeriesDB) UpdateFromCreateSeriesPayload(ctx context.Context, payload *app.CreateSeriesPayload, id int) error

UpdateFromCreateSeriesPayload applies non-nil changes from CreateSeriesPayload to the model and saves it

func (*SeriesDB) UpdateFromUpdateSeriesPayload

func (m *SeriesDB) UpdateFromUpdateSeriesPayload(ctx context.Context, payload *app.UpdateSeriesPayload, id int) error

UpdateFromUpdateSeriesPayload applies non-nil changes from UpdateSeriesPayload to the model and saves it

type SeriesStorage

type SeriesStorage interface {
	DB() interface{}
	List(ctx context.Context) []Series
	Get(ctx context.Context, id int) (Series, error)
	Add(ctx context.Context, series *Series) (*Series, error)
	Update(ctx context.Context, series *Series) error
	Delete(ctx context.Context, id int) error

	ListSeries(ctx context.Context, tenantID int) []*app.Series
	OneSeries(ctx context.Context, id int, tenantID int) (*app.Series, error)

	UpdateFromCreateSeriesPayload(ctx context.Context, payload *app.CreateSeriesPayload, id int) error

	UpdateFromUpdateSeriesPayload(ctx context.Context, payload *app.UpdateSeriesPayload, id int) error
}

SeriesStorage represents the storage interface.

type Speaker

type Speaker struct {
	ID        int `gorm:"primary_key"` // This is the ID PK field
	Bio       *string
	CreatedAt time.Time
	DeletedAt *time.Time
	EventID   int // Belongs To Event
	FirstName string
	Github    *string
	ImageURL  *string
	LastName  string
	Linkedin  *string
	Twitter   *string
	UpdatedAt time.Time
	Event     Event
}

This is the Speaker model

func SpeakerFromCreateSpeakerPayload

func SpeakerFromCreateSpeakerPayload(payload *app.CreateSpeakerPayload) *Speaker

SpeakerFromCreateSpeakerPayload Converts source CreateSpeakerPayload to target Speaker model only copying the non-nil fields from the source.

func SpeakerFromUpdateSpeakerPayload

func SpeakerFromUpdateSpeakerPayload(payload *app.UpdateSpeakerPayload) *Speaker

SpeakerFromUpdateSpeakerPayload Converts source UpdateSpeakerPayload to target Speaker model only copying the non-nil fields from the source.

func (*Speaker) SpeakerToSpeaker

func (m *Speaker) SpeakerToSpeaker() *app.Speaker

SpeakerToSpeaker returns the Speaker representation of Speaker.

func (*Speaker) SpeakerToSpeakerAdmin

func (m *Speaker) SpeakerToSpeakerAdmin() *app.SpeakerAdmin

SpeakerToSpeakerAdmin returns the Speaker representation of Speaker.

func (m *Speaker) SpeakerToSpeakerLink() *app.SpeakerLink

SpeakerToSpeakerLink returns the Speaker representation of Speaker.

func (Speaker) TableName

func (m Speaker) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

type SpeakerDB

type SpeakerDB struct {
	Db gorm.DB
}

SpeakerDB is the implementation of the storage interface for Speaker.

func NewSpeakerDB

func NewSpeakerDB(db gorm.DB) *SpeakerDB

NewSpeakerDB creates a new storage type.

func (*SpeakerDB) Add

func (m *SpeakerDB) Add(ctx context.Context, model *Speaker) (*Speaker, error)

Add creates a new record. /// Maybe shouldn't return the model, it's a pointer.

func (*SpeakerDB) DB

func (m *SpeakerDB) DB() interface{}

DB returns the underlying database.

func (*SpeakerDB) Delete

func (m *SpeakerDB) Delete(ctx context.Context, id int) error

Delete removes a single record.

func (*SpeakerDB) Get

func (m *SpeakerDB) Get(ctx context.Context, id int) (Speaker, error)

Get returns a single Speaker as a Database Model This is more for use internally, and probably not what you want in your controllers

func (*SpeakerDB) List

func (m *SpeakerDB) List(ctx context.Context) []Speaker

List returns an array of Speaker

func (*SpeakerDB) ListSpeaker

func (m *SpeakerDB) ListSpeaker(ctx context.Context, eventID int) []*app.Speaker

ListSpeaker returns an array of view: default.

func (*SpeakerDB) ListSpeakerAdmin

func (m *SpeakerDB) ListSpeakerAdmin(ctx context.Context, eventID int) []*app.SpeakerAdmin

ListSpeakerAdmin returns an array of view: admin.

func (m *SpeakerDB) ListSpeakerLink(ctx context.Context, eventID int) []*app.SpeakerLink

ListSpeakerLink returns an array of view: link.

func (*SpeakerDB) OneSpeaker

func (m *SpeakerDB) OneSpeaker(ctx context.Context, id int, eventID int) (*app.Speaker, error)

OneSpeaker returns an array of view: default.

func (*SpeakerDB) OneSpeakerAdmin

func (m *SpeakerDB) OneSpeakerAdmin(ctx context.Context, id int, eventID int) (*app.SpeakerAdmin, error)

OneSpeakerAdmin returns an array of view: admin.

func (m *SpeakerDB) OneSpeakerLink(ctx context.Context, id int, eventID int) (*app.SpeakerLink, error)

OneSpeakerLink returns an array of view: link.

func (*SpeakerDB) TableName

func (m *SpeakerDB) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

func (*SpeakerDB) Update

func (m *SpeakerDB) Update(ctx context.Context, model *Speaker) error

Update modifies a single record.

func (*SpeakerDB) UpdateFromCreateSpeakerPayload

func (m *SpeakerDB) UpdateFromCreateSpeakerPayload(ctx context.Context, payload *app.CreateSpeakerPayload, id int) error

UpdateFromCreateSpeakerPayload applies non-nil changes from CreateSpeakerPayload to the model and saves it

func (*SpeakerDB) UpdateFromUpdateSpeakerPayload

func (m *SpeakerDB) UpdateFromUpdateSpeakerPayload(ctx context.Context, payload *app.UpdateSpeakerPayload, id int) error

UpdateFromUpdateSpeakerPayload applies non-nil changes from UpdateSpeakerPayload to the model and saves it

type SpeakerStorage

type SpeakerStorage interface {
	DB() interface{}
	List(ctx context.Context) []Speaker
	Get(ctx context.Context, id int) (Speaker, error)
	Add(ctx context.Context, speaker *Speaker) (*Speaker, error)
	Update(ctx context.Context, speaker *Speaker) error
	Delete(ctx context.Context, id int) error

	ListSpeakerAdmin(ctx context.Context, eventID int) []*app.SpeakerAdmin
	OneSpeakerAdmin(ctx context.Context, id int, eventID int) (*app.SpeakerAdmin, error)

	ListSpeaker(ctx context.Context, eventID int) []*app.Speaker
	OneSpeaker(ctx context.Context, id int, eventID int) (*app.Speaker, error)

	ListSpeakerLink(ctx context.Context, eventID int) []*app.SpeakerLink
	OneSpeakerLink(ctx context.Context, id int, eventID int) (*app.SpeakerLink, error)

	UpdateFromCreateSpeakerPayload(ctx context.Context, payload *app.CreateSpeakerPayload, id int) error

	UpdateFromUpdateSpeakerPayload(ctx context.Context, payload *app.UpdateSpeakerPayload, id int) error
}

SpeakerStorage represents the storage interface.

type Tenant

type Tenant struct {
	ID        int `gorm:"primary_key"` // This is the ID PK field
	CreatedAt time.Time
	DeletedAt *time.Time
	Events    []Event // has many Events
	Name      string
	UpdatedAt time.Time
	Users     []User // has many Users
}

This is the Tenant model

func TenantFromCreateTenantPayload

func TenantFromCreateTenantPayload(payload *app.CreateTenantPayload) *Tenant

TenantFromCreateTenantPayload Converts source CreateTenantPayload to target Tenant model only copying the non-nil fields from the source.

func TenantFromUpdateTenantPayload

func TenantFromUpdateTenantPayload(payload *app.UpdateTenantPayload) *Tenant

TenantFromUpdateTenantPayload Converts source UpdateTenantPayload to target Tenant model only copying the non-nil fields from the source.

func (Tenant) TableName

func (m Tenant) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

func (*Tenant) TenantToTenant

func (m *Tenant) TenantToTenant() *app.Tenant

TenantToTenant returns the Tenant representation of Tenant.

type TenantDB

type TenantDB struct {
	Db gorm.DB
}

TenantDB is the implementation of the storage interface for Tenant.

func NewTenantDB

func NewTenantDB(db gorm.DB) *TenantDB

NewTenantDB creates a new storage type.

func (*TenantDB) Add

func (m *TenantDB) Add(ctx context.Context, model *Tenant) (*Tenant, error)

Add creates a new record. /// Maybe shouldn't return the model, it's a pointer.

func (*TenantDB) DB

func (m *TenantDB) DB() interface{}

DB returns the underlying database.

func (*TenantDB) Delete

func (m *TenantDB) Delete(ctx context.Context, id int) error

Delete removes a single record.

func (*TenantDB) Get

func (m *TenantDB) Get(ctx context.Context, id int) (Tenant, error)

Get returns a single Tenant as a Database Model This is more for use internally, and probably not what you want in your controllers

func (*TenantDB) List

func (m *TenantDB) List(ctx context.Context) []Tenant

List returns an array of Tenant

func (*TenantDB) ListTenant

func (m *TenantDB) ListTenant(ctx context.Context) []*app.Tenant

ListTenant returns an array of view: default.

func (*TenantDB) OneTenant

func (m *TenantDB) OneTenant(ctx context.Context, id int) (*app.Tenant, error)

OneTenant returns an array of view: default.

func (*TenantDB) TableName

func (m *TenantDB) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

func (*TenantDB) Update

func (m *TenantDB) Update(ctx context.Context, model *Tenant) error

Update modifies a single record.

func (*TenantDB) UpdateFromCreateTenantPayload

func (m *TenantDB) UpdateFromCreateTenantPayload(ctx context.Context, payload *app.CreateTenantPayload, id int) error

UpdateFromCreateTenantPayload applies non-nil changes from CreateTenantPayload to the model and saves it

func (*TenantDB) UpdateFromUpdateTenantPayload

func (m *TenantDB) UpdateFromUpdateTenantPayload(ctx context.Context, payload *app.UpdateTenantPayload, id int) error

UpdateFromUpdateTenantPayload applies non-nil changes from UpdateTenantPayload to the model and saves it

type TenantStorage

type TenantStorage interface {
	DB() interface{}
	List(ctx context.Context) []Tenant
	Get(ctx context.Context, id int) (Tenant, error)
	Add(ctx context.Context, tenant *Tenant) (*Tenant, error)
	Update(ctx context.Context, tenant *Tenant) error
	Delete(ctx context.Context, id int) error

	ListTenant(ctx context.Context) []*app.Tenant
	OneTenant(ctx context.Context, id int) (*app.Tenant, error)

	UpdateFromCreateTenantPayload(ctx context.Context, payload *app.CreateTenantPayload, id int) error

	UpdateFromUpdateTenantPayload(ctx context.Context, payload *app.UpdateTenantPayload, id int) error
}

TenantStorage represents the storage interface.

type User

type User struct {
	ID             int `gorm:"primary_key"` // This is the ID PK field
	CreatedAt      time.Time
	DeletedAt      *time.Time
	Email          string
	FirstName      string `gorm:"column:firstname"`
	Href           string
	LastName       string `gorm:"column:lastname"`
	Password       string
	Role           string
	TenantID       int // Belongs To Tenant
	UpdatedAt      time.Time
	Validated      *bool
	ValidationCode *string
	Tenant         Tenant
}

This is the User model

func UserFromCreateAdminuserPayload

func UserFromCreateAdminuserPayload(payload *app.CreateAdminuserPayload) *User

UserFromCreateAdminuserPayload Converts source CreateAdminuserPayload to target User model only copying the non-nil fields from the source.

func UserFromCreateUserPayload

func UserFromCreateUserPayload(payload *app.CreateUserPayload) *User

UserFromCreateUserPayload Converts source CreateUserPayload to target User model only copying the non-nil fields from the source.

func UserFromUpdateAdminuserPayload

func UserFromUpdateAdminuserPayload(payload *app.UpdateAdminuserPayload) *User

UserFromUpdateAdminuserPayload Converts source UpdateAdminuserPayload to target User model only copying the non-nil fields from the source.

func UserFromUpdateUserPayload

func UserFromUpdateUserPayload(payload *app.UpdateUserPayload) *User

UserFromUpdateUserPayload Converts source UpdateUserPayload to target User model only copying the non-nil fields from the source.

func (*User) BeforeCreate

func (u *User) BeforeCreate() (err error)

TODO: Gorm changed something here, what is it?

func (User) TableName

func (m User) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

func (*User) UserToUser

func (m *User) UserToUser() *app.User

UserToUser returns the User representation of User.

func (m *User) UserToUserLink() *app.UserLink

UserToUserLink returns the User representation of User.

func (*User) UserToUserTenant

func (m *User) UserToUserTenant() *app.UserTenant

UserToUserTenant returns the User representation of User.

type UserDB

type UserDB struct {
	Db gorm.DB
}

UserDB is the implementation of the storage interface for User.

func NewUserDB

func NewUserDB(db gorm.DB) *UserDB

NewUserDB creates a new storage type.

func (*UserDB) Add

func (m *UserDB) Add(ctx context.Context, model *User) (*User, error)

Add creates a new record. /// Maybe shouldn't return the model, it's a pointer.

func (*UserDB) DB

func (m *UserDB) DB() interface{}

DB returns the underlying database.

func (*UserDB) Delete

func (m *UserDB) Delete(ctx context.Context, id int) error

Delete removes a single record.

func (*UserDB) Get

func (m *UserDB) Get(ctx context.Context, id int) (User, error)

Get returns a single User as a Database Model This is more for use internally, and probably not what you want in your controllers

func (*UserDB) GetByLogin

func (m *UserDB) GetByLogin(ctx context.Context, l Login) (User, error)

func (*UserDB) List

func (m *UserDB) List(ctx context.Context) []User

List returns an array of User

func (*UserDB) ListUser

func (m *UserDB) ListUser(ctx context.Context, tenantID int) []*app.User

ListUser returns an array of view: default.

func (m *UserDB) ListUserLink(ctx context.Context, tenantID int) []*app.UserLink

ListUserLink returns an array of view: link.

func (*UserDB) ListUserTenant

func (m *UserDB) ListUserTenant(ctx context.Context, tenantID int) []*app.UserTenant

ListUserTenant returns an array of view: tenant.

func (*UserDB) OneUser

func (m *UserDB) OneUser(ctx context.Context, id int, tenantID int) (*app.User, error)

OneUser returns an array of view: default.

func (m *UserDB) OneUserLink(ctx context.Context, id int, tenantID int) (*app.UserLink, error)

OneUserLink returns an array of view: link.

func (*UserDB) OneUserTenant

func (m *UserDB) OneUserTenant(ctx context.Context, id int, tenantID int) (*app.UserTenant, error)

OneUserTenant returns an array of view: tenant.

func (*UserDB) TableName

func (m *UserDB) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

func (*UserDB) Update

func (m *UserDB) Update(ctx context.Context, model *User) error

Update modifies a single record.

func (*UserDB) UpdateFromCreateAdminuserPayload

func (m *UserDB) UpdateFromCreateAdminuserPayload(ctx context.Context, payload *app.CreateAdminuserPayload, id int) error

UpdateFromCreateAdminuserPayload applies non-nil changes from CreateAdminuserPayload to the model and saves it

func (*UserDB) UpdateFromCreateUserPayload

func (m *UserDB) UpdateFromCreateUserPayload(ctx context.Context, payload *app.CreateUserPayload, id int) error

UpdateFromCreateUserPayload applies non-nil changes from CreateUserPayload to the model and saves it

func (*UserDB) UpdateFromUpdateAdminuserPayload

func (m *UserDB) UpdateFromUpdateAdminuserPayload(ctx context.Context, payload *app.UpdateAdminuserPayload, id int) error

UpdateFromUpdateAdminuserPayload applies non-nil changes from UpdateAdminuserPayload to the model and saves it

func (*UserDB) UpdateFromUpdateUserPayload

func (m *UserDB) UpdateFromUpdateUserPayload(ctx context.Context, payload *app.UpdateUserPayload, id int) error

UpdateFromUpdateUserPayload applies non-nil changes from UpdateUserPayload to the model and saves it

type UserStorage

type UserStorage interface {
	DB() interface{}
	List(ctx context.Context) []User
	Get(ctx context.Context, id int) (User, error)
	Add(ctx context.Context, user *User) (*User, error)
	Update(ctx context.Context, user *User) error
	Delete(ctx context.Context, id int) error

	ListUser(ctx context.Context, tenantID int) []*app.User
	OneUser(ctx context.Context, id int, tenantID int) (*app.User, error)

	ListUserLink(ctx context.Context, tenantID int) []*app.UserLink
	OneUserLink(ctx context.Context, id int, tenantID int) (*app.UserLink, error)

	ListUserTenant(ctx context.Context, tenantID int) []*app.UserTenant
	OneUserTenant(ctx context.Context, id int, tenantID int) (*app.UserTenant, error)

	UpdateFromCreateAdminuserPayload(ctx context.Context, payload *app.CreateAdminuserPayload, id int) error

	UpdateFromCreateUserPayload(ctx context.Context, payload *app.CreateUserPayload, id int) error

	UpdateFromUpdateAdminuserPayload(ctx context.Context, payload *app.UpdateAdminuserPayload, id int) error

	UpdateFromUpdateUserPayload(ctx context.Context, payload *app.UpdateUserPayload, id int) error
}

UserStorage represents the storage interface.

Jump to

Keyboard shortcuts

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