models

package
v0.0.0-...-47d78cf Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateOrgRequestModel

type CreateOrgRequestModel struct {
	Name        string `json:"name" validate:"required,min=2,max=255"`
	Description string `json:"description" `
	Email       string `json:"email" validate:"required"`
	State       string `json:"state" validate:"required"`
	Industry    string `json:"industry" validate:"required"`
	Type        string `json:"type" validate:"required"`
	Address     string `json:"address" validate:"required"`
	Country     string `json:"country" validate:"required"`
}

type CreateUserRequestModel

type CreateUserRequestModel struct {
	Email       string `json:"email" validate:"required"`
	Password    string `json:"password" validate:"required"`
	FirstName   string `json:"first_name" validate:"required"`
	LastName    string `json:"last_name" validate:"required"`
	UserName    string `json:"username" validate:"required"`
	PhoneNumber string `json:"phone_number"`
}

type LoginRequestModel

type LoginRequestModel struct {
	Email    string `json:"email" validate:"required"`
	Password string `json:"password" validate:"required"`
}

type Organisation

type Organisation struct {
	ID          string    `gorm:"type:uuid;primaryKey;unique;not null" json:"id"`
	Name        string    `gorm:"type:varchar(255);not null" json:"name"`
	Description string    `gorm:"type:text" json:"description"`
	Email       string    `gorm:"type:varchar(255);unique" json:"email"`
	State       string    `gorm:"type:varchar(255)" json:"state"`
	Industry    string    `gorm:"type:varchar(255)" json:"industry"`
	Type        string    `gorm:"type:varchar(255)" json:"type"`
	Address     string    `gorm:"type:varchar(255)" json:"address"`
	Country     string    `gorm:"type:varchar(255)" json:"country"`
	OwnerID     string    `gorm:"type:uuid;" json:"owner_id"`
	Users       []User    `gorm:"many2many:user_organisations;foreignKey:ID;joinForeignKey:org_id;References:ID;joinReferences:user_id"`
	CreatedAt   time.Time `gorm:"column:created_at; not null; autoCreateTime" json:"created_at"`
	UpdatedAt   time.Time `gorm:"column:updated_at; null; autoUpdateTime" json:"updated_at"`
}

func (*Organisation) CreateOrganisation

func (c *Organisation) CreateOrganisation(db *gorm.DB) error

type Ping

type Ping struct {
	Message string `json:"message"`
}

type Product

type Product struct {
	ID          string    `gorm:"type:uuid;primaryKey" json:"product_id"`
	Name        string    `gorm:"column:name; type:varchar(255); not null" json:"name"`
	Description string    `gorm:"column:description;type:text;" json:"description"`
	OwnerID     string    `gorm:"type:uuid;" json:"owner_id"`
	CreatedAt   time.Time `gorm:"column:created_at; not null; autoCreateTime" json:"created_at"`
	UpdatedAt   time.Time `gorm:"column:updated_at; null; autoUpdateTime" json:"updated_at"`
}

type Profile

type Profile struct {
	ID        string    `gorm:"type:uuid;primary_key" json:"profile_id"`
	FirstName string    `gorm:"column:first_name; type:text; not null" json:"first_name"`
	LastName  string    `gorm:"column:last_name; type:text;not null" json:"last_name"`
	Phone     string    `gorm:"type:varchar(255)" json:"phone"`
	AvatarURL string    `gorm:"type:varchar(255)" json:"avatar_url"`
	Userid    string    `gorm:"type:uuid;" json:"user_id"`
	CreatedAt time.Time `gorm:"column:created_at; not null; autoCreateTime" json:"created_at"`
	UpdatedAt time.Time `gorm:"column:updated_at; null; autoUpdateTime" json:"updated_at"`
}

type User

type User struct {
	ID            string         `gorm:"type:uuid;primaryKey;unique;not null" json:"id"`
	Name          string         `gorm:"column:name; type:varchar(255)" json:"name"`
	Email         string         `gorm:"column:email; type:varchar(255)" json:"email"`
	Password      string         `gorm:"column:password; type:text; not null" json:"-"`
	Profile       Profile        `gorm:"foreignKey:Userid;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" json:"profile"`
	Organisations []Organisation `gorm:"many2many:user_organisations;;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" json:"organisations" ` // many to many relationship
	Products      []Product      `gorm:"foreignKey:OwnerID" json:"products"`
	CreatedAt     time.Time      `gorm:"column:created_at; not null; autoCreateTime" json:"created_at"`
	UpdatedAt     time.Time      `gorm:"column:updated_at; null; autoUpdateTime" json:"updated_at"`
}

func (*User) AddUserToOrganisation

func (u *User) AddUserToOrganisation(db *gorm.DB, user interface{}, orgs []interface{}) error

func (*User) CreateUser

func (u *User) CreateUser(db *gorm.DB) error

func (*User) GetUserByID

func (u *User) GetUserByID(db *gorm.DB, userID string) (User, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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