server

package
v0.0.0-...-d4218d0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2021 License: GPL-3.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WeekView  = "week"
	MonthView = "month"
	YearView  = "year"
	AllView   = "all"
)
View Source
const (
	ChapterImage = "chapter-image"
	UserAvatar   = "user-avatar"
	AuthorAvatar = "author-avatar"
	GenreImage   = "genre-image"
	CoverArt     = "cover-art"
)
View Source
const (
	Like    = "like"
	DisLike = "dislike"
	Unlike  = "unlike"
)
View Source
const (
	MemberRole    = "member"
	ModeratorRole = "moderator"
	BannedRole    = "banned"
)
View Source
const (
	BookGroupModule   = "book"
	BookChapterModule = "chapter"
	CommentModule     = "comment"
	AuthorModule      = "author"
	LikeModule        = "like"
	PostAction        = "post"
	ReadAction        = "read"
	ModifyAction      = "modify"
	DeleteAction      = "delete"
	ModifySelfAction  = "modifySelf"
	DeleteSelfAction  = "deleteSelf"
)
View Source
const LimitUserBookGroups = 20
View Source
const MaxSize = 1024 * 1024 * 10
View Source
const RoleNameClaimKey = "rol"
View Source
const RolePermsClaimKey = "rolp"
View Source
const RootFolder = "static/images"
View Source
const UserIdClaimKey = "uid"

Variables

This section is empty.

Functions

func AuthMiddleware

func AuthMiddleware() *jwt.GinJWTMiddleware

AuthMiddleware is a jwt auth(enticator/orizator)

func AuthorsByBookGroup

func AuthorsByBookGroup(bookGroupId, page int32) ([]int32, error)

func BookAuthorById

func BookAuthorById(id int32) (*db.BookAuthorByIdRow, error)

func BookAuthors

func BookAuthors(page int32) ([]*db.BookAuthorsRow, error)

func BookChapterById

func BookChapterById(id int32) (*db.BookChapter, error)

func BookChaptersByBookGroupId

func BookChaptersByBookGroupId(bookGroupID, page int32) ([]*db.BookChapter, error)

func BookGroupAuthor

func BookGroupAuthor(bookGroupId, bookAuthorId int32) (bool, error)

func BookGroupById

func BookGroupById(id int32) (*db.BookGroupByIdRow, error)

func BookGroupGenre

func BookGroupGenre(bookGroupId, genreId int32) (bool, error)

func BookGroupsByGenre

func BookGroupsByGenre(genreId, page int32) (*[]db.BookGroupsByGenreRow, error)

func BookGroupsByTitle

func BookGroupsByTitle(title string, page int32) ([]*db.BookGroupsByTitleRow, error)

func ChangeCurrentUserInfoHandler

func ChangeCurrentUserInfoHandler(c *gin.Context)

func ChangeCurrentUserPasswordHandler

func ChangeCurrentUserPasswordHandler(c *gin.Context)

func CheckAuthorExistById

func CheckAuthorExistById(id int32) (bool, error)

func CheckEmptyString

func CheckEmptyString(content string) bool

func CheckGenreExistById

func CheckGenreExistById(id int32) (bool, error)

func CheckImageExistById

func CheckImageExistById(id int32) (bool, error)

func Clamp

func Clamp(input, min, max int32) int32

func CleanImages

func CleanImages() error

func CleanSearchString

func CleanSearchString(search string) string

func CommentsByBookChapter

func CommentsByBookChapter(bookChapterId int32, page int)

func CommentsByBookGroup

func CommentsByBookGroup(bookGroupId int32, page int)

func CompleteOauthAccountHandler

func CompleteOauthAccountHandler(c *gin.Context)

func CompleteOauthRegistration

func CompleteOauthRegistration(userId int32, name string, avatarId *int32, roleId int32) error

func CountCommentInBookGroup

func CountCommentInBookGroup(bookGroupId int32) (int32, error)

func CountLikesInBookGroup

func CountLikesInBookGroup(bookGroupId int32) (int64, error)

func CreateAuthorHandler

func CreateAuthorHandler(c *gin.Context)

func CreateBookAuthor

func CreateBookAuthor(name, description string, imageID int32, alias interface{}) (*db.BookAuthor, error)

func CreateBookChapter

func CreateBookChapter(chapterNumber float64, description, textContext, chapterType string,
	bookGroupID, ownerID int32) (*db.BookChapter, error)

func CreateBookGroup

func CreateBookGroup(input *InputBookGroup) (*db.InsertBookGroupRow, error)

func CreateBookGroupArt

func CreateBookGroupArt(bookGroupId, imageId int32) (*db.BookGroupArt, error)

func CreateBookGroupAuthor

func CreateBookGroupAuthor(bookGroupId, bookAuthorId int32) (*db.BookGroupAuthor, error)

func CreateBookGroupGenre

func CreateBookGroupGenre(bookGroupId, genreId int32) (*db.BookGroupGenre, error)

func CreateBookGroupHandler

func CreateBookGroupHandler(c *gin.Context)

func CreateCommentHandler

func CreateCommentHandler(c *gin.Context)

func CreateGenre

func CreateGenre(name, description string, imageID int32) (*db.Genre, error)

func CreateHypertextChapterHandler

func CreateHypertextChapterHandler(c *gin.Context)

func CreateImage

func CreateImage(width int, height int) (*os.File, int64, string, string, error)

func CreateImagesChapterHandler

func CreateImagesChapterHandler(c *gin.Context)

func DeleteAccount

func DeleteAccount(username string) error

func DeleteAuthorHandler

func DeleteAuthorHandler(c *gin.Context)

func DeleteAuthorsByBookGroup

func DeleteAuthorsByBookGroup(bookGroupId int32) error

func DeleteBookAuthor

func DeleteBookAuthor(id int32) error

func DeleteBookChapterByBookGroupId

func DeleteBookChapterByBookGroupId(bookGroupId int32) error

func DeleteBookChapterHandler

func DeleteBookChapterHandler(c *gin.Context)

func DeleteBookGroup

func DeleteBookGroup(id int32) error

func DeleteBookGroupAuthor

func DeleteBookGroupAuthor(bookGroupId, bookAuthorId int32) error

func DeleteBookGroupGenre

func DeleteBookGroupGenre(bookGroupId, genreId int32) error

func DeleteBookGroupHandler

func DeleteBookGroupHandler(c *gin.Context)

func DeleteBookGroupsByBookAuthor

func DeleteBookGroupsByBookAuthor(genre int32) error

func DeleteBookGroupsByGenre

func DeleteBookGroupsByGenre(genre int32) error

func DeleteCommentHandler

func DeleteCommentHandler(c *gin.Context)

func DeleteCoverOfBookGroup

func DeleteCoverOfBookGroup(bookGroupId int32) error

func DeleteGenre

func DeleteGenre(id int32) error

func DeleteGenresByBookGroup

func DeleteGenresByBookGroup(bookGroupId int32) error

func DislikeBookGroup

func DislikeBookGroup(params UserLikeParams) error

func EditComment

func EditComment(commentId int32, content string) error

func EditCommentHandler

func EditCommentHandler(c *gin.Context)

func EqualPasswords

func EqualPasswords(hashedPassword, password []byte) bool

func GeneratePasswordHash

func GeneratePasswordHash(password string) ([]byte, error)

func GenerateThumbnail

func GenerateThumbnail(path string, size int, filetype *string) (string, error)

func GenreById

func GenreById(id int32) (*db.Genre, error)

func GenresByBookGroup

func GenresByBookGroup(bookGroupId, page int32) ([]int32, error)

func GetAuthorInfoHandler

func GetAuthorInfoHandler(c *gin.Context)

func GetBookByGenreHandler

func GetBookByGenreHandler(c *gin.Context)

func GetBookChapterContentHandler

func GetBookChapterContentHandler(c *gin.Context)

func GetBookGroupContentHandler

func GetBookGroupContentHandler(c *gin.Context)

func GetBookGroupsByViewHandler

func GetBookGroupsByViewHandler(c *gin.Context)

func GetCommentsHandler

func GetCommentsHandler(c *gin.Context)

func GetImageResolution

func GetImageResolution(filestream multipart.File) (int, int, error)

func GetLatestBookGroupsHandler

func GetLatestBookGroupsHandler(c *gin.Context)

func GetLatestCommentsHandler

func GetLatestCommentsHandler(c *gin.Context)

func GetRandomBookGroups

func GetRandomBookGroups(c *gin.Context)

func GetRoleHandler

func GetRoleHandler(c *gin.Context)

func GetSearchResultHandler

func GetSearchResultHandler(c *gin.Context)

func GetSearchSuggestionHandler

func GetSearchSuggestionHandler(c *gin.Context)

func GetUserInfoByIdHandler

func GetUserInfoByIdHandler(c *gin.Context)

func GetViewInBookGroup

func GetViewInBookGroup(bookGroupId int32) (int64, error)

func GoogleOauthRedirect

func GoogleOauthRedirect(c *gin.Context)

func HasControlCharacters

func HasControlCharacters(content string) bool

func ImagesByBookChapter

func ImagesByBookChapter(bookChapterId int32) (*[]db.ImagesByBookChapterRow, error)

func InitOauth

func InitOauth()

func InsertComment

func InsertComment(params CommentParams) error

func InsertView

func InsertView(chapterId int32) error

func LikeBookGroup

func LikeBookGroup(params UserLikeParams) error

func LikeOperationHandler

func LikeOperationHandler(c *gin.Context)

func ListAllGenresHandler

func ListAllGenresHandler(c *gin.Context)

func NumberBookGroupInGenre

func NumberBookGroupInGenre(genreId int32) (int32, error)

func RegisterAccount

func RegisterAccount(username, password, email string) (*db.User, *db.RoleRow, error)

func RegisterOauthAccount

func RegisterOauthAccount(email string) (*db.User, *db.RoleRow, error)

func RegisterPasswordHandler

func RegisterPasswordHandler(c *gin.Context)

func RemoveComment

func RemoveComment(commentId int32) error

func ReportError

func ReportError(c *gin.Context, err error, message string, code int)

func ResizeImage

func ResizeImage(fileStream multipart.File, params ResizeImageParams) error

func Run

func Run()

func SaveImageFromStream

func SaveImageFromStream(filestream multipart.File, location string, fileNameNoExt string, description string) (int32, string, error)

func SaveImageFromUrl

func SaveImageFromUrl(fileUrl string, location string, fileNameNoExt string, description string) (int32, error)

func SearchAuthorHandler

func SearchAuthorHandler(c *gin.Context)

func SearchUserHandler

func SearchUserHandler(c *gin.Context)

func SetRole

func SetRole(adminId int32, userId int32, role string) error

func SetRoleHandler

func SetRoleHandler(c *gin.Context)

func SubmitImages

func SubmitImages(submitImages []int32) error

func TryOutsideTest

func TryOutsideTest()

func UnlikeBookGroup

func UnlikeBookGroup(params UserLikeParams) error

func UpdateAuthorHandler

func UpdateAuthorHandler(c *gin.Context)

func UpdateBookAuthor

func UpdateBookAuthor(id int32, name, description string, imageID int32, alias interface{}) error

func UpdateBookChapter

func UpdateBookChapter(chapter UpdateChapterParams) error

func UpdateBookGroup

func UpdateBookGroup(id int32, input *InputBookGroup) error

func UpdateBookGroupHandler

func UpdateBookGroupHandler(c *gin.Context)

func UpdateGenre

func UpdateGenre(id int32, name, description string, imageID int32) error

func UpdateHypertextChapter

func UpdateHypertextChapter(c *gin.Context)

func UpdateImagesChapterHandler

func UpdateImagesChapterHandler(c *gin.Context)

func UploadImageHandler

func UploadImageHandler(c *gin.Context)

func UserByGoogleOauthCode

func UserByGoogleOauthCode(code string) (*db.User, *db.RoleRow, error)

func UserByLoginInfo

func UserByLoginInfo(loginInfo PasswordLogin) (*db.User, *db.RoleRow, error)

func UserByOauthToken

func UserByOauthToken(login OauthLogin) (*db.User, *db.RoleRow, error)

func ValidAuthors

func ValidAuthors(authorIds *[]int32)

func ValidCoverArt

func ValidCoverArt(coverArtIds *[]int32)

func ValidDescription

func ValidDescription(description *string) error

func ValidGenres

func ValidGenres(genreIds *[]int32)

func ValidPassword

func ValidPassword(password string) bool

func ValidPrimaryCoverArtId

func ValidPrimaryCoverArtId(PrimaryCoverArtId *int32, coverArtIds *[]int32)

func ValidTitle

func ValidTitle(title *string) error

func ValidUsername

func ValidUsername(username string) bool

Types

type Author

type Author struct {
	Name  string      `json:"name" binding:"required"`
	Alias interface{} `json:"alias"`
	Id    int32       `json:"id" binding:"required"`
	Image interface{} `json:"image"`
}

type BookByGenreHandler

type BookByGenreHandler struct {
	Id            int32       `json:"id"`
	Image         interface{} `json:"image"`
	Title         string      `json:"title"`
	LatestChapter interface{} `json:"latestChapter"`
	Comments      int32       `json:"comments"`
	Views         int64       `json:"views"`
	Likes         int64       `json:"likes"`
}

type BookByUser

type BookByUser struct {
	Id            int32       `json:"id"`
	Image         interface{} `json:"image"`
	Title         string      `json:"title"`
	LatestChapter interface{} `json:"latestChapter"`
	Comments      int64       `json:"comments"`
	Views         int64       `json:"views"`
	Likes         int64       `json:"likes"`
	LastUpdated   interface{} `json:"lastUpdated"`
}

type BookGroup

type BookGroup struct {
	Name              string      `json:"name"`
	Alias             interface{} `json:"alias"`
	Description       interface{} `json:"description"`
	Views             int64       `json:"views"`
	LikeCount         int64       `json:"likeCount"`
	DislikeCount      int64       `json:"dislikeCount"`
	OwnerId           int32       `json:"ownerId"`
	Authors           []Author    `json:"authors"`
	Genres            []Genre     `json:"genres"`
	Chapters          []Chapter   `json:"chapters"`
	CoverArts         []Image     `json:"coverArts"`
	PrimaryCoverArt   interface{} `json:"primaryCoverArt"`
	PrimaryCoverArtId interface{} `json:"primaryCoverArtId"`
}

type ChangePassword

type ChangePassword struct {
	OldPassword string `json:"oldPassword" binding:"required"`
	NewPassword string `json:"newPassword" binding:"required"`
}

type ChangeUserInfo

type ChangeUserInfo struct {
	Email       interface{} `json:"email"`
	Username    interface{} `json:"username"`
	Description interface{} `json:"description"`
	Avatar      interface{} `json:"avatar"`
}

type Chapter

type Chapter struct {
	ChapterNumber float64     `json:"chapterNumber"`
	Name          interface{} `json:"name"`
	Id            int32       `json:"id" binding:"required"`
	TimePosted    int64       `json:"timePosted" binding:"required"`
	UserPosted    Author      `json:"userPosted" binding:"required"`
	Views         int64       `json:"views"`
}

type Comment

type Comment struct {
	CommentId     int32       `json:"commentId" binding:"required"`
	Comment       string      `json:"comment" binding:"required"`
	UserName      string      `json:"userName" binding:"required"`
	UserId        int32       `json:"userId" binding:"required"`
	UserAvatar    interface{} `json:"userAvatar" binding:"required"`
	TimePosted    int64       `json:"timePosted" binding:"required"`
	ChapterId     interface{} `json:"chapterId"`
	ChapterNumber interface{} `json:"chapterNumber"`
}

type CommentPage

type CommentPage struct {
	LastPage int32     `json:"lastPage"`
	Comments []Comment `json:"comments"`
}

type CommentParams

type CommentParams struct {
	UserId    int32
	BookId    int32
	ChapterId *int32
	Content   string
}

type CompleteOauth

type CompleteOauth struct {
	Username string      `json:"username" binding:"required" form:"username"`
	Avatar   interface{} `json:"avatar" form:"avatar"`
}

type CreateAuthor

type CreateAuthor struct {
	Name        string      `json:"name" form:"name" binding:"required"`
	Alias       interface{} `json:"alias"`
	Description string      `json:"description" form:"description"`
	AvatarId    int32       `json:"avatarId" form:"avatarId"`
}

type Genre

type Genre struct {
	Id   int32  `json:"id" binding:"required"`
	Name string `json:"name" binding:"required"`
}

type HypertextChapter

type HypertextChapter struct {
	ChapterNumber interface{} `json:"chapterNumber"`
	Name          interface{} `json:"name"`
	TextContent   string      `json:"textContent" binding:"required"`
	BookGroupId   int32       `json:"bookGroupId" binding:"required"`
}

type Image

type Image struct {
	Path string `json:"path"`
	Id   int32  `json:"id"`
}

type ImageChapter

type ImageChapter struct {
	ChapterNumber interface{} `json:"chapterNumber"`
	Name          interface{} `json:"name"`
	Images        []int32     `json:"images" binding:"required"`
	BookGroupId   int32       `json:"bookGroupId" binding:"required"`
}

type InputBookGroup

type InputBookGroup struct {
	Title             string      `json:"name" form:"name"`
	Alias             interface{} `json:"alias"`
	Description       string      `json:"description" form:"description"`
	AuthorIds         []int32     `json:"authors" form:"authors"`
	GenreIds          []int32     `json:"genres" form:"genres"`
	CoverArtIds       []int32     `json:"coverArts" form:"coverArts"`
	PrimaryCoverArtId int32       `json:"primaryCoverArt" form:"primaryCoverArt"`
	OwnerId           int32       `json:"owner" form:"owner"`
}

type InsertViewParams

type InsertViewParams struct {
	ChapterId int32
	ViewDate  time.Time
}

type LatestComment

type LatestComment struct {
	CommentId     int32       `json:"commentId" binding:"required"`
	Comment       string      `json:"comment" binding:"required"`
	UserName      string      `json:"userName" binding:"required"`
	UserId        int32       `json:"userId" binding:"required"`
	UserAvatar    interface{} `json:"userAvatar" binding:"required"`
	TimePosted    int64       `json:"timePosted" binding:"required"`
	ChapterId     interface{} `json:"chapterId"`
	ChapterName   interface{} `json:"chapterName"`
	ChapterNumber interface{} `json:"chapterNumber"`
	BookId        int32       `json:"bookId" binding:"required"`
	BookName      string      `json:"bookName" binding:"required"`
}

type OauthLogin

type OauthLogin struct {
	Provider string `form:"provider" json:"provider" binding:"required"`
	Code     string `form:"code" json:"code" binding:"required"`
}

type PasswordLogin

type PasswordLogin struct {
	UsernameOrEmail string `form:"usernameOrEmail" json:"usernameOrEmail" binding:"required"`
	Password        string `form:"password" json:"password" binding:"required"`
}

type PostComment

type PostComment struct {
	Comment string `json:"comment" binding:"required"`
}

type Register

type Register struct {
	Username string `json:"username" form:"username" binding:"required"`
	Password string `json:"password" form:"password" binding:"required"`
	Email    string `json:"email" form:"email" binding:"required"`
}

type ResizeImageParams

type ResizeImageParams struct {
	InType  string `json:"in_type"`
	OutType string `json:"out_type"`
	OutDst  string `json:"out_dst"`
	Width   int    `json:"width"`
	Height  int    `json:"height"`
}

type SetRoleInput

type SetRoleInput struct {
	UserId int32  `json:"userId"`
	Role   string `json:"role"`
}

type UpdateAuthor

type UpdateAuthor struct {
	Name        string      `json:"name" form:"name"`
	Alias       interface{} `json:"alias"`
	Description string      `json:"description" form:"description"`
	AvatarId    int32       `json:"avatar" form:"avatar"`
}

type UpdateChapterParams

type UpdateChapterParams struct {
	Id            int32       `json:"id"`
	ChapterNumber float64     `json:"chapterNumber"`
	Name          interface{} `json:"name"`
	TextContent   string      `json:"textContent"`
	Images        []int32     `json:"images"`
}

type User

type User struct {
	Name  string      `json:"name" binding:"required"`
	Id    int32       `json:"id" binding:"required"`
	Image interface{} `json:"image"`
}

type UserClaims

type UserClaims struct {
	UserId          int32
	RoleName        string
	RolePermissions []string
}

type UserInfo

type UserInfo struct {
	Role       string      `json:"role" binding:"required"`
	Permission []string    `json:"permission" binding:"required"`
	Id         int32       `json:"id" binding:"required"`
	Name       interface{} `json:"name"`
	Avatar     interface{} `json:"avatar"`
	Email      string      `json:"email" binding:"required"`
}

type UserLikeParams

type UserLikeParams struct {
	UserId int32
	BookId int32
}

type UserProfile

type UserProfile struct {
	Name        string       `json:"name"`
	Role        string       `json:"role"`
	Avatar      interface{}  `json:"avatar"`
	AvatarId    interface{}  `json:"avatarId"`
	Description interface{}  `json:"description"`
	BookPosted  []BookByUser `json:"bookPosted"`
}

Jump to

Keyboard shortcuts

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