Documentation
¶
Index ¶
- func AddUserToCourseInfo(uid primitive.ObjectID, cid primitive.ObjectID) error
- func CalcAvgScore(cid primitive.ObjectID) (float32, error)
- func CountReviewByCourseId(cid primitive.ObjectID) (int64, error)
- func CreateCourseTextIndexModels() []mongo.IndexModel
- func InitDb(config *ultis.Config) error
- func IsBanned(uid primitive.ObjectID) bool
- func IsUserJoined(cid primitive.ObjectID, uid primitive.ObjectID) bool
- type Approve
- type Category
- type Course
- func FindAllCourseByCatId(cid primitive.ObjectID) ([]Course, error)
- func FindAllCourseBySubcatId(scid primitive.ObjectID) ([]Course, error)
- func FindByCatId(cid primitive.ObjectID, limit int64, offset int64) ([]Course, error)
- func FindByLecId(lid primitive.ObjectID) ([]Course, error)
- func FindBySubcatId(subcatId primitive.ObjectID, limit int64, offset int64) ([]Course, error)
- func Get5RandomCourseBySubcat(cid primitive.ObjectID) ([]Course, error)
- func GetAllCourse(excludeDisabled bool) ([]Course, error)
- func GetTop10MostRegisterCourse() ([]Course, error)
- func SearchByKeyword(keyword string, limit int64, offset int64) ([]Course, error)
- func (c *Course) AfterInsert() error
- func (c *Course) BeforeInsert() error
- func (c *Course) ConvertToFullCourse() (*FullCourse, error)
- func (c *Course) ConvertToSimpleCourse() (*SimpleCourse, error)
- func (c *Course) FindById(oid primitive.ObjectID) error
- func (c *Course) ForceRemove() error
- func (c *Course) Remove() error
- func (c *Course) Save() error
- func (c *Course) UpdateChapterCount(count int) error
- func (c *Course) UpdateCourseDesc(short string, full string) error
- func (c *Course) UpdateCourseStatus(isDone bool) error
- func (c *Course) UpdateDisableStatus(disabled bool) error
- func (c *Course) UpdateDiscount(discount float64) error
- func (c *Course) UpdateWatchCount() error
- type CourseChapter
- type DisplayableReview
- type FullCourse
- type Review
- func (rv *Review) ConvertToDisplayableReview() (*DisplayableReview, error)
- func (r *Review) DeleteReview(rid primitive.ObjectID) error
- func (r *Review) FindById(oid primitive.ObjectID) error
- func (r *Review) FindByUid(uid primitive.ObjectID) error
- func (r *Review) FindByUidAndCid(uid primitive.ObjectID, cid primitive.ObjectID) error
- func (r *Review) Save() error
- func (r *Review) UpdateReview(newContent string, newScore float32) error
- type SimpleCourse
- func GetAllCourseAsSimple() ([]SimpleCourse, error)
- func GetAllCourseByCatIdAsSimple(catId primitive.ObjectID) ([]SimpleCourse, error)
- func GetAllCourseBySubcatIdAsSimple(subcatId primitive.ObjectID) ([]SimpleCourse, error)
- func GetTop10MostWatchCourse() ([]SimpleCourse, error)
- func GetTop10NewestCourse() ([]SimpleCourse, error)
- func GetTop4HighlightCourse() ([]SimpleCourse, error)
- type SubCategory
- func (subcat *SubCategory) BeforeInsert() error
- func (subcat *SubCategory) FindByName(name string) error
- func (subcat *SubCategory) FindSubCategoryById(oid primitive.ObjectID) error
- func (subcat *SubCategory) Remove() error
- func (subcat *SubCategory) Save() error
- func (subcat *SubCategory) UpdateName(name string) error
- type TimeMark
- type User
- func (u *User) AfterInsert() error
- func (u *User) Ban() error
- func (u *User) BeforeInsert() error
- func (u *User) ConfirmOtp(username string, otp string) error
- func (u *User) ConfirmResetPassword(recoverCode string, newPassword string) error
- func (u *User) FindByEmail(email string) error
- func (u *User) FindById(oid primitive.ObjectID) error
- func (u *User) FindByIdAndRfToken(oid primitive.ObjectID, rf string) error
- func (u *User) FindByUsername(username string) error
- func (u *User) GenerateOtp() error
- func (u *User) GenerateRecoverCode() error
- func (u *User) GenerateRfToken() error
- func (u *User) Save() error
- func (u *User) Unban() error
- func (u *User) UpdateLecturerStatus(isLec bool) error
- func (u *User) UpdateOtp(username string) (*string, error)
- func (u *User) UpdatePassword(newPassword string) error
- func (u *User) UpdateProfile(newFullname string, newEmail string) error
- func (u *User) UpdateTokens() (*string, *string, error)
- type VideoMetadata
- type WatchList
- type XSimpleCourse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddUserToCourseInfo ¶
func CreateCourseTextIndexModels ¶
func CreateCourseTextIndexModels() []mongo.IndexModel
Types ¶
type Approve ¶
type Approve struct { field.DefaultField `json:"-" bson:",inline"` LecId primitive.ObjectID `json:"lid" bson:"lid"` }
type Category ¶
type Category struct { field.DefaultField `json:",inline" bson:",inline" json:"-"` Name string `json:"name" bson:"name" binding:"required"` }
func GetAllCategory ¶
func (*Category) FindCategoryById ¶
func (*Category) FindCategoryByName ¶
func (*Category) UpdateName ¶
type Course ¶
type Course struct { field.DefaultField `bson:",inline"` LecId primitive.ObjectID `json:"lid" bson:"lid" binding:"required"` CatId primitive.ObjectID `json:"cat_id" bson:"cat_id" binding:"required"` Ava string `json:"ava" bson:"ava"` Name string `json:"name" bson:"name" binding:"required"` ShortDesc string `json:"short_desc" bson:"short_desc"` FullDesc string `json:"full_desc" bson:"full_desc"` Fee float64 `json:"fee" bson:"fee" binding:"required"` Discount float64 `json:"discount" bson:"discount" binding:"required"` ChapterCount int `json:"chapter_count" bson:"chapter_count"` IsDone bool `json:"is_done" bson:"is_done"` RegCount int `json:"reg_count" bson:"reg_count"` WatchCount int `json:"watch_count" bson:"watch_count"` Disabled bool `json:"disabled" bson:"disabled"` }
func FindAllCourseBySubcatId ¶
func FindByCatId ¶
func FindBySubcatId ¶
func GetAllCourse ¶
func SearchByKeyword ¶
func (*Course) AfterInsert ¶
func (*Course) ConvertToFullCourse ¶
func (c *Course) ConvertToFullCourse() (*FullCourse, error)
func (*Course) ConvertToSimpleCourse ¶
func (c *Course) ConvertToSimpleCourse() (*SimpleCourse, error)
func (*Course) ForceRemove ¶
func (*Course) UpdateChapterCount ¶
func (*Course) UpdateCourseDesc ¶
func (*Course) UpdateCourseStatus ¶
func (*Course) UpdateDisableStatus ¶
func (*Course) UpdateDiscount ¶
func (*Course) UpdateWatchCount ¶
type CourseChapter ¶
type CourseChapter struct { field.DefaultField `bson:",inline" json:",inline"` CourseId primitive.ObjectID `json:"cid" bson:"cid" binding:"required"` Title string `json:"title" bson:"title" binding:"required"` Previewable *bool `json:"previewable" bson:"previewable" binding:"required"` Videos []VideoMetadata `json:"videos" bson:"-" binding:"-"` }
func FindAllChapterByCourseId ¶
func FindAllChapterByCourseId(cid primitive.ObjectID) ([]CourseChapter, error)
func (*CourseChapter) AfterRemove ¶
func (cc *CourseChapter) AfterRemove() error
func (*CourseChapter) Remove ¶
func (cc *CourseChapter) Remove() error
func (*CourseChapter) Save ¶
func (cc *CourseChapter) Save() error
type DisplayableReview ¶
type FullCourse ¶
type FullCourse struct { Id string `json:"id"` Title string `json:"title"` CategoryId string `json:"cid"` Category string `json:"category"` LecturerId string `json:"lid"` Lecturer string `json:"lecturer"` LecturerEmail string `json:"lecturer_email"` ReviewScore float32 `json:"review_score"` Ava string `json:"ava"` Fee float64 `json:"fee" bson:"fee"` Discount float64 `json:"discount" bson:"discount"` ShortDesc string `json:"short_desc" bson:"short_desc"` FullDesc string `json:"full_desc" bson:"full_desc"` IsDone bool `json:"is_done"` Chapters []CourseChapter `json:"chapters"` ReviewCount int64 `json:"review_count"` Disabled bool `json:"disabled"` }
func GetAllCourseAsFull ¶
func GetAllCourseAsFull() ([]FullCourse, error)
type Review ¶
type Review struct { field.DefaultField `bson:",inline"` UserId primitive.ObjectID `json:"uid" bson:"uid"` CourseId primitive.ObjectID `json:"cid" bson:"cid"` Content string `json:"content" bson:"content"` Score float32 `json:"score" bson:"score"` }
func (*Review) ConvertToDisplayableReview ¶
func (rv *Review) ConvertToDisplayableReview() (*DisplayableReview, error)
func (*Review) FindByUidAndCid ¶
type SimpleCourse ¶
type SimpleCourse struct { Id string `json:"id"` Title string `json:"title"` CategoryId string `json:"cid"` Category string `json:"category"` LecturerId string `json:"lid"` Lecturer string `json:"lecturer"` ReviewScore float32 `json:"review_score"` Ava string `json:"ava"` CurrentPrice float64 `json:"current_price"` IsDiscount bool `json:"is_discount"` IsDone bool `json:"is_done"` ReviewCount int64 `json:"review_count"` }
func GetAllCourseAsSimple ¶
func GetAllCourseAsSimple() ([]SimpleCourse, error)
func GetAllCourseByCatIdAsSimple ¶
func GetAllCourseByCatIdAsSimple(catId primitive.ObjectID) ([]SimpleCourse, error)
func GetAllCourseBySubcatIdAsSimple ¶
func GetAllCourseBySubcatIdAsSimple(subcatId primitive.ObjectID) ([]SimpleCourse, error)
func GetTop10MostWatchCourse ¶
func GetTop10MostWatchCourse() ([]SimpleCourse, error)
func GetTop10NewestCourse ¶
func GetTop10NewestCourse() ([]SimpleCourse, error)
func GetTop4HighlightCourse ¶
func GetTop4HighlightCourse() ([]SimpleCourse, error)
type SubCategory ¶
type SubCategory struct { field.DefaultField `bson:",inline" json:",inline"` Name string `json:"name" bson:"name"` ParentCategoryId primitive.ObjectID `json:"parentCategoryId" bson:"parentCategoryId"` }
func CreateSubCategory ¶
func CreateSubCategory(name string, catName string) (*SubCategory, error)
func FindByParentCategoryId ¶
func FindByParentCategoryId(ParentCatId primitive.ObjectID) ([]SubCategory, error)
func FindSubcatsByCatName ¶
func FindSubcatsByCatName(name string) ([]SubCategory, error)
func GetAllMostRegisterCategory ¶
func GetAllMostRegisterCategory() ([]SubCategory, error)
func (*SubCategory) FindByName ¶
func (subcat *SubCategory) FindByName(name string) error
func (*SubCategory) FindSubCategoryById ¶
func (subcat *SubCategory) FindSubCategoryById(oid primitive.ObjectID) error
func (*SubCategory) Remove ¶
func (subcat *SubCategory) Remove() error
func (*SubCategory) Save ¶
func (subcat *SubCategory) Save() error
func (*SubCategory) UpdateName ¶
func (subcat *SubCategory) UpdateName(name string) error
type TimeMark ¶
type TimeMark struct { field.DefaultField `bson:",inline"` UserId primitive.ObjectID `json:"uid" bson:"uid"` VideoId primitive.ObjectID `json:"vid" bson:"vid"` CurTime int64 `json:"cur_time" bson:"cur_time"` }
func (*TimeMark) UpdateTimeMark ¶
type User ¶
type User struct { field.DefaultField `json:",inline" bson:",inline"` Fullname string `json:"fullname" bson:"fullname" binding:"required"` Username string `json:"username" bson:"username" binding:"required"` Email string `json:"email" bson:"email" binding:"required"` HPassword string `json:"pass" bson:"hpass" binding:"required"` CurOtp string `json:"-" bson:"otp"` LastOtpUpdated time.Time `json:"-" bson:"last_otp_updated"` CurOtpExpiredTime time.Time `json:"-" bson:"otp_exp"` RecoverCode string `json:"-" bson:"recover"` RecoverCodeExpiredTime time.Time `json:"-" bson:"rec_exp"` RefreshToken string `json:"-" bson:"rf"` IsLec bool `json:"isLec" bson:"is_lec"` IsBanned bool `json:"is_banned" bson:"is_banned"` }
func (*User) AfterInsert ¶
func (*User) ConfirmResetPassword ¶
func (*User) FindByEmail ¶
func (*User) FindByIdAndRfToken ¶
func (*User) FindByUsername ¶
func (*User) GenerateOtp ¶
func (*User) GenerateRecoverCode ¶
func (*User) GenerateRfToken ¶
func (*User) UpdateLecturerStatus ¶
func (*User) UpdatePassword ¶
func (*User) UpdateProfile ¶
type VideoMetadata ¶
type VideoMetadata struct { field.DefaultField `bson:",inline" json:",inline"` ChapterId primitive.ObjectID `json:"chap_id" bson:"chap_id"` CourseId primitive.ObjectID `json:"cid" bson:"cid"` Title string `json:"title" bson:"title"` }
func FindAllVideoMetadataByChapterId ¶
func FindAllVideoMetadataByChapterId(ccid primitive.ObjectID) ([]VideoMetadata, error)
func (*VideoMetadata) Remove ¶
func (vm *VideoMetadata) Remove() error
func (*VideoMetadata) Save ¶
func (vm *VideoMetadata) Save() error
func (*VideoMetadata) UpdateVideoTitle ¶
func (vm *VideoMetadata) UpdateVideoTitle(title string) error
type WatchList ¶
type WatchList struct { field.DefaultField `bson:",inline"` UserId primitive.ObjectID `json:"uid" bson:"uid"` CoursesId []primitive.ObjectID `json:"cids" bson:"cids"` }
func (*WatchList) AddCourseToWatchList ¶
func (*WatchList) RemoveCourseFromWatchList ¶
type XSimpleCourse ¶
type XSimpleCourse struct { CourseId primitive.ObjectID `json:"cid"` CourseName string `json:"course_name"` }
func GetRegByUid ¶
func GetRegByUid(uid primitive.ObjectID) ([]XSimpleCourse, error)
Click to show internal directories.
Click to hide internal directories.