models

package
v0.0.0-...-cc686c7 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2019 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateArticle

func CreateArticle(article Article) int

func CreateComment

func CreateComment(comment *Comment) int

func CreateTag

func CreateTag(tag string)

func CreateUser

func CreateUser(user User) int

func Follow

func Follow(userid int, followerid int) bool

func Unfollow

func Unfollow(userid int, followerid int) bool

func UpdateArticleByID

func UpdateArticleByID(article Article) bool

func UpdateCommentByID

func UpdateCommentByID(comment Comment) bool

func UpdateUserByID

func UpdateUserByID(id int, user User) bool

func UpdateUserIconByID

func UpdateUserIconByID(id int, iconPath string) bool

Types

type Article

type Article struct {
	ID        int       `json:"id, omitempty"`
	Author    int       `json:"author_id"`
	Title     string    `json:"title"`
	Tags      []Tag     `json:"tags"`
	Content   string    `json:"content"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type ArticleList

type ArticleList struct {
	ID        int           `json:"id"`
	Author    UserList      `json:"author"`
	AuthorId  int           `json:"author_id"`
	Content   string        `json:"content"`
	Comments  []CommentList `json:"comments"`
	Title     string        `json:"title"`
	Tags      []Tag         `json:"tags"`
	UpdatedAt time.Time     `json:"updated_at"`
}

func GetAllArticles

func GetAllArticles() []ArticleList

func GetArticleByID

func GetArticleByID(id int) *ArticleList

func GetArticleByUserID

func GetArticleByUserID(id int) []ArticleList

func GetArticlesByTag

func GetArticlesByTag(tag string) []ArticleList

type ArticlePage

type ArticlePage struct {
	Number   int           `json: "number"`
	Articles []ArticleList `json: "articles"`
}

func GetArticlesPerPage

func GetArticlesPerPage(pageNum int) ArticlePage

type Comment

type Comment struct {
	ID        int       `json:"id"`
	Content   string    `json:"content"`
	CreatedAt time.Time `json:"created_at"`
	ArticleID int       `json:"article_id"`
	CreatorID int       `json:"creator_id"`
}

type CommentList

type CommentList struct {
	ID        int       `json:"id"`
	Content   string    `json:"content"`
	CreatedAt time.Time `json:"created_at"`
	ArticleID int       `json:"article_id"`
	Creator   UserList  `json:"creator"`
	CreatorID int       `json:"creator_id"`
}

func GetAllCommentsByArticleID

func GetAllCommentsByArticleID(articleID int) []CommentList

type Tag

type Tag struct {
	Content string `json: "content"`
}

func GetAllTags

func GetAllTags() []Tag

type User

type User struct {
	UserID    int    `json:"id, omitempty"`
	Username  string `json:"username"`
	Password  string `json:"password"`
	Email     string `json:"email"`
	Followers []int  `json:"followers,[]"`
	Following []int  `json:"following,[]"`
	Iconpath  string `json:"iconpath"`
}

func GetUserByID

func GetUserByID(id int) *User

func GetUserByUsername

func GetUserByUsername(username string) *User

type UserDetail

type UserDetail struct {
	UserID    int           `json:"id"`
	Username  string        `json:"username"`
	Email     string        `json:"email"`
	Followers []int         `json:"followers"`
	Following []int         `json:"following"`
	Articles  []ArticleList `json:"articles"`
	Iconpath  string        `json:"iconpath"`
}

func GetUserDetailByID

func GetUserDetailByID(id int) *UserDetail

type UserList

type UserList struct {
	UserID    int    `json:"id"`
	Username  string `json:"username"`
	Email     string `json:"email"`
	Followers []int  `json:"followers"`
	Following []int  `json:"following"`
	Iconpath  string `json:"iconpath"`
}

func GetUserFollowers

func GetUserFollowers(id int) []UserList

func GetUserFollowing

func GetUserFollowing(id int) []UserList

func GetUserListByID

func GetUserListByID(id int) *UserList

Jump to

Keyboard shortcuts

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