models

package
v0.0.0-...-eedabaa Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Admin

type Admin struct {
	BaseModelSoftDelete
	FullName        string  `gorm:"not null;"`
	Email           string  `gorm:"not null;unique"`
	Password        string  `gorm:"not null;"`
	Role            string  `gorm:"not null;"`
	Phone           *string `gorm:"unique"`
	PhoneVerifiedAt *time.Time
	CreatedByID     *string
	CreatedBy       *Admin
	SuspendedAt     *time.Time
	SuspendedReason *string
	SuspendByID     *string
	SuspendBy       *Admin
}

Admin defines a administrators who are to manage the app

func (*Admin) BeforeCreate

func (admin *Admin) BeforeCreate(tx *gorm.DB) (err error)

BeforeCreate hook is called before the data is persisted to db

func (*Admin) BeforeDelete

func (admin *Admin) BeforeDelete(tx *gorm.DB) (err error)

BeforeDelete hook is called before the data is delete so that we dont delete super admin

type BaseModel

type BaseModel struct {
	// ID should use uuid_generate_v4() for the pk's
	ID        uuid.UUID `gorm:"primary_key;type:uuid;default:uuid_generate_v4()"`
	CreatedAt time.Time `gorm:"index;not null;default:CURRENT_TIMESTAMP"`
	UpdatedAt time.Time `gorm:"index;not null;default:CURRENT_TIMESTAMP"`
}

BaseModel defines the common columns that all db structs should hold, usually db structs based on this have no soft delete

type BaseModelSoftDelete

type BaseModelSoftDelete struct {
	BaseModel
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

BaseModelSoftDelete defines the common columns that all db structs should hold, usually. This struct also defines the fields for GORM triggers to detect the entity should soft delete

type BlogPost

type BlogPost struct {
	BaseModelSoftDelete
	Title       string `gorm:"not null;"`
	Image       *string
	Status      string `gorm:"not null;"` // active, draft
	TagID       string
	Tag         Tag
	Details     string `gorm:"not null;"`
	CreatedByID string
	CreatedBy   Admin
}

BlogPost defines a blog post

type Business

type Business struct {
	CountryID      *string
	Country        Country
	EntityType     *string
	Name           *string
	Owners         *string
	Directors      *string
	Address        *string
	NumberOfShares *string
	InitialCapital *float32
	Industry       *string
}

type Country

type Country struct {
	BaseModelSoftDelete
	Name        string `gorm:"not null;unique"`
	Description *string
	Currency    *string
	Image       *string
	CreatedByID string
	CreatedBy   Admin
}

Country defines countries we are working with

type Customer

type Customer struct {
	BaseModelSoftDelete
	UserID   string `gorm:"not null;"`
	User     User
	LawyerID *string
	Lawyer   User
	Type     *string // business, individual
	TIN      *string

	// For address
	DigitalAddress    *string
	AddressCountry    *string
	AddressCity       *string
	AddressStreetName *string
	AddressNumber     *string

	// Company
	CompanyName                  *string
	CompanyEntityType            *string
	CompanyEntityTypeOther       *string
	CompanyCountryOfRegistration *string
	CompanyDateOfRegistration    *time.Time
	CompanyRegistrationNumber    *string
}

Customer defines customers in the system. They could be businesses or individuals

type Document

type Document struct {
	Type              *string
	NatureOfDoc       *string
	Deadline          *time.Time
	ExistingDocuments *string
	NewDocuments      *string
}

type Faq

type Faq struct {
	BaseModel
	Question    string `gorm:"not null;"`
	Answer      string `gorm:"not null;"`
	CreatedByID string
	CreatedBy   Admin
}

Faq defines structure of frequently asked questions

type Lawyer

type Lawyer struct {
	BaseModelSoftDelete
	UserID string `gorm:"not null;"`
	User   User

	// For address
	DigitalAddress    *string
	AddressCountry    *string
	AddressCity       *string
	AddressStreetName *string
	AddressNumber     *string

	// lawyer stuff
	FirstYearOfBarAdmission *string
	LicenseNumber           *string
	TIN                     *string

	// Uploads
	NationalIDFront   *string
	NationalIDBack    *string
	BARMembershipCard *string
	LawCertificate    *string
	CV                *string
	CoverLetter       *string

	ApprovedAt   *time.Time
	ApprovedByID *string
	ApprovedBy   *Admin
}

Lawyer defines the registred laywers in the system

type LegalArea

type LegalArea struct {
	BaseModelSoftDelete
	Name        string `gorm:"not null;"`
	Image       *string
	Description *string
	CreatedByID string
	CreatedBy   Admin
}

LegalArea defines the legal areas in the system

type NewsletterSubscribers

type NewsletterSubscribers struct {
	BaseModel
	Email string `gorm:"not null;unique"`
	Type  string `gorm:"not null;"` // anon, user
}

NewsletterSubscribers defines those who have subscribed for newsletters

type Package

type Package struct {
	BaseModelSoftDelete
	Name           string `gorm:"not null;"`
	Description    *string
	AmountPerMonth *int
	AmountPerYear  *int
	Status         string // pending, approved
	CreatedByID    *string
	CreatedBy      Admin
	RequestedByID  *string //when they are creating a custom package
	RequestedBy    User
}

Package defines packages a user can subscribe to

type PackageService

type PackageService struct {
	BaseModelSoftDelete
	ServiceID     string `gorm:"not null;"`
	Service       Service
	PackageID     string `gorm:"not null;"`
	Package       Package
	Type          PackageServiceType
	Quantity      *int
	IsActive      *bool
	CreatedByID   *string
	CreatedBy     Admin
	RequestedByID *string
	RequestedBy   User
}

type PackageServiceType

type PackageServiceType string
const (
	Boolean PackageServiceType = "BOOLEAN"
	Number  PackageServiceType = "NUMBER"
)

type Payment

type Payment struct {
	BaseModelSoftDelete
	Code             uuid.UUID `gorm:"primary_key;type:uuid;default:uuid_generate_v4()"`
	Amount           float64   `gorm:"not null;"`
	ServicingID      *string
	Servicing        Servicing
	SubscriptionID   *string
	Subscription     Subscription
	AuthorizationUrl string        `gorm:"not null;"`
	AccessCode       string        `gorm:"not null;"`
	Status           PaymentStatus `gorm:"default:PENDING"`
	CreatedByID      string
	CreatedBy        User
}

Payment defines payments a user creates

type PaymentStatus

type PaymentStatus string
const (
	PaymentPending PaymentStatus = "PENDING"
	PaymentSuccess PaymentStatus = "SUCCESS"
	PaymentFailed  PaymentStatus = "FAILED"
)

type Service

type Service struct {
	BaseModelSoftDelete
	Name        string `gorm:"not null;"`
	Price       *float64
	Description *string
	Type        ServiceType `gorm:"default:SUBSCRIBE"` // subscribe/unsubscribe/both
	Variant     string      // BOOLEAN/NUMBER
	CreatedByID string
	CreatedBy   Admin
}

Service defines services a user can subscribe to

type ServiceType

type ServiceType string
const (
	Subscribe   ServiceType = "SUBSCRIBE"
	Unsubscribe ServiceType = "UNSUBSCRIBE"
	Both        ServiceType = "BOTH"
)

type Servicing

type Servicing struct {
	BaseModelSoftDelete
	ServiceID string `gorm:"not null;"`
	Service   Service
	Cost      *float64 `gorm:"not null;"`
	// PaymentID       *string
	// Payment         Payment
	Status          ServicingStatus `gorm:"default:PENDING"`
	SubscriptionID  *string
	Subscription    Subscription
	LawyerID        *string
	Lawyer          User
	CreatedByID     string
	CreatedBy       User
	ServiceFieldsID string
	ServiceFields   ServicingField
}

Servicing defines each single services user has made

type ServicingField

type ServicingField struct {
	BaseModelSoftDelete
	Business  Business  `gorm:"embedded; embeddedPrefix:business_"`
	Trademark Trademark `gorm:"embedded; embeddedPrefix:trademark_"`
	Document  Document  `gorm:"embedded; embeddedPrefix:document_"`
}

type ServicingStatus

type ServicingStatus string
const (
	ServicingPending ServicingStatus = "PENDING"
	ServicingPaid    ServicingStatus = "PAID"
	ServicingActive  ServicingStatus = "ACTIVE"
	ServicingDone    ServicingStatus = "DONE"
)

type Subscription

type Subscription struct {
	BaseModelSoftDelete
	PackageID string `gorm:"not null;"`
	Package   Package
	// PaymentID   *string
	// Payment     Payment
	Status      SubscriptionStatus `gorm:"default:PENDING"`
	SubscribeAt time.Time
	ExpiresAt   time.Time
	CreatedByID string
	CreatedBy   User
}

Subscription defines what the user has subscribed

type SubscriptionStatus

type SubscriptionStatus string
const (
	SubscriptionPending SubscriptionStatus = "PENDING"
	SubscriptionActive  SubscriptionStatus = "ACTIVE"
	SubscriptionExpired SubscriptionStatus = "EXPIRED"
)

type Tag

type Tag struct {
	BaseModelSoftDelete
	Name        string `gorm:"not null;"`
	CreatedByID string
	CreatedBy   Admin
}

Tag defines categoru of a certain blog post

type Trademark

type Trademark struct {
	CountryID                 *string
	Country                   Country
	OwnershipType             *string
	Owners                    *string
	Address                   *string
	ClassificationOfTrademark *string
	Uploads                   *string
}

type User

type User struct {
	BaseModelSoftDelete
	Type            string `gorm:"not null;"` // customer, lawyer
	LastName        *string
	FirstName       *string
	OtherNames      *string
	Email           string  `gorm:"not null;unique"`
	Password        string  `gorm:"not null;"`
	Phone           *string `gorm:"unique"`
	EmailVerifiedAt *time.Time
	PhoneVerifiedAt *time.Time
	SetupAt         *time.Time

	SuspendedAt     *time.Time
	SuspendedReason *string
	SuspendedByID   *string
	SuspendedBy     *Admin
}

User defines the two typa users in the system (Lawyers and normal clients)

func (*User) BeforeCreate

func (user *User) BeforeCreate(tx *gorm.DB) (err error)

BeforeCreate hook is called before the data is persisted to db

Jump to

Keyboard shortcuts

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