Documentation
¶
Index ¶
- func CreateNewClass(class *Class) error
- func CreateNewUser(user *User) error
- func DB() *gorm.DB
- type Article
- type ArticleComment
- type ArticleModel
- type ArticleStatus
- type Class
- type ClassImage
- type ClassMeeting
- type ClassMeetingAttendance
- type ClassPermission
- type ClassPermissionType
- type User
- type UserType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateNewClass ¶
func CreateNewUser ¶
Types ¶
type Article ¶
type Article struct {
ID int `gorm:"primaryKey" json:"id"`
UserID int `json:"user_id"`
Title string `gorm:"size:50" json:"title"`
Slug string `gorm:"size:60;uniqueIndex" json:"slug"`
Content string `gorm:"type:text" json:"content"`
Views int `gorm:"default:0" json:"views"`
Status ArticleStatus `gorm:"default:DRAFTED" json:"status"`
UpdatedAt time.Time `json:"updated_at"`
CreatedAt time.Time `json:"created_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at"`
Comments []ArticleComment `gorm:"foreignKey:ArticleID" json:"comments"`
}
Article is model to implement fields in database.
type ArticleComment ¶
type ArticleComment struct {
ID int `gorm:"primaryKey" json:"id"`
ArticleID int `json:"article_id"`
UserID int `json:"user_id"`
Text string `gorm:"type:text" json:"text"`
UpdatedAt time.Time `json:"updated_at"`
CreatedAt time.Time `json:"created_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at"`
}
ArticleComment
type ArticleModel ¶
type ArticleModel struct {
// contains filtered or unexported fields
}
ArticleModel struct to article model.
func NewArticleModel ¶
func NewArticleModel(db *gorm.DB) *ArticleModel
NewArticleModel is function to run article model.
func (*ArticleModel) CreateNewArticle ¶
func (a *ArticleModel) CreateNewArticle(article *Article) error
CreateNewArticle is function to create new article.
func (*ArticleModel) GetAllArticle ¶
func (a *ArticleModel) GetAllArticle(status ArticleStatus, limit, offset int) []Article
GetAllArticle is function to get all article.
func (*ArticleModel) GetArticleBySlug ¶
func (a *ArticleModel) GetArticleBySlug(slug string) (Article, error)
GetArticleBySlug is function to get article by given slug.
type ArticleStatus ¶
type ArticleStatus string
const ( PUBLISHED ArticleStatus = "PUBLISHED" DRAFTED ArticleStatus = "DRAFTED" )
type Class ¶
type Class struct {
ID int `gorm:"primaryKey" json:"id"`
Title string `gorm:"size:50;unique" json:"title"`
Slug string `gorm:"size:60;uniqueIndex" json:"slug"`
Description string `gorm:"type:text" json:"description"`
Logo *string `gorm:"size:255" json:"logo"`
IsActive bool `gorm:"default:false" json:"is_active"`
UpdatedAt time.Time `json:"updated_at"`
CreatedAt time.Time `json:"created_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at"`
Mentors []*User `gorm:"many2many:classes_user_mentor" json:"mentors"`
Members []*User `gorm:"many2many:classes_user_member" json:"members"`
Images []*ClassImage `gorm:"foreignKey:ClassID" json:"images"`
Meetings []*ClassMeeting `gorm:"foreignKey:ClassID" json:"meetings"`
}
Class is struct for implement class in kafekoding.
func GetAllClass ¶
func GetClassBySlug ¶
type ClassImage ¶
type ClassImage struct {
ID int `gorm:"primaryKey" json:"id"`
ClassID int `json:"class_id"`
Image string `gorm:"size:255" json:"image"`
Caption *string `gorm:"size:255" json:"caption"`
UpdatedAt time.Time `json:"updated_at"`
CreatedAt time.Time `json:"created_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at"`
}
type ClassMeeting ¶
type ClassMeeting struct {
ID int `gorm:"primaryKey" json:"id"`
ClassID int `json:"class_id"`
Title string `gorm:"size:50" json:"title"`
Slug string `gorm:"size:60;uniqueIndex" json:"slug"`
Content string `gorm:"type:text" json:"content"`
OpenedAt time.Time `json:"opened_at"`
ClosedAt time.Time `json:"closed_at"`
UpdatedAt time.Time `json:"updated_at"`
CreatedAt time.Time `json:"created_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at"`
Attendances []ClassMeetingAttendance `gorm:"foreignKey:MeetingID" json:"attendances"`
}
type ClassMeetingAttendance ¶
type ClassMeetingAttendance struct {
ID int `gorm:"primaryKey" json:"id"`
MeetingID int `json:"meeting_id"`
Users []*User `gorm:"many2many:classes_meetingattendance_user" json:"users"`
UpdatedAt time.Time `json:"updated_at"`
CreatedAt time.Time `json:"created_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at"`
}
type ClassPermission ¶
type ClassPermissionType ¶
type ClassPermissionType string
const ( JOIN ClassPermissionType = "JOIN" OUT ClassPermissionType = "OUT" )
type User ¶
type User struct {
ID int `gorm:"primaryKey" json:"id,omitempty"`
FirstName string `gorm:"size:50" json:"first_name,omitempty"`
LastName string `gorm:"size:50" json:"last_name,omitempty"`
Username string `gorm:"size:50;uniqueIndex" json:"username,omitempty"`
Email string `gorm:"size:50;uniqueIndex" json:"email,omitempty"`
Avatar *string `gorm:"size:255" json:"avatar,omitempty"`
Password string `gorm:"size:128" json:"-"`
IsActive bool `gorm:"default:false" json:"is_active,omitempty"`
IsLogined bool `gorm:"default:false" json:"is_logined,omitempty"`
Type UserType `gorm:"default:1" json:"type"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
DateJoined time.Time `gorm:"autoCreateTime" json:"date_joined,omitempty"`
Articles []Article `gorm:"foreignKey:UserID" json:"articles,omitempty"`
ClassMentors []*Class `gorm:"many2many:classes_user_mentor" json:"class_mentors,omitempty"`
ClassMembers []*Class `gorm:"many2many:classes_user_member" json:"class_members,omitempty"`
}
func GetUserByEmail ¶
func GetUserByID ¶
func GetUserByUsername ¶
Click to show internal directories.
Click to hide internal directories.