model

package
v0.0.0-...-2cf31f2 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusGreen  = "green"
	StatusOrange = "orange"
	StatusRed    = "red"
)

Variables

This section is empty.

Functions

func HashPassword

func HashPassword(password string) (string, error)

func ValidatePassword

func ValidatePassword(password string) error

Types

type Base

type Base struct {
	ID        uuid.UUID      `gorm:"type:uuid;primaryKey" json:"id"`
	CreatedAt time.Time      `json:"createdAt"`
	UpdatedAt time.Time      `json:"updatedAt"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"deletedAt,omitempty"`
}

func (*Base) BeforeCreate

func (base *Base) BeforeCreate(tx *gorm.DB) (err error)

type Category

type Category struct {
	Base
	Name string `gorm:"not null" json:"name"`
}

type Error

type Error struct {
	// The general error message
	//
	// required: true
	//
	// example: Unauthorized
	Error string `json:"error"`
	// The http error code
	//
	// required: true
	//
	// example: 401
	ErrorCode int `json:"errorCode"`
	// The error description
	//
	// required: true
	//
	// example: You are not authorized to access this resource
	ErrorDescription string `json:"errorDescription"`
}

Error Model

Error model is used to return error messages to the client.

swagger:model Error

type Health

type Health struct {
	Health   string `json:"health"`
	Database string `json:"database"`
}

type PasswordResetToken

type PasswordResetToken struct {
	Base
	UserID    uuid.UUID `gorm:"type:uuid;not null"`
	Token     string    `gorm:"index;unique;not null;"`
	ExpiresAt time.Time `json:"expiresAt"`
	User      User      `gorm:"foreignKey:UserID;"`
}

type Permission

type Permission struct {
	Base
	Name        string `gorm:"not null" json:"name"`
	Description string `json:"description"`
	Roles       []Role `gorm:"many2many:role_permissions;"`
}

type RefreshToken

type RefreshToken struct {
	Base
	Token     string    `gorm:"index;unique;not null;" json:"token"`
	ExpiresAt time.Time `json:"expiresAt"`
	UserID    uuid.UUID `gorm:"type:uuid;not null;" json:"userId"`
	User      User      `gorm:"foreignKey:UserID;" json:"user"`
}

type Reminder

type Reminder struct {
	Base
	ReminderDate time.Time `gorm:"not null" json:"reminderDate"`
	TaskID       uuid.UUID `gorm:"type:uuid;not null" json:"taskID"`
	Task         Task      `gorm:"foreignKey:TaskID;"`
}

type Role

type Role struct {
	Base
	Name        string       `gorm:"not null" json:"name"`
	Description string       `json:"description"`
	WorkspaceID uuid.UUID    `gorm:"type:uuid;not null"`
	Permissions []Permission `gorm:"many2many:role_permissions;"`
}

type Task

type Task struct {
	Base
	Title       string
	Description string
	DueDate     time.Time
	Status      string
	Priority    string
	CompletedAt time.Time
	CategoryID  uuid.UUID  `gorm:"type:uuid;not null;"`
	CreatorID   uuid.UUID  `gorm:"type:uuid;not null"`
	WorkspaceID uuid.UUID  `gorm:"type:uuid;not null"`
	Creator     User       `gorm:"foreignKey:CreatorID;"`
	Category    Category   `gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
	Workspace   Workspace  `gorm:"foreignKey:WorkspaceID"`
	Reminders   []Reminder `gorm:"foreignKey:TaskID"`
	Users       []User     `gorm:"many2many:user_tasks;"`
}

type TaskAssignment

type TaskAssignment struct {
	Base
	AssignedAt time.Time
	UserID     uint
	User       User `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	TaskID     uint
	Task       Task `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
}

type User

type User struct {
	Base
	Email               string               `gorm:"uniqueIndex" json:"email"`
	PasswordHash        string               `json:"-"`
	PasswordLastChanged time.Time            `json:"-"`
	Verified            bool                 `gorm:"default:false" json:"verified"`
	FirstName           string               `json:"firstName"`
	LastName            string               `json:"lastName"`
	ProfileImage        string               `json:"profileImage"`
	LastLogin           time.Time            `json:"lastLogin"`
	RefreshTokens       []RefreshToken       `gorm:"foreignKey:UserID" json:"-"`
	PasswordResetTokens []PasswordResetToken `gorm:"foreignKey:UserID" json:"-"`
	OwnedWorkspaces     []Workspace          `gorm:"foreignKey:OwnerID" json:"ownedWorkspaces"`
	Tasks               []Task               `gorm:"many2many:user_tasks;"`
	Workspaces          []Workspace          `gorm:"many2many:workspace_members;"`
	UserRoleWorkspaces  []WorkspaceRole      `gorm:"foreignKey:UserID"`
}

User Model

User model is used to store user information.

swagger:model User

func (User) TableName

func (User) TableName() string

TableName sets the table name for the user model.

func (*User) VerifyPassword

func (u *User) VerifyPassword(password string) (err error)

type VersionInfo

type VersionInfo struct {
	Version   string `json:"version"`
	Commit    string `json:"commit"`
	BuildTime string `json:"buildTime"`
}

type Workspace

type Workspace struct {
	Base
	Name        string `gorm:"not null"`
	Description string
	OwnerID     uuid.UUID `gorm:"type:uuid;not null;"`
	Owner       User      `gorm:"foreignKey:OwnerID;"`
	Roles       []Role    `gorm:"foreignKey:WorkspaceID;"`
	Tasks       []Task    `gorm:"foreignKey:WorkspaceID;"`
	Users       []User    `gorm:"many2many:workspace_members;"`
}

type WorkspaceRole

type WorkspaceRole struct {
	Base
	WorkspaceID uuid.UUID
	UserID      uuid.UUID
	RoleID      uuid.UUID
	Workspace   Workspace `gorm:"forgeinKey:WorkspaceID;"`
	User        User      `gorm:"forgeinKey:UserID;"`
	Role        Role      `gorm:"forgeinKey:RoleID;"`
}

Jump to

Keyboard shortcuts

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