Documentation
¶
Index ¶
- type AuthToken
- type BaseModel
- type Book
- type BookRead
- type BookReport
- type BookSubSection
- type Bookmark
- type Chapter
- type Coin
- type Comment
- type FeaturedContent
- type Genre
- type Gift
- type Like
- type Log
- type Notification
- type Paragraph
- type Section
- type SentGift
- type SiteDetail
- type SubSection
- type Subscriber
- type SubscriptionPlan
- type Tag
- type Transaction
- type User
- func (user *User) BeforeCreate(tx *gorm.DB) (err error)
- func (user User) BooksCount() int
- func (user User) FollowersCount() int
- func (user User) FollowingsCount() int
- func (u *User) GenerateOTP(db *gorm.DB)
- func (u *User) GenerateToken(db *gorm.DB)
- func (user *User) GenerateUsername(db *gorm.DB, email string, username *string) string
- func (u User) IsOtpExpired() bool
- func (u User) IsTokenExpired() bool
- func (user User) SubscriptionExpired() bool
- type Vote
- type Waitlist
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Book ¶
type Book struct {
BaseModel
AuthorID uuid.UUID
Author User `gorm:"foreignKey:AuthorID;constraint:OnDelete:SET NULL;<-:false"`
Title string `gorm:"type: varchar(1000)"`
Slug string `gorm:"unique"`
Blurb string `gorm:"type: varchar(10000)"`
AgeDiscretion choices.AgeType
GenreID uuid.UUID
Genre Genre `gorm:"foreignKey:GenreID;constraint:OnDelete:SET NULL;<-:false"`
SubSections []SubSection `gorm:"many2many:book_sub_sections;joinForeignKey:BookID;joinReferences:SubSectionID"`
Tags []Tag `gorm:"many2many:book_tags"`
Chapters []Chapter `gorm:"constraint:OnDelete:CASCADE"`
CoverImage string `gorm:"type:varchar(10000)"`
Completed bool `gorm:"default:false"`
Reviews []Comment `gorm:"<-:false;constraint:OnDelete:CASCADE"`
Votes []Vote `gorm:"<-:false;constraint:OnDelete:CASCADE"`
Featured bool `gorm:"default:false"` //controlled by admin
WeeklyFeatured time.Time
Reads []BookRead `gorm:"<-:false;constraint:OnDelete:CASCADE"`
AvgRating float64 // meant for query purposes. do not intentionally populate field
Bookmark []Bookmark `gorm:"<-:false;constraint:OnDelete:CASCADE"`
// BOOK CONTRACT
FullName string `gorm:"type: varchar(1000)"`
Email string
PenName string `gorm:"type: varchar(1000)"`
Age uint
Country string `gorm:"type: varchar(1000)"`
Address string `gorm:"type: varchar(1000)"`
City string `gorm:"type: varchar(1000)"`
State string `gorm:"type: varchar(1000)"`
PostalCode string
TelephoneNumber string `gorm:"type: varchar(20)"`
IDType choices.ContractIDTypeChoice `gorm:"type: varchar(100)"`
IDFrontImage string
IDBackImage string
BookAvailabilityLink *string
PlannedLength uint
AverageChapter uint
UpdateRate uint
IntendedContract choices.ContractTypeChoice
FullPrice *int
ChapterPrice int
FullPurchaseMode bool `gorm:"default:false"`
ContractStatus choices.ContractStatusChoice `gorm:"default:PENDING"`
}
func (Book) ChaptersCount ¶
func (Book) GetWordCount ¶
func (Book) LibraryCount ¶
func (Book) ReadsCount ¶
func (Book) VotesCount ¶
type BookRead ¶
type BookRead struct {
BaseModel
UserID uuid.UUID
User User `gorm:"foreignKey:UserID;constraint:OnDelete:CASCADE;<-:false"`
BookID uuid.UUID `json:"book_id"`
Book Book `gorm:"foreignKey:BookID;constraint:OnDelete:CASCADE;<-:false"`
Completed bool `gorm:"default:false"`
InLibrary bool `gorm:"default:false"`
FirstRead bool `gorm:"default:false"`
}
type BookReport ¶
type BookReport struct {
BaseModel
UserID uuid.UUID
User User `gorm:"foreignKey:UserID;constraint:OnDelete:CASCADE;<-:false"`
BookID uuid.UUID `json:"book_id"`
Book Book `gorm:"foreignKey:BookID;constraint:OnDelete:CASCADE;<-:false"`
Reason string `gorm:"type: varchar(1000)"`
AdditionalExplanation *string `gorm:"type: varchar(1000)"`
}
type BookSubSection ¶
type Chapter ¶
type Chapter struct {
BaseModel
BookID uuid.UUID
Book Book `gorm:"foreignKey:BookID;constraint:OnDelete:CASCADE;<-:false"`
Title string `gorm:"type: varchar(255)"`
Slug string `gorm:"unique"`
Paragraphs []Paragraph `gorm:"foreignKey:ChapterID;constraint:OnDelete:CASCADE;"`
IsLast bool `gorm:"default:false"`
}
type Comment ¶
type Comment struct {
BaseModel
UserID uuid.UUID
User User `gorm:"foreignKey:UserID;constraint:OnDelete:CASCADE;<-:false"`
BookID *uuid.UUID // For reviews
Book *Book `gorm:"foreignKey:BookID;constraint:OnDelete:CASCADE;<-:false"`
Rating choices.RatingChoice
ParagraphID *uuid.UUID // For paragraph
Paragraph *Paragraph `gorm:"foreignKey:ParagraphID;constraint:OnDelete:CASCADE;<-:false"`
Likes []Like `gorm:"foreignKey:CommentID;constraint:OnDelete:CASCADE"`
Text string `gorm:"type:varchar(10000)"`
ParentID *uuid.UUID
Parent *Comment `gorm:"foreignKey:ParentID;constraint:OnDelete:CASCADE;<-:false"`
Replies []Comment `gorm:"foreignKey:ParentID;constraint:OnDelete:CASCADE"`
}
func (Comment) LikesCount ¶
func (Comment) RepliesCount ¶
type FeaturedContent ¶
type Gift ¶
type Notification ¶
type Notification struct {
BaseModel
SenderID uuid.UUID
Sender User `gorm:"foreignKey:SenderID;constraint:OnDelete:CASCADE;<-:false"`
ReceiverID uuid.UUID
Receiver User `gorm:"foreignKey:ReceiverID;constraint:OnDelete:CASCADE;<-:false"`
Ntype choices.NotificationTypeChoice
Text string
BookID *uuid.UUID
Book *Book `gorm:"foreignKey:BookID;constraint:OnDelete:CASCADE;<-:false"`
CommentID *uuid.UUID
Comment *Comment `gorm:"foreignKey:CommentID;constraint:OnDelete:SET NULL;<-:false"`
SentGiftID *uuid.UUID
SentGift *SentGift `gorm:"foreignKey:SentGiftID;constraint:OnDelete:CASCADE;<-:false"`
IsRead bool `gorm:"default:false"`
}
type Paragraph ¶
type Paragraph struct {
BaseModel
ChapterID uuid.UUID
Chapter Chapter `gorm:"foreignKey:ChapterID;constraint:OnDelete:CASCADE;<-:false"`
Index uint
Text string `gorm:"type:text"`
Comments []Comment `gorm:"foreignKey:ParagraphID;constraint:OnDelete:CASCADE"`
}
func (Paragraph) CommentsCount ¶
type Section ¶
type Section struct {
BaseModel
Name string `gorm:"unique"`
Slug string `gorm:"unique"`
SubSections []SubSection
}
type SentGift ¶
type SentGift struct {
BaseModel
SenderID uuid.UUID
Sender User `gorm:"foreignKey:SenderID;constraint:OnDelete:CASCADE;<-:false"`
ReceiverID uuid.UUID
Receiver User `gorm:"foreignKey:ReceiverID;constraint:OnDelete:CASCADE;<-:false"`
GiftID uuid.UUID
Gift Gift `gorm:"foreignKey:GiftID;constraint:OnDelete:CASCADE;<-:false"`
Claimed bool `gorm:"default:false"`
}
type SiteDetail ¶
type SiteDetail struct {
BaseModel
Name string `json:"name" gorm:"default:LitPad;type:varchar(50);not null"`
Email string `json:"email" gorm:"default:litpad@gmail.com;not null" example:"litpad@gmail.com"`
Phone string `json:"phone" gorm:"default:+23412344343545;type:varchar(20);not null" example:"+234345434343"`
Address string `json:"address" gorm:"default:234, Lagos, Nigeria;not null" example:"234, Lagos, Nigeria"`
Fb string `json:"fb" gorm:"default:https://facebook.com;not null" example:"https://facebook.com"`
Tw string `json:"tw" gorm:"default:https://twitter.com;not null" example:"https://twitter.com"`
Wh string `json:"wh" gorm:"default:https://wa.me/2348133831036;not null" example:"https://wa.me/2348133831036"`
Ig string `json:"ig" gorm:"default:https://instagram.com;not null" example:"https://instagram.com"`
}
type SubSection ¶
type SubSection struct {
BaseModel
Name string `gorm:"unique"`
Slug string `gorm:"unique"`
Books []Book `gorm:"many2many:book_sub_sections;joinForeignKey:SubSectionID;joinReferences:BookID"`
SectionID uuid.UUID
Section Section `gorm:"foreignKey:SectionID;constraint:OnDelete:SET NULL;<-:false"`
}
func (*SubSection) BeforeSave ¶
func (subSection *SubSection) BeforeSave(tx *gorm.DB) (err error)
type Subscriber ¶
type SubscriptionPlan ¶
type SubscriptionPlan struct {
BaseModel
Amount decimal.Decimal `gorm:"default:0"`
SubType choices.SubscriptionTypeChoice `gorm:"default:MONTHLY;unique"`
}
type Tag ¶
type Tag struct {
BaseModel
Name string
Slug string `gorm:"unique"`
GenreID uuid.UUID
Genre Genre `gorm:"foreignKey:GenreID;constraint:OnDelete:CASCADE;<-:false"`
Books []Book `gorm:"many2many:book_tags;"`
}
func (Tag) BooksCount ¶
type Transaction ¶
type Transaction struct {
BaseModel
Reference string `gorm:"type: varchar(1000);not null"` // payment id
UserID uuid.UUID `json:"user_id"`
User User `gorm:"foreignKey:UserID;constraint:OnDelete:CASCADE"`
// FOR COINS
CoinID *uuid.UUID `json:"coin_id"`
Coin *Coin `gorm:"foreignKey:CoinID;constraint:OnDelete:SET NULL"`
Quantity int `gorm:"default:1"`
// FOR SUBSCRIPTION
SubscriptionPlanID *uuid.UUID `json:"subscription_plan_id"`
SubscriptionPlan *SubscriptionPlan `gorm:"foreignKey:SubscriptionPlanID;constraint:OnDelete:SET NULL"`
PaymentType choices.PaymentType `json:"payment_type"`
PaymentPurpose choices.PaymentPurpose `json:"payment_purpose"`
PaymentStatus choices.PaymentStatus `json:"payment_status" gorm:"default:PENDING"`
ClientSecret string
}
func (Transaction) CoinsTotal ¶
func (t Transaction) CoinsTotal() *int
type User ¶
type User struct {
BaseModel
Name *string `gorm:"type: varchar(255);null"`
Username string `gorm:"type: varchar(1000);not null;unique;"`
Email string `gorm:"not null;unique;"`
Password string `gorm:"not null"`
IsEmailVerified bool `gorm:"default:false"`
IsSuperuser bool `gorm:"default:false"`
IsStaff bool `gorm:"default:false"`
IsActive bool `gorm:"default:true"`
Otp *uint `gorm:"null"`
OtpExpiry *time.Time `gorm:"null"`
TokenString *string `gorm:"null"`
TokenExpiry *time.Time `gorm:"null"`
Avatar string `gorm:"type:varchar(1000);null;"`
SocialLogin bool `gorm:"default:false"`
Bio *string `gorm:"type:varchar(1000);null;"`
AccountType choices.AccType `gorm:"type:varchar(100); default:READER"`
Followings []User `gorm:"many2many:user_followers;foreignKey:ID;joinForeignKey:Follower;References:ID;joinReferences:Following"`
Followers []User `gorm:"many2many:user_followers;foreignKey:ID;joinForeignKey:Following;References:ID;joinReferences:Follower"`
Coins int `gorm:"default:0"`
Lanterns int `gorm:"default:0"`
LikeNotification bool `gorm:"default:false"`
ReplyNotification bool `gorm:"default:false"`
CurrentPlan *choices.SubscriptionTypeChoice `gorm:"null"`
SubscriptionExpiry *time.Time `gorm:"index,null"`
ReminderSent bool `gorm:"default:false"`
// Back referenced
Books []Book `gorm:"foreignKey:AuthorID"`
}
func (User) BooksCount ¶
func (User) FollowersCount ¶
func (User) FollowingsCount ¶
func (*User) GenerateOTP ¶
func (*User) GenerateToken ¶
func (*User) GenerateUsername ¶
func (User) IsOtpExpired ¶
func (User) IsTokenExpired ¶
func (User) SubscriptionExpired ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.