models

package
v0.0.0-...-3abd2fa Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *sql.DB

Functions

func AddRoleInForum

func AddRoleInForum(forum_id, user_id int, role string) error

将某用户"添加为"某论坛的"user/owner/admin"

func CreateComment

func CreateComment(comment Comment) (int64, error)

在给定的PostID中创建一个评论Comment

func CreateFile

func CreateFile(file ExtendedFile) (int64, error)

创建文件记录

func CreateForum

func CreateForum(forum Forum) (int64, error)

创建论坛

func CreateHole

func CreateHole(hole Hole) (int64, error)

创建一个匿名帖子(树洞帖子)

func CreatePost

func CreatePost(post Post) (int64, error)

创建一个帖子

func CreateUser

func CreateUser(user User) error

创建用户

func DeleteRoleInForum

func DeleteRoleInForum(forum_id, user_id int) error

将某用户在论坛中删除

func Execute

func Execute(sentence string, args ...interface{}) (int64, error)

插入/删除, 返回最后插入的ID和错误

func FindRoleInForum

func FindRoleInForum(forum_id, user_id int) (string, error)

查找某用户在某论坛中的角色

func GetAllAdminsInForum

func GetAllAdminsInForum(forum_id int) ([]int, error)

func GetCoverURL

func GetCoverURL(forumID int) error

获取论坛封面的url

func GetOneUserLikeListByUserID

func GetOneUserLikeListByUserID(userID int) ([]int, error)

func GetPostNumInForum

func GetPostNumInForum(forum_id int) (int, error)

func GetSubscribeNumInForum

func GetSubscribeNumInForum(forum_id int) (int, error)

func LikeOnePostByUserIDAndPostID

func LikeOnePostByUserIDAndPostID(userID int, postID int) error

func QueryRows

func QueryRows(sentence string, args ...interface{}) ([]map[string]string, error)

查询

func UpdateCover

func UpdateCover(path string, forumID int) error

往论坛写入封面的url

func UpdateRoleInForum

func UpdateRoleInForum(forum_id, user_id int, role string) error

将某用户在某论坛的角色修改为role

func UpdateUserAvatarByUserId

func UpdateUserAvatarByUserId(userID int, avatar_path string) error

Types

type Comment

type Comment struct {
	CommentID int    `json:"comment_id"`
	PostID    int    `json:"post_id"`
	UserID    int    `json:"user_id"`
	UserName  string `json:"username"`
	Content   string `json:"content"`
	CreateAt  string `json:"create_at"`
}

func GetAllCommentsByPostID

func GetAllCommentsByPostID(post_id int) ([]Comment, error)

获取给定的 PostID 下的全部 comments

func GetOneCommentByCommentID

func GetOneCommentByCommentID(comment_id int) ([]Comment, error)

根据id获取某个 Comment

type CommentDetail

type CommentDetail struct {
	Comment
}

type ExtendedFile

type ExtendedFile struct {
	FileID   int    `json:"file_id"`
	PostID   int    `json:post_id`
	FileName string `json:"filename"`
	Bucket   string `json:"bucket"`
	CreateAt string `json:"create_at"`
}

在数据库中存放的 File 类型的定义

func GetFilesByPostID

func GetFilesByPostID(post_id int) ([]ExtendedFile, error)

根据 post_id 获取其相关的 files

type Forum

type Forum struct {
	ForumID      int    `json:"forum_id"`
	ForumName    string `json:"forum_name"`
	IsPublic     bool   `json:"is_public"`
	Description  string `json:"description"`
	CreateAt     string `json:"create_at"`
	Cover        string `json:"cover"`
	PostNum      int    `json:"post_num"`
	SubscribeNum int    `json:"subscribe_num"`
	AdminList    []int  `json:"admin_list"`
}

func GetAllPublicForums

func GetAllPublicForums() ([]Forum, error)

获取所有公开论坛,用于未登陆时获取公开论坛

func GetForumByID

func GetForumByID(forum_id int) ([]Forum, error)

根据论坛的 ID 获取论坛信息

type ForumUser

type ForumUser struct {
	User
	Role    string `json:"role"`
	ForumID int    `json:"forum_id"`
}

包含 forum 信息的用户

func GetForumUserByForumID

func GetForumUserByForumID(forum_id int) ([]ForumUser, error)

根据论坛id获取其成员信息/关注者信息

type Hole

type Hole struct {
	HoleID   int    `json:"hole_id"`
	ForumID  int    `json:"forum_id"`
	UserID   int    `json:"user_id"`
	Title    string `json:"title"`
	Content  string `json:"content"`
	CreateAt string `json:"create_at"`
}

func GetAllHolesByForumID

func GetAllHolesByForumID(forum_id int) ([]Hole, error)

获取某个 forum 下的全部 holes

func GetOneHoleByHoleID

func GetOneHoleByHoleID(hole_id int) ([]Hole, error)

根据id获取某个 Hole

type HoleDetail

type HoleDetail struct {
	Hole
}

type Post

type Post struct {
	PostID   int    `json:"post_id"`
	ForumID  int    `json:"forum_id"`
	UserID   int    `json:"user_id"`
	Title    string `json:"title"`
	Content  string `json:"content"`
	CreateAt string `json:"create_at"`
	Like     int    `json:"like"`
	Username string `json:"username"`
}

func GetAllPostsByForumID

func GetAllPostsByForumID(forum_id int) ([]Post, error)

获取某个 forum 下的全部 posts

func GetOnePostByPostID

func GetOnePostByPostID(post_id int) ([]Post, error)

根据id获取某个 Post

type PostDetail

type PostDetail struct {
	Post
	Files []ExtendedFile `json:"files"`
}

type SubscribeList

type SubscribeList struct {
	ParticipateList []int `json:"participate_list"`
	FocusList       []int `json:"star_list"`
}

func GetOneUserSubscribe

func GetOneUserSubscribe(userID int) (SubscribeList, error)

根据用户id获取某个用户信息以及所参与的/关注的列表

type User

type User struct {
	UserId   int    `json:"user_id"`
	Username string `json:"username"`
	Email    string `json:"email"`
	Password string `json:"password"`
	IsAdmin  bool   `json:"is_admin"`
	Avatar   string `json:"avatar"`
	CreateAt string `json:"create_at"`
}

func GetAllUsers

func GetAllUsers() ([]User, error)

func GetAllUsersContains

func GetAllUsersContains(str string) ([]User, error)

func GetUserByEmail

func GetUserByEmail(email string) ([]User, error)

func GetUserById

func GetUserById(user_id int) ([]User, error)

根据用户id获取用户

func GetUserByUsername

func GetUserByUsername(username string) ([]User, error)

根据用户名获取用户

type UserDetail

type UserDetail struct {
	User
	SubscribeList
	LikeList []int `json:"like_list"`
}

Jump to

Keyboard shortcuts

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