database

package
v1.0.0-alpha Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const Source string = "./fl.db"

Variables

View Source
var DB *sql.DB

Functions

func AddContent

func AddContent(ctx context.Context, course, lesson, index int) error

func AddCourse

func AddCourse(ctx context.Context, course *Course) error

func AddLesson

func AddLesson(ctx context.Context, lesson *Lesson) error

func AddUser

func AddUser(ctx context.Context, user *User) error

func BuyLesson

func BuyLesson(ctx context.Context, user, lesson int) error

func CountFollowers

func CountFollowers(ctx context.Context, course int) (int, error)

func DelContent

func DelContent(ctx context.Context, course, lesson int) error

func DelCourse

func DelCourse(ctx context.Context, id int) error

func DelLesson

func DelLesson(ctx context.Context, id int) error

func DelUser

func DelUser(ctx context.Context, id int) error

func Follow

func Follow(ctx context.Context, user, course int) error

func GenMime

func GenMime(ctx context.Context, total, count int) error

func GetCoursesPageTotal

func GetCoursesPageTotal(ctx context.Context, size int, category string) (int, error)

func GetCoursesTotal

func GetCoursesTotal(ctx context.Context, category string) (int, error)

func GetLessonsPageTotal

func GetLessonsPageTotal(ctx context.Context, size int, owner int) (int, error)

func GetLessonsTotal

func GetLessonsTotal(ctx context.Context, owner int) (int, error)

func GetMaxIndex

func GetMaxIndex(ctx context.Context, course int) (int, error)

func GetMimes

func GetMimes(ctx context.Context, total, count int) ([]string, error)

func GetUsersPageTotal

func GetUsersPageTotal(ctx context.Context, size int) (int, error)

func GetUsersTotal

func GetUsersTotal(ctx context.Context) (int, error)

func HashString

func HashString(text string) string

func IsBought

func IsBought(ctx context.Context, user, lesson int) (bool, error)

func IsExistContent

func IsExistContent(ctx context.Context, course, lesson int) (bool, error)

func IsFollowed

func IsFollowed(ctx context.Context, user, course int) (bool, error)

func Mining

func Mining(ctx context.Context, user int, code string) (int, error)

func SetCourse

func SetCourse(ctx context.Context, course *Course) error

func SetLesson

func SetLesson(ctx context.Context, lesson *Lesson) error

func SetUser

func SetUser(ctx context.Context, user *User) error

func SetUserTicket

func SetUserTicket(ctx context.Context, user *User) error

func UnFollow

func UnFollow(ctx context.Context, user, course int) error

func ValidEmail

func ValidEmail(ctx context.Context, email string) bool

func ValidPassword

func ValidPassword(ctx context.Context, email, password string) int

Types

type Course

type Course struct {
	Id           int
	Time         int64
	Title        string
	Introduction string
	Keywords     string
	Image        string
	Category     string
	Owner        int
	Total        int
	Level        int
}

CREATE TABLE "course" (

"id"	INTEGER NOT NULL,
"time"	INTEGER NOT NULL,
"title"	TEXT NOT NULL,
"introduction"	TEXT NOT NULL,
"keywords"	TEXT NOT NULL,
"image"	TEXT NOT NULL,
"category"	TEXT NOT NULL,
"total"	INTEGER NOT NULL DEFAULT 0,
"owner"	INTEGER NOT NULL,
"level"	INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY("id")

);

func GetCourseById

func GetCourseById(ctx context.Context, id int) (*Course, error)

func GetLikes

func GetLikes(ctx context.Context, user int) ([]*Course, error)

type CourseSummary

type CourseSummary struct {
	Id           int
	Time         int64
	Title        string
	Introduction string
	Image        string
	Level        int
}

func GetCourses

func GetCourses(
	ctx context.Context,
	limit int, offset int, where string,
	args ...interface{}) ([]*CourseSummary, error)

func GetCoursesByPage

func GetCoursesByPage(
	ctx context.Context,
	page int, size int, category string) ([]*CourseSummary, error)

type Lesson

type Lesson struct {
	Id           int
	Time         int64
	Title        string
	Introduction string
	Keywords     string
	Image        string
	Source       string
	Type         int
	Owner        int
	Ticket       int
	Level        int
}

CREATE TABLE "lesson" (

"id"	INTEGER NOT NULL,
"time"	INTEGER NOT NULL,
"title"	TEXT NOT NULL,
"introduction"	TEXT NOT NULL,
"keywords"	TEXT NOT NULL,
"image"	TEXT NOT NULL,
"source"	TEXT NOT NULL,
"type"	INTEGER NOT NULL DEFAULT 0,
"owner"	INTEGER NOT NULL,
"level"	INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY("id")

);

func GetBoughts

func GetBoughts(ctx context.Context, user int) ([]*Lesson, error)

func GetContents

func GetContents(ctx context.Context, course int) ([]*Lesson, error)

func GetLessonById

func GetLessonById(ctx context.Context, id int) (*Lesson, error)

type LessonSummary

type LessonSummary struct {
	Id           int
	Time         int64
	Title        string
	Introduction string
	Image        string
	Ticket       int
	Level        int
}

func GetLessons

func GetLessons(
	ctx context.Context,
	limit int, offset int, where string,
	args ...interface{}) ([]*LessonSummary, error)

func GetLessonsByPage

func GetLessonsByPage(
	ctx context.Context,
	page int, size int, owner int) ([]*LessonSummary, error)

type User

type User struct {
	Id           int
	Username     string
	Password     string
	Email        string
	Introduction string
	Image        string
	Ticket       int
	Time         int64
	Level        int
}

CREATE TABLE "user" (

	"id"	INTEGER NOT NULL,
	"username"	TEXT NOT NULL,
	"password"	TEXT NOT NULL,
	"email"	TEXT NOT NULL,
	"introduction"	TEXT,
	"image"	TEXT,
    "time" INTEGER NOT NULL,
	"level"	INTEGER NOT NULL DEFAULT 0,
	PRIMARY KEY("id")

);

func GetUserById

func GetUserById(ctx context.Context, id int) (*User, error)

type UserSummary

type UserSummary struct {
	Id           int
	Username     string
	Email        string
	Introduction string
	Image        string
	Ticket       int
	Time         int64
	Level        int
}

func GetUsers

func GetUsers(
	ctx context.Context,
	limit int, offset int, where string,
	args ...interface{}) ([]*UserSummary, error)

func GetUsersByPage

func GetUsersByPage(ctx context.Context, page int, size int) ([]*UserSummary, error)

Jump to

Keyboard shortcuts

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