service

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: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MinioClient *minio.Client

Functions

func CreateForum

func CreateForum(forumName, description string, isPublic bool) (int64, error)

创建论坛

func CreateUser

func CreateUser(username string, password string, email string) error

func FileDelete

func FileDelete(filename string, bucketName string) error

func FileDownload

func FileDownload(filename string, bucketName string, ext string) (*minio.Object, error)

func FileDownloadByName

func FileDownloadByName(filename string, bucketName string) (*minio.Object, error)

func FileUpload

func FileUpload(file multipart.File, header *multipart.FileHeader, bucketName string, path string, ext string) (filename string, err error)

func GenerateToken

func GenerateToken(user_id int, username string, password string) (string, error)

func GetAllCommentsByPostID

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

根据 post_id 获取全部comment的详情

func GetAllHolesByForumID

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

func GetAllPostDetailsByForumID

func GetAllPostDetailsByForumID(forum_id int) ([]models.PostDetail, error)

func GetAllPostsByForumID

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

func GetDownloadName

func GetDownloadName(path string, ext string) string

同上

func GetFilesByPostID

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

func GetOneCommentDetailByCommentID

func GetOneCommentDetailByCommentID(comment_id int) ([]models.CommentDetail, error)

根据 comment_id 获取一个comment的详情

func GetOneHoleDetailByHoleID

func GetOneHoleDetailByHoleID(hole_id int) ([]models.HoleDetail, error)

根据 hole_id 获取一个hole的详情

func GetOnePostDetailByPostID

func GetOnePostDetailByPostID(post_id int) ([]models.PostDetail, error)

根据 post_id 获取一个post的详情

func GetOneUserDetail

func GetOneUserDetail(userID int) (models.UserDetail, error)

func GetOneUserSubscribe

func GetOneUserSubscribe(userID int) (models.SubscribeList, error)

func GetUploadName

func GetUploadName(path string, ext string) string

传入api路径和文件扩展名,如 getUploadName('/api/users/1/avatar', '.png')

func GetUserFromContext

func GetUserFromContext(c *gin.Context) models.User

从上下文中获取当前用户信息

func IsEmailExist

func IsEmailExist(email string) (bool, error)

func IsUserInForum

func IsUserInForum(user_id int, forum_id int) (bool, error)

查找当前用户是否是论坛成员 如果该论坛是公开的,则直接返回true, 否则查看论坛的成员列表中是否有该用户

func IsUsernameExist

func IsUsernameExist(username string) (bool, error)

func MultipleFilesUpload

func MultipleFilesUpload(files []File, bucketName string, path string, ext string) ([]string, error)

上传多个文件,如果有文件上传出错则回滚之前的文件, 返回成功上传的文件名

func ProduceTokenByEmailAndPassword

func ProduceTokenByEmailAndPassword(email string, password string) (string, error)

func ProduceTokenByUsernameAndPasword

func ProduceTokenByUsernameAndPasword(username string, password string) (string, error)

func VerifyByEmailAndPassword

func VerifyByEmailAndPassword(email string, password string) (bool, error)

func VerifyByUsernameAndPassword

func VerifyByUsernameAndPassword(username string, password string) (bool, error)

Types

type Claims

type Claims struct {
	UserId   int    `json:"user_id"`
	Username string `json:"username"`
	Password string `json:"password"`
	jwt.StandardClaims
}

func ParseToken

func ParseToken(token string) (*Claims, error)

type File

type File struct {
	F multipart.File
	H *multipart.FileHeader
}

Jump to

Keyboard shortcuts

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