Files
novel_server/api/book/v1/book.go

222 lines
9.5 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package v1
import (
"server/internal/model"
"github.com/gogf/gf/v2/net/ghttp"
"github.com/gogf/gf/v2/frame/g"
)
type ListReq struct {
g.Meta `path:"/book" tags:"Backend/Book" method:"get" summary:"获取小说列表"`
Page int `json:"page" dc:"页码"`
Size int `json:"size" dc:"每页数量"`
Title string `json:"title" dc:"书名模糊搜索"`
CategoryId int64 `json:"categoryId" dc:"分类ID"`
AuthorId int64 `json:"authorId" dc:"作者ID"`
Status int `json:"status" dc:"状态"`
IsRecommended int `json:"isRecommended" dc:"是否推荐"`
Sort string `json:"sort" dc:"排序字段"`
}
type ListRes struct {
Total int `json:"total" dc:"总数"`
List []model.Book `json:"list" dc:"书籍列表"`
}
type AddReq struct {
g.Meta `path:"/book" tags:"Backend/Book" method:"post" summary:"新增小说"`
AuthorId int64 `json:"authorId" dc:"作者ID" v:"required"`
CategoryId int64 `json:"categoryId" dc:"分类ID" v:"required"`
Title string `json:"title" dc:"书名" v:"required"`
CoverUrl string `json:"coverUrl" dc:"封面图"`
Description string `json:"description" dc:"简介"`
Status int `json:"status" dc:"状态"`
Tags string `json:"tags" dc:"标签"`
IsRecommended int `json:"isRecommended" dc:"是否推荐"`
IsFeatured int `json:"isFeatured" dc:"是否精选"`
Language string `json:"language" dc:"语言"`
}
type AddRes struct {
Success bool `json:"success" dc:"是否成功"`
}
type EditReq struct {
g.Meta `path:"/book" tags:"Backend/Book" method:"put" summary:"编辑小说"`
Id int64 `json:"id" dc:"书籍ID" v:"required"`
AuthorId int64 `json:"authorId" dc:"作者ID" v:"required"`
CategoryId int64 `json:"categoryId" dc:"分类ID" v:"required"`
Title string `json:"title" dc:"书名" v:"required"`
CoverUrl string `json:"coverUrl" dc:"封面图"`
Description string `json:"description" dc:"简介"`
Status int `json:"status" dc:"状态"`
Tags string `json:"tags" dc:"标签"`
IsRecommended int `json:"isRecommended" dc:"是否推荐"`
IsFeatured int `json:"isFeatured" dc:"是否精选"`
Language string `json:"language" dc:"语言"`
}
type EditRes struct {
Success bool `json:"success" dc:"是否成功"`
}
type DelReq struct {
g.Meta `path:"/book" tags:"Backend/Book" method:"delete" summary:"删除小说"`
Id int64 `json:"id" dc:"书籍ID" v:"required"`
}
type DelRes struct {
Success bool `json:"success" dc:"是否成功"`
}
// 加入书架
type ShelfAddReq struct {
g.Meta `path:"/book/shelf/add" tags:"APP/Book" method:"post" summary:"加入书架"`
BookId int64 `json:"bookId" dc:"小说ID" v:"required"`
}
type ShelfAddRes struct {
Success bool `json:"success" dc:"是否成功"`
}
// 移除书架
type ShelfRemoveReq struct {
g.Meta `path:"/book/shelf/remove" tags:"APP/Book" method:"post" summary:"移除书架(支持批量)"`
BookIds []int64 `json:"bookIds" dc:"小说ID列表" v:"required"`
}
type ShelfRemoveRes struct {
Success bool `json:"success" dc:"是否成功"`
}
type HistoryRemoveReq struct {
g.Meta `path:"/book/history/remove" tags:"APP/Book" method:"post" summary:"移除阅读记录(支持批量)"`
BookIds []int64 `json:"bookIds" dc:"小说ID列表" v:"required"`
}
type HistoryRemoveRes struct {
Success bool `json:"success" dc:"是否成功"`
}
// App 获取书籍列表
type AppListReq struct {
g.Meta `path:"/book/app/list" tags:"APP/Book" method:"get" summary:"App获取书籍列表"`
Page int `json:"page" dc:"页码"`
Size int `json:"size" dc:"每页数量"`
IsRecommended bool `json:"isRecommended" dc:"是否推荐"`
IsFeatured bool `json:"isFeatured" dc:"是否精选"`
IsLatest int `json:"isLatest" dc:"是否最新"`
IsHot bool `json:"isHot" dc:"是否最热"`
CategoryId int64 `json:"categoryId" dc:"分类ID"`
Title string `json:"title" dc:"书名模糊搜索"`
AuthorId int `json:"authorId" dc:"作者ID"`
Language string `json:"language" dc:"语言"`
Sort string `json:"sort" dc:"排序字段"`
}
type AppListRes struct {
Total int `json:"total" dc:"总数"`
List []model.BookAppItem `json:"list" dc:"书籍列表"`
}
// App 获取书籍详情
type AppDetailReq struct {
g.Meta `path:"/book/app/detail" tags:"APP/Book" method:"get" summary:"App获取书籍详情"`
Id int64 `json:"id" dc:"书籍ID" v:"required"`
}
type AppDetailRes struct {
Id int64 `json:"id" dc:"书籍ID"`
CoverUrl string `json:"coverUrl" dc:"封面图"`
Rating float64 `json:"rating" dc:"评分"`
Title string `json:"title" dc:"标题"`
Description string `json:"description" dc:"简介"`
AuthorId int64 `json:"authorId" dc:"作者ID"`
Author model.AppAuthor `json:"author" dc:"作者信息"`
IsFeatured int `json:"isFeatured" dc:"是否精选"`
Language string `json:"language" dc:"语言"`
CategoryId int64 `json:"categoryId" dc:"分类ID"`
Category model.Category `json:"category" dc:"分类信息"`
Status int `json:"status" dc:"状态"`
WordsCount int `json:"wordsCount" dc:"字数"`
ChaptersCount int `json:"chaptersCount" dc:"章节数"`
ReadCount int64 `json:"readCount" dc:"阅读人数"`
CurrentReaders int64 `json:"currentReaders" dc:"在读人数"`
Tags string `json:"tags" dc:"标签"`
IsRecommended int `json:"isRecommended" dc:"是否推荐"`
HasRated bool `json:"hasRated" dc:"当前用户是否已评分"`
MyRating float64 `json:"myRating" dc:"当前用户评分未评分为0"`
HasRead bool `json:"hasRead" dc:"是否读过"`
ReadProgress int `json:"readProgress" dc:"阅读进度百分比"`
LastChapterId int64 `json:"lastChapterId" dc:"最近阅读章节ID"`
LastReadAt string `json:"lastReadAt" dc:"最近阅读时间"`
IsInBookshelf bool `json:"isInBookshelf" dc:"当前用户是否已加入书架"`
CreatedAt string `json:"createdAt" dc:"创建时间"`
UpdatedAt string `json:"updatedAt" dc:"更新时间"`
}
// App 用户评分
type AppRateReq struct {
g.Meta `path:"/book/app/rate" tags:"APP/Book" method:"post" summary:"App用户评分"`
BookId int64 `json:"bookId" dc:"书籍ID" v:"required"`
Rating float64 `json:"rating" dc:"评分(1-10分)" v:"required"`
}
type AppRateRes struct {
Success bool `json:"success" dc:"是否成功"`
}
type BookAppItem struct {
Id int64 `json:"id" dc:"书籍ID"`
CoverUrl string `json:"coverUrl" dc:"封面图"`
Rating float64 `json:"rating" dc:"评分"`
Title string `json:"title" dc:"标题"`
Description string `json:"description" dc:"简介"`
HasRated bool `json:"hasRated" dc:"当前用户是否已评分"`
MyRating float64 `json:"myRating" dc:"当前用户评分未评分为0"`
}
// 我的书籍列表
// =============================
type MyListReq struct {
g.Meta `path:"/book/app/my-books" tags:"APP/Book" method:"get" summary:"获取我的书籍列表"`
Type int `json:"type" dc:"类型1-正在读 2-已读完 3-历史记录" v:"required"`
Page int `json:"page" dc:"页码"`
Size int `json:"size" dc:"每页数量"`
Sort string `json:"sort" dc:"排序字段"`
}
type MyListRes struct {
Total int `json:"total" dc:"总数"`
List []model.MyBookItem `json:"list" dc:"书籍列表"`
}
// =============================
// 新增:单独修改精选状态和推荐状态
// =============================
type BookSetFeaturedReq struct {
g.Meta `path:"/book/set-featured" tags:"Backend/Book" method:"post" summary:"设置书籍精选状态"`
Id int64 `json:"id" dc:"书籍ID" v:"required"`
IsFeatured int `json:"isFeatured" dc:"是否精选" v:"required"`
}
type BookSetFeaturedRes struct {
Success bool `json:"success" dc:"是否成功"`
}
type BookSetRecommendedReq struct {
g.Meta `path:"/book/set-recommended" tags:"Backend/Book" method:"post" summary:"设置书籍推荐状态"`
Id int64 `json:"id" dc:"书籍ID" v:"required"`
IsRecommended int `json:"isRecommended" dc:"是否推荐" v:"required"`
}
type BookSetRecommendedRes struct {
Success bool `json:"success" dc:"是否成功"`
}
type BookSetHotReq struct {
g.Meta `path:"/book/set-hot" tags:"Backend/Book" method:"post" summary:"设置书籍热门状态"`
Id int64 `json:"id" dc:"书籍ID" v:"required"`
IsHot int `json:"isHot" dc:"是否热门" v:"required"`
}
type BookSetHotRes struct {
Success bool `json:"success" dc:"是否成功"`
}
type BookCoverImageReq struct {
g.Meta `path:"/book/coverImage" tags:"Backend/Book" method:"post" summary:"上传封面图"`
File *ghttp.UploadFile `json:"file" v:"required#请上传文件"`
}
type BookCoverImageRes struct {
ImageUrl string `json:"imageUrl" dc:"图片地址"`
}