models

package
v0.0.0-...-4f00221 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const EMAIL_REGEX = `^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$`
View Source
const MAX_CITY_SIZE = 32
View Source
const MAX_FNAME_SIZE = 50
View Source
const MAX_INTITIALS_SIZE = 2
View Source
const MAX_LNAME_SIZE = 50
View Source
const MAX_NAME_SIZE = 255
View Source
const MAX_PASSWORD_SIZE = 16
View Source
const MAX_STATE_SIZE = 32
View Source
const MAX_STREETNAME_SIZE = 120
View Source
const MAX_STREETNUM_SIZE = 8
View Source
const MAX_SUITE_SIZE = 8
View Source
const MAX_USERNAME_SIZE = 16
View Source
const MAX_ZIP_SIZE = 5
View Source
const MIN_FNAME_SIZE = 2
View Source
const MIN_LNAME_SIZE = 2
View Source
const MIN_PASSWORD_SIZE = 8
View Source
const MIN_USERNAME_SIZE = 6

Variables

View Source
var PHONE_FILTER = []string{"-", "(", ")", " "}

Functions

This section is empty.

Types

type Address

type Address struct {
	gorm.Model
	StreetNumber string
	StreetName   string
	Suite        string
	City         string
	State        string
	ZipCode      string
}

func (*Address) IsValidAddr

func (a *Address) IsValidAddr() error

type Company

type Company struct {
	gorm.Model
	Name        string
	Alias       string
	AddressID   uint
	Address     Address
	Departments []Department
}

func NewCompany

func NewCompany(name string, addr Address) *Company

func (*Company) BeforeCreate

func (c *Company) BeforeCreate(tx *gorm.DB) error

type Department

type Department struct {
	gorm.Model
	Name      string
	Members   []User
	CompanyID uint
	Company   Company
}

func NewDepartment

func NewDepartment(name string, companyID uint) *Department

func (*Department) BeforeCreate

func (d *Department) BeforeCreate(tx *gorm.DB) error

type Role

type Role struct {
	gorm.Model
	UserID uint
	Name   string
}

func NewRole

func NewRole(name string) *Role

type User

type User struct {
	gorm.Model
	FirstName      string
	LastName       string
	MiddleInitials string
	Username       string `gorm:"unique"`
	Password       string
	Email          string
	Phone          string
	Role           Role
	CompanyID      uint
	Company        Company
	DepartmentID   uint
	Department     Department
	UpdatedAt      time.Time
	CreatedAt      time.Time
	DeletedAt      gorm.DeletedAt
}

func NewUser

func NewUser(config UserConfig, companyID uint, departmentID uint) *User

func (*User) BeforeCreate

func (u *User) BeforeCreate(tx *gorm.DB) error

func (*User) CheckPassword

func (u *User) CheckPassword(password string) error

type UserConfig

type UserConfig struct {
	FirstName      string
	LastName       string
	MiddleInitials string
	Username       string
	Password       string
	Email          string
	Phone          string
	Role           Role
}

Jump to

Keyboard shortcuts

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